Tjerk Wolterink <tj***@wolterinkwebdesign.com> writes:
IU have the following xsl root element:
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:page="http://www.wolterinkwebdesign.com/xml/page"
xmlns:xc="http://www.wolterinkwebdesign.com/xml/xcontent">
Well how do i select the xhtml namespace with xpath
I need it to use in a xpath expression like this:
*[namespace-uri(.) == namespace::xc]
But namespace::xc' should be the namespace of xhtml. Pleas help
since it's a constant you don't need to extract it from the source
you can just use
*[namespace-uri(.) = 'http://www.w3.org/1999/xhtml']
although as I said earlier it's simpler and more efficient (probably) to
write that as
h:*
and add
xmlns:h="http://www.w3.org/1999/xhtml"
to your xsl:stylesheet.
even in the xc case
*[namespace-uri(.) = namespace::xc]
is rather dangerous as it forces a dependency on the prefixes used in
the source, whereas normally in XPath a source document can use any
prefix.
given your xsl:stylesheet above then the Xpath
xc:*
selects any element in the namespace
http://www.wolterinkwebdesign.com/xml/xcontent
which is what you want.
However
*[namespace-uri(.) = namespace::xc]
selects any element whose namespace is bound to the prefix xc
in the source file. (So it might match MathML or XHTML or SVG or any
other namespace, if that namespace happens to be bound to the prefix xc
in the document)
David