I have a XSLT I've created to handle a particular xml document. However, now namespaces are being introduced in some, but not all of our documents. I'd like to use the same XSLT for these documents, however I'm having trouble modifying my stylesheet to be namespace agnostic.
It's been suggested previously to modify my xpaths to *[local-name()="ElementName"]
, however considering we've already made a stylesheet, this is very labor intensive.
In addition, I am aware I can set the xpath-default-namespace
to the particular namespace, but as mentioned earlier, I cannot simply set it to #all or a list of possible namespaces. I'm looking for a more effective solution and have the extension functions of the Saxon processor available to me. Any ideas? Thanks.
Have you considered pre-processing your XML documents?
You could remove all namespaces (be aware of possible clashes) and then process it using the existing XSL transformation.
Such an approach would have the advantage that you don't have to modify your XSLT at all. It stays readable (the *[local-name()='frob'] looks so awful) and maintainable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With