You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/03/09 01:11:21 UTC

DO NOT REPLY [Bug 32360] - [jxpath] Default Namespace not handled correctly

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

http://issues.apache.org/bugzilla/show_bug.cgi?id=32360





------- Additional Comments From patrick@qantel.com  2006-03-09 00:11 -------
I found this discussion less confusing after I came up with some XSLT examples 
of the issues raised here.  I thought I'd share them here in case anyone else 
finds them useful. 

As I understand it, JXPathContext requires that a namespace be registered 
using registerNamespace() before it will match on an element inside that 
namespace, even if that namespace was the default namespace for the Object 
passed to newContext().  This is not unlike the code in "32360a.xsl".

Richard believes JXPathContext should provide methods to register a default 
namespace so that elements inside a namespace will match without requiring a 
namespace to be registered.  This would working something like the code 
in "32360b.xsl".

The implementation of XSLT on my machine causes "32360b.xsl" to 
produce "Element does not exist."  I checked the W3C spec 
[http://www.w3.org/TR/xslt#qname], and it says that "The default namespace is 
not used for unprefixed names."  So, just to be clear, the behavior Richard 
suggests would deviate from XSLT.

[32360.xml]
<?xml-stylesheet type='text/xsl' href='32360b.xsl'?>
<?xml version="1.0" encoding="iso-8859-1"?>
<test xmlns="http://test">
  <child-element />
</test>

[32360a.xsl]
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:foo="http://test">
<xsl:template match="/">
  <xsl:choose>
    <xsl:when test="foo:test/foo:child-element">
    Element exists.
    </xsl:when>
    <xsl:otherwise>
    Element does not exist.
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
</xsl:stylesheet>

[32360b.xsl]
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns="http://test" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <xsl:choose>
    <xsl:when test="test/child-element">
    Element exists.
    </xsl:when>
    <xsl:otherwise>
    Element does not exist.
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
</xsl:stylesheet>

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org