I have a set of XML files that I process using an XSL transform. They have a default namespace, so my XSL transform should contain a declaration:
XPath-default-names = "urn: CZ-P-IS-bav-XML-NS: data-1.2.2"
The problem is that this value changes from time to time, and my conversion suddenly stops working until I look at an example from a new file, extract this namespace identifier and put it in the conversion, as a result of which the conversion stops working for old files. Is there a way to pass this as a parameter or set it somehow at runtime? I tried parameter syntaxes that I searched in various tutorials, but no one worked for that specific use.
I searched all kinds of forums and found links to the XSL agnostic coding namespace, but didn't understand how to do this. Ivan Williams' book, XSLT and Xpath, states that the default namespace must be declared, or you don’t get anything in the output stream, as it worked for me. But I really do not want to regularly change this manually, I want to give the user something that will work, without constant attention from me.
The only reliable way that I have invented so far is to use a standard programming language to open both an XML source and XSL transform as text files, extract a URI from an XML source, insert it into an XSL transform, close both files, and then, finally run the actual conversion. It works, but incredibly expensive, at least for my taste. How can I deal better with changing namespaces by default?
Pete
source
share