DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23484>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23484

XML with default namespace wrongly processed





------- Additional Comments From [EMAIL PROTECTED]  2003-09-29 15:39 -------
The FAQ is a bit terse. It should say more clearly that the real answer is that
you can't use default namespaces in your XPaths -- to reference a namespaced
node,  XPath and XSLT *MUST* use a prefix which is bound to that namespace.

In other words, change
  <xsl:template match="body">
to
  <xsl:template match="ns:body" xmlns:ns="http://your.namespace/goes/here";>
(More commonly, you'd define the prefix at the root of the stylesheet so it's
inherited and available everywhere.)

The next generation of the XPath and XSLT specs may introduce a feature which
would allow you to set default namespaces for your paths -- but then you'd have
to explicitly state which nodes are _not_ namespaced, so this may not simplify
life all that much.

Note that if the DTD sets a default namespace via an implied attribute, you've
got exactly the same situation and must handle it the same way.


If you need to handle both documents that do and don't set the default
namespace... well, that's non-namespace-aware processing, which is not what
XPath and XSLT are set up for. You can, however, force it by matching on * and
then using a predicate to text the localname or qname separately from their
namespace binding. This is NOT A RECOMMENDED SOLUTION -- you shouldn't be doing
non-namespace-aware processing these days -- but it's a workable kluge.

Reply via email to