-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions to manage namespace usage #1045
Comments
I would suggest a function An example of a rule might be This is primarily about namespace URIs, not prefixes, on the assumption that prefixes don't actually matter. |
The goal of case 2 above is to replace use of a prefix with an explicit let $book:=
<d:book xmlns:d="http://docbook.org/ns/docbook">
<d:info>
<title xmlns="http://docbook.org/ns/docbook">Another fine book</title>
</d:info>
</d:book>
return rename-nodes($book, map{"Q{http://docbook.org/ns/docbook}*" : ""}) <book xmlns="http://docbook.org/ns/docbook">
<info>
<title>Another fine book</title>
</info>
</book> |
rename-nodes() definitely sounds useful, but it would not take the place of strip-namespaces() described in the link in #3 in BaseX. That function, when passed an empty string, will remove all namespaces. With rename-nodes(), you'd have to explicitly specify all namespaces in the doc to produce the same behavior. |
This is related to #266 |
The CG at the F2F meeting in Prague conclude that several users have asked for this, and it isn't straight-forward in XQuery, so we should do something to address it. |
Prior to saving XML generated in XQuery I often tweak the namespace usage.
This makes the XML lighter and clearer for the casual reader and is sometimes mandated by users and systems.
I think providing builtin solutions for these cases would ease these tasks.
Common cases are:
Remove unused prefixes
Example: the function presented at https://stackoverflow.com/questions/23002655/xquery-how-to-remove-unused-namespace-in-xml-node
Make a namespace the default wherever it is used.
Example:
functx:change-element-ns-deep($nodes,$targetns,"")
See http://www.xqueryfunctions.com/xq/functx_change-element-ns-deep.html
Remove the use of all/some namespaces
Example: BaseX https://docs.basex.org/wiki/Utility_Module#util:strip-namespaces
A somewhat related issue #266
The text was updated successfully, but these errors were encountered: