Re: Only child pattern -- XT bug or my failure?

Subject: Re: Only child pattern -- XT bug or my failure?
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Wed, 07 Jun 2000 16:26:21 -0400
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>


--- xslt ----
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="";

<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:template match="text()" />


---- 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:

Current Thread