You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Yori Sakakura <yo...@psteering.com> on 2001/02/02 23:51:48 UTC

Xalan-J 1 bug? - child:: matching attributes

I wasn't able to access archives at
http://xml-archive.webweaving.org/xml-archive-xalan so sorry if this is a
dupe. Sorry regardless if it turns out to be a non-issue.

	-Yori

Unexpected match on attributes with same name as elements in match patterns
regardless of attribute location (in elements) in the document hierarchy
using Xalan 1.2.2 with Xerces 1.2.2 & 1.2.3 (Sun JDK 1.3 on Win2k, Sun 1.2.2
on Linux).

Sample input:
<root>
	<strange attribute="value1">
		<child strange="value2"/>
		<child strange="value3"/>
	</strange>
	
	<should-be-ignored-but-isnt>
		<strange attribute="value4">
			<some strange="value5"/>
		</strange>
	</should-be-ignored-but-isnt>
</root>

Stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- Turns same named attributes values into elements??? -->
	<xsl:template match="/root/strange">
		<strange new-attribute="token">
			<xsl:apply-templates select="node()|@*"/>
		</strange>
	</xsl:template>

<!-- copy everything not matching to the output -->
	<xsl:template match="*|@*">
		<xsl:copy>
			<xsl:apply-templates select="node()|@*"/>
		</xsl:copy>
	</xsl:template>
</xsl:stylesheet>

Output:
<root>
	<strange new-attribute="token" attribute="value1">
		<child>value2</child>
		<child>value3</child>
	</strange>

	<should-be-ignored-but-isnt>
		<strange attribute="value4">
			<some>value5</some>
		</strange>
	</should-be-ignored-but-isnt>
</root>

I expected to see (only change is addition of new-attribute="token" to
root/strange):
<root>
	<strange new-attribute="token" attribute="value1">
		<child strange="value2"/>
		<child strange="value3"/>
	</strange>

	<should-be-ignored-but-isnt>
		<strange attribute="value4">
			<some strange="value5"/>
		</strange>
	</should-be-ignored-but-isnt>
</root>

but attributes named 'strange' had their values turned into child elements
instead, regardless of whether or not they were part of the nodeset selected
by the first template's match pattern.