I'd like to do something similar as asked here: how to include the node XML in my XSLT text output? or, shortly explained:
- input is XML
- convert using XSL to a different syntax (non-XML)
- copy an XML sub-tree verbatim to the output
Both options presented in the topic referenced above are interesting, but will not work, because my input XML doc uses (possibly multiple) namespaces and:
- when using xsl:output=text (answer 2) the namespaces of the input XML are lost. I can use name() instead of local-name() but then still the namespace declarations are missing. Is there a nice way of collecting the referred namespace declarations and insert them?
- if I use the xsl:output=xml way (answer 1), I get the namespaces in the generated XML properly, but then I somehow need to escape the quotes of the XML attributes - any idea how to do this?
- Another problem with solution 1 is, if XML-special chars like & are in the input XML, then the textual output has them still as & (which is of course correct but not what I need)
Example:
<bla:Library xmlns:bla="ns1" xmlns:blub="ns2">
<blub:Book id="123">
<Title>Python Does Everythig & more</Title>
<Author>Smith</Author>
</Book>
...
And, different from the original post, the result shall be (note the quoting and handling of the &). And, yes the output syntax in my case is different (not DB-related, therefore I need the quotes around the raw XML output), but to stick with the original example ...:
Python Does Everything & more|Smith|"<bla:Book xmlns:bla=\"ns1\" xmlns:blub=\"ns2\" id=\"123\"><blub:Title>Python Does Everythig & more</Title>Author>Smith</Author></Book>"
Seems as if this is quite impossible but maybe somebody knows a nice trick ... :-) Regards, tge