You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the namespace of an XML attributes is discarded
That could lead to undesirable behavior. Parsing the following XML : readXML("\<Data xmlns:ns=\"http://trivial\"\>\<Field name=\"A\" ns:name=\"a\"\>\</Field\>\</Data\>");
Lead to that : node: "Data"(["Field"( [], name="a")])
Only one of the two "name" attribute was kept.
Proposed solution
The namespace could be handled like this : node: "Data"(["Field"( [], default = [(name, "a")])] ns = [(name, "A")])])
Or like this : node: "Data"(["Field"( [], ("", "name") = "a", ("ns", "name") = "A"])
But there may be a more "Rascalest" way.
The "get" method provided by the XML module should also accept an optional parameter in order to precise the namespace required : get(node, "name") => "a" get(node, "name", "ns") => "A"
This allows us to search the attribute associated with the correct namespace and that doesn't break the backward compatibility of the get function.
The text was updated successfully, but these errors were encountered:
allow : in escaped qualified names, like so: \ns:name
substitute the : for - like so: \ns-name
I prefer the latter since it does not require adapting the Rascal syntax, but it's not so nice as the : solution. @PaulKlint@tvdstorm should have an opinion about this too..
Currently the namespace of an XML attributes is discarded
That could lead to undesirable behavior. Parsing the following XML :
readXML("\<Data xmlns:ns=\"http://trivial\"\>\<Field name=\"A\" ns:name=\"a\"\>\</Field\>\</Data\>");
Lead to that :
node: "Data"(["Field"( [], name="a")])
Only one of the two "name" attribute was kept.
Proposed solution
The namespace could be handled like this :
node: "Data"(["Field"( [], default = [(name, "a")])] ns = [(name, "A")])])
Or like this :
node: "Data"(["Field"( [], ("", "name") = "a", ("ns", "name") = "A"])
But there may be a more "Rascalest" way.
The "get" method provided by the XML module should also accept an optional parameter in order to precise the namespace required :
get(node, "name") => "a"
get(node, "name", "ns") => "A"
This allows us to search the attribute associated with the correct namespace and that doesn't break the backward compatibility of the get function.
The text was updated successfully, but these errors were encountered: