Fix up some more xml tests and other small bugs
This commit is contained in:
@@ -59,6 +59,13 @@ func (p *XMLProcessor) ProcessContent(content string, path string, luaExpr strin
|
||||
}
|
||||
log.Printf("%#v", result)
|
||||
|
||||
modified := false
|
||||
modified = L.GetGlobal("modified").String() == "true"
|
||||
if !modified {
|
||||
log.Printf("No changes made to node at path: %s", node.Data)
|
||||
continue
|
||||
}
|
||||
|
||||
// Apply modification based on the result
|
||||
if updatedValue, ok := result.(string); ok {
|
||||
// If the result is a simple string, update the node value directly
|
||||
@@ -105,7 +112,7 @@ func (p *XMLProcessor) ToLua(L *lua.LState, data interface{}) error {
|
||||
for _, attr := range node.Attr {
|
||||
L.SetField(attrs, attr.Name.Local, lua.LString(attr.Value))
|
||||
}
|
||||
L.SetField(table, "attributes", attrs)
|
||||
L.SetField(table, "attr", attrs)
|
||||
}
|
||||
|
||||
L.SetGlobal("v", table)
|
||||
@@ -217,7 +224,7 @@ func updateNodeFromMap(node *xmlquery.Node, data map[string]interface{}) {
|
||||
}
|
||||
|
||||
// Update attributes if present
|
||||
if attrs, ok := data["attributes"].(map[string]interface{}); ok && node.Type == xmlquery.ElementNode {
|
||||
if attrs, ok := data["attr"].(map[string]interface{}); ok && node.Type == xmlquery.ElementNode {
|
||||
for name, value := range attrs {
|
||||
if strValue, ok := value.(string); ok {
|
||||
// Look for existing attribute
|
||||
|
Reference in New Issue
Block a user