You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/11/27 16:00:17 UTC
DO NOT REPLY [Bug 14897] New: -
Pattern of form "//A/B" selects B even if A is its grandparent
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=14897>.
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=14897
Pattern of form "//A/B" selects B even if A is its grandparent
Summary: Pattern of form "//A/B" selects B even if A is its
grandparent
Product: XalanJ2
Version: 2.4
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: org.apache.xpath
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: marco.roduit@tinext.com
As far as I understand from the XPATH specification (and other
documentation), the pattern "//A/B" should mean:
"select all B elements that have an A element as their parent"
The following XML document
<?xml version="1.0"?>
<root>
<content>
<container>
<list>
<list-entry>
This is a list entry
</list-entry>
</list>
</container>
</content>
</root>
with the following style sheet applied
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:template name="root">
Root
<xsl:apply-templates />
</xsl:template>
<xsl:template match="content">
Root - Content
<xsl:apply-templates />
</xsl:template>
<xsl:template match="//content/container">
Root - Content - Container
<xsl:apply-templates />
</xsl:template>
<xsl:template match="//content/list">
Root - Content - List (WRONG)
<xsl:apply-templates />
</xsl:template>
<xsl:template match="list-entry">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
produces the following output:
<?xml version="1.0" encoding="UTF-8"?>
Root - Content
Root - Content - Container
Root - Content - List (WRONG)
This is a list entry
As you note, there's no list element child of a content element;
the list element is actually the child of the container element.
If you change the template definitions in
<xsl:template match="/root/content/container">
...
<xsl:template match="/root/content/list">
...
everything works fine.