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

RE: Sort Question

Subject: RE: Sort Question
From: "Simon, Jb" <jb.simon@xxxxxxxx>
Date: Mon, 06 Jun 2005 10:57:26 -0400
RE:  Sort Question
> -----Original Message-----
> From: omprakash.v@xxxxxxxxxxxxx [mailto:omprakash.v@xxxxxxxxxxxxx]
> Sent: Thursday, June 02, 2005 3:57 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Sort Question
> 

<snip>

> Next, the Range_Type should be
> 
> RANGE_TYPE ( UINT8, ColorType, Red, White ) ;
> 
> I can't for the life of me figure out how to restucture the template
> 
>            <xsl:template match="tblEnumeratedTypes_WC"
mode="range-macro">
> 
> 
> Ans: This one was a lot tougher. My original idea was to store the
sorted
> nodes in a variable and access the nodes using xpath expressions. But
this
> didn't work as I  found out to my surprise that the text output method
> does
> not allow you create elements not even create them and bind them to a
> variable. Then I  found the match template for tblEnumValues_WC node
was
> being called in sorted order and used position() arrive at the desired
> result. However, the stylesheet needs to receive the position of the
last
> node as a parameter or needs to compute it in a previous pass to allow
the
> stylesheet to scale.
> 
> 
> Hope this helps.
> 
> Cheers,
> prakash
> 
> 
> 
> <xsl:template match="tblEnumValues_WC" mode="makecopy">
> 
> 
> <xsl:choose>
> <xsl:when test="position() = 1">
>                      <xsl:variable name="Start">
>                                <xsl:call-template
name="removeSpaces">
>                                           <xsl:with-param name="text"
> select="EnumValueDescription"/>
>                                </xsl:call-template>
>                      </xsl:variable>
> 
> <xsl:value-of select="$Start"/>
> 
> </xsl:when>
> <xsl:when test="position() = last()">
>  <xsl:variable name="End" >
>  <xsl:call-template  name="removeSpaces">
>  <xsl:with-param name="text"
>           select="EnumValueDescription"/>
>  </xsl:call-template>
>  </xsl:variable>
> 
> , <xsl:value-of select="$End"/>) ;
> 
> </xsl:when>
> <xsl:otherwise>
> 
> </xsl:otherwise>
> </xsl:choose>
> 
> 

Prakash,

The above stylesheet works fine as long as there are more than 1 nodes.

If there is only one than below statement

> <xsl:when test="position() = last()">

Never gets evaluated. I am attempting to repair this now... any ideas ?

What I was thinking was something along the lines of the following
pseudo code, although I do not know how to implement it in xsl. I hope
the following makes some sense !

lastParameterWritten=false
Choose
When test="position()=1"
	Write first parameter
End when
When test="position()=last()"
	Write last parameter
	Set lastParameterWritten = true
End when
End Choose

If test="lastParameterWritten=false"
	Write currentParameter as last
End if


Thanks
Joe

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.