[xquery-talk] Generating xhtml from xml in no namespace
mike at saxonica.com
Wed Dec 17 11:50:10 PST 2008
> This is surely a faq, but I'm interested in what people think
> is the right approach for this...
> The input is in no namespace, the required output is unprefixed xhtml:
> <html xmlns="http://www.w3.org/1999/xhtml">
> for $x in collection(...)/path/to/node
> For some reason the default namespace on the html element
> affects the xpath - which is different to xslt and a little
> odd to me...
> Is there something like xpath-default-namespace so I can
> clear the default namespace for the xpaths?
No, unfortunately not. I tried to get something like this in, but the
general tendency of the WG was resistance to making namespaces even more
complicated than they were already.
If you want the output to be in an unprefixed namespace, but the input is in
no namespace, then the only ways I know to achieve this are either
(a) to use computed element constructors to create all the output elements,
(b) to put all the path expressions into functions, rather than having them
nested within element constructors
I think it would have been better to have had two completely separate static
namespace contexts, one used for path expressions and one for constructed
elements, and for namespace declarations on constructed elements to affect
only the latter.
More information about the talk