This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Only child pattern -- XT bug or my failure?
- To: xsl-list at mulberrytech dot com
- Subject: Re: Only child pattern -- XT bug or my failure?
- From: Warren Hedley <w dot hedley at auckland dot ac dot nz>
- Date: Wed, 07 Jun 2000 16:26:21 -0400
- CC: Chris Powell <sooty at umich dot edu>
- Organization: Department of Engineering Science, The University of Auckland
- References: <Pine.GSO.4.10.10006071428000.687-100000@koolaid.umdl.umich.edu>
- Reply-To: xsl-list at mulberrytech dot com
Chris Powell wrote:
>
> Looking at the XSLT recommendation, I see
> that the correct match should be DOC/DIV[last()=1]. However, when
> documents have multiple divisions (that is, they are correctly marked up
> with no superfluous wrapping DIV), the first DIV gets matched and the
> template gets applied; siblings get left alone.
This isn't probably much help - based on the attached results, I can
only really suggest you try Saxon.
The template match you suggested is correct, and this may well be a bug
in XT - it definitely produced different results from Saxon.
Here's my input, XSLT and output.
---- input ----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document>
<document>
<doc>
<div>doc1-div1</div>
<div>doc1-div2</div>
</doc>
<doc>
<div>doc2-div1</div>
</doc>
<doc>
<div>doc3-div1</div>
<div>doc3-div2</div>
<div>doc3-div3</div>
</doc>
</document>
--- xslt ----
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="doc/div[last()=1]">
<xsl:value-of select="." />
<xsl:text> (</xsl:text>
<xsl:value-of select="position()" />
<xsl:text> - </xsl:text>
<xsl:value-of select="last()" />
<xsl:text>)
</xsl:text>
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
---- output with saxon 5.3.2 ----
<?xml version="1.0" encoding="utf-8" ?>
doc2-div1 (2 - 3)
---- output with xt 19991105 ----
<?xml version="1.0" encoding="utf-8"?>
doc1-div1 (2 - 5)
doc3-div2 (4 - 7)
Really wierd!
I've asked this before, but can someone explain why position()
and last() give the results they do in the Saxon output?
--
Warren Hedley
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list