This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Why doesn't <xsl:for-each select="*[position()&lt;last( )] work?


Thanks. Sorry for the typos. What output do you get?

I get "lightgrey lightblue lightyellow" if I use
"<xsl:text>&#xD;&#xA;</xsl:text>" instead of the "<br/>" line.

According to the slides I entered thet text from, the output should be:
  Jeff/555-1234/555-4321/lightgrey
  David/383-1234/383-4321/lightblue
  Roger/888-1234/888-4321/lightyellow

-----Original Message-----
From: Crowers, Steve [mailto:scrowers@liberate.com]
Sent: August 10, 2001 4:03 PM
To: xsl-list@lists.mulberrytech.com
Subject: RE: [xsl] Why doesn't <xsl:for-each
select="*[position()&lt;last( )] work?


off the top of my head, I see several things wrong with the sylesheet that
you included.

1) "</xsl:value-of select="*[last()]"/>" <-- not an end tag - remove the
first '/'.
2) spurious </xsl:for-each> right afterwards.

once I fixed that, it works through MSXML3 and XALAN.

HTH

Steve Crowers 
Software Engineer 


Liberate Technologies 
2 Walnut Grove, 
Suite 200 
Horsham, PA 19044 
Phone: 215-773-9400 x 9514 
Fax: 215-773-9401 
scrowers@liberate.com 
http://www.liberate.com 

 

"The good Lord sets definite limits on man's wisdom but sets no limits on
his stupidity -- and that's just not fair." --Konrad Adenauer, German
Chancellor 



-----Original Message-----
From: Hewko, Doug [mailto:Doug.Hewko@ccra-adrc.gc.ca]
Sent: Friday, August 10, 2001 3:44 PM
To: 'xsl-list@lists.mulberrytech.com'
Subject: [xsl] Why doesn't <xsl:for-each select="*[position()&lt;last()]
work?


I am unable to get an example to work from a tutorial I grabbed and I do not
know why. The troubling line is "<xsl:for-each
select="*[position()&lt;last()]">". 

I am using Cocoon2 to translate the code and the output is set to HTML,
which is why I substituted the Hex codes with "<br />". Would you know why I
am having problems?

********************************** Stylesheet *************************
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text"/>
<xsl:variable name="delimiter" select='"/"'/>

<xsl:template match="FitnessCenter">
	<xsl:for-each select="Member">
		<xsl:apply-templates select="."/>
		<br/>    <!--- I had to change this from &#xD;&#xA because
the hex codes are not recognized -->
	</xsl:for-each>
</xsl:template>

<xsl:template match="Member">
	<xsl:for-each select="*[position()&lt;last()]">
		<xsl:value-of select="."/>
		<xsl:value-of select="$delimiter"/>
	</xsl:for-each>
	</xsl:value-of select="*[last()]"/>
	</xsl:for-each>

</xsl:template>

</xsl:stylesheet>
******************************************* XML Document
************************
<?xml version="1.0" ?> 
<FitnessCenter>
<Member id="1" level="platinum">
<Name>Jeff</Name>
<Phone type="home">555-1234</Phone>
<Phone type="work">555-4321</Phone>
<FavoriteColor>lightgrey</FavoriteColor>
</Member>
<Member id="2" level="platinum">
<Name>David</Name>
<Phone type="home">383-1234</Phone>
<Phone type="work">383-4321</Phone>
<FavoriteColor>lightblue</FavoriteColor>
</Member>
<Member id="3" level="platinum">
<Name>Roger</Name>
<Phone type="home">888-1234</Phone>
<Phone type="work">888-4321</Phone>
<FavoriteColor>lightyellow</FavoriteColor>
</Member>
</FitnessCenter>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]