[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
xsl only child
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.