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

RE: Comparing node for identity using union

Subject: RE: Comparing node for identity using union
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Wed, 19 Jan 2005 16:12:56 -0000
match template using union
> > The $pos is defined like
> >
> > 	<xsl:param name="pos" select="0"/>
>
> That's certainly a number, and since positions start at 1,
> xyz[$pos] should always be an empty sequence (node-set). If,
> as you say, one processor is behaving differently from all
> the others, then that's prima facie evidence of a bug.

I think it's only a number as long as it doesn't get overridden - as
soon as you pass in the value a parameter it becomes a string.  For
example this XML:

<group>
	<menu>1</menu>
	<menu>2</menu>
	<menu>3</menu>
	<menu>4</menu>
	<menu>5</menu>
	<menu>6</menu>
</group>

And this stylesheet:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="pos" select="5"/>

<xsl:template match="/">
  <xsl:apply-templates select="(//menu)[$pos]"/>
</xsl:template>

</xsl:stylesheet>

Transformed without specifying a parameter produces the result:

5

Pass in the parameter 'pos' a value of '5' and the result is:

123456

This is consistent across processors.

In XSLT 1.0 the number() function ensures $pos is treated as a number,
2.0 the 'as' attribute on the param does the job.

cheers
andrew

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.