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

RE: Sort Question

Subject: RE: Sort Question
From: omprakash.v@xxxxxxxxxxxxx
Date: Tue, 7 Jun 2005 11:24:37 +0530
xsl sort select call template
Hi,

   Sorry for the delay. Please use the following xsl to achieve what you
want.


<?xml version="1.0" encoding="ISO-8859-1"?>
<?altova_sps C:\Documents and Settings\simonj\My
Documents\us101\xml\Messages.sps?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan
="http://xml.apache.org/xalan"
>
           <xsl:output method="text"/>
           <xsl:strip-space elements="*"/>

           <xsl:param name="file" select=" 'MESSAGES.h' "/>

           <xsl:variable name="assignment" select=" ' = ' "/>
           <xsl:variable name="terminator" select="  ' ;' "/>

           <xsl:template match="dataroot">
                               <xsl:apply-templates select="node()"/>
           </xsl:template>


<!--
-->
<!-- This template matches an Enumerated Type                -->
<!--
-->
<!--           It creates a header for the type and then     -->
<!--           creates the C struct.
-->
<!--
-->

           <xsl:template match="tblEnumeratedTypes_WC" priority="1">
                     <xsl:choose>
                               <xsl:when test="1=position()">
                                          <xsl:call-template name
="SectionHeader">
                                                    <xsl:with-param
name="SectionName" >Enumerated Types</xsl:with-param>
                                          </xsl:call-template>
                               </xsl:when>
                     </xsl:choose>
                     <xsl:apply-templates select="." mode="doc"/>
                     <xsl:apply-templates select="." mode="struct"/>
                     <xsl:apply-templates select="." mode="range-macro"/>
           </xsl:template>


<!--
-->
<!--      This template is used to create the Section Headers
-->
<!--
-->

           <!-- Should Be Centered ?? -->
           <xsl:template name="SectionHeader">
                     <xsl:param name="SectionName"/>

//----------------------------------------------------------------------
----------------

//----------------------------------------------------------------------
----------------
           //        <xsl:value-of select="$SectionName"/>

//----------------------------------------------------------------------
----------------

//----------------------------------------------------------------------
----------------
           </xsl:template>



<!--
-->
<!--      This template creates the header for an enumerated Type
-->
<!--
-->

           <xsl:template match="tblEnumeratedTypes_WC" mode="doc">

//----------------------------------------------------------------------
----------------
           // Name                  : <xsl:apply-templates select
="EnumeratedType"/>
           // Description    : <xsl:apply-templates select="Description"/>


//----------------------------------------------------------------------
----------------
           </xsl:template>




<!--
-->
<!--      This template creates the structure for an enumerated Type
-->
<!--
-->
           <xsl:template match="tblEnumeratedTypes_WC" mode="struct">

           enum {
                               <xsl:apply-templates select
="tblEnumValues_WC">
                                          <xsl:sort select="EnumValue"/>
                               </xsl:apply-templates>
           }   ;
           </xsl:template>

<!--
-->
<!--      This template creates the line for each of the enumerations
within         -->
<!--      an Enumerated Type
-->
<!--
-->

           <xsl:template match="tblEnumValues_WC">
                     <xsl:call-template name="padSpaces">
                               <xsl:with-param name="text" >
                                          <xsl:call-template name
="removeSpaces">
                                                    <xsl:with-param name
="text"
select="EnumValueDescription"/>
                                          </xsl:call-template>
                               </xsl:with-param>
                               <xsl:with-param name="size"
>20</xsl:with-param>
                     </xsl:call-template>

                     <xsl:text> = </xsl:text>

                     <!-- If we are on the last line, dont add a "," or
carriage return -->
                     <xsl:value-of select="EnumValue"/>
                     <xsl:choose>
                               <xsl:when test="last()=position()">
                               </xsl:when>

                               <xsl:otherwise>
                                          <xsl:text>, &#x0a;
</xsl:text>
                               </xsl:otherwise>
                     </xsl:choose>

           </xsl:template>



<!--
-->
<!--      This template creates call to the RANGE_TYPE Macro for an
enumerated Type     -->
<!--
-->

           <xsl:template match="tblEnumeratedTypes_WC" mode="range-macro">

           <xsl:variable name="ET" select="EnumeratedType"/>

          RANGE_TYPE ( UINT8, <xsl:value-of select="$ET"/>,

                     <xsl:apply-templates select="tblEnumValues_WC" mode
="makecopy">
                     <xsl:sort select="EnumValue"/>
                     </xsl:apply-templates>

<!--
                     <xsl:variable name="Start">
                               <xsl:call-template name="removeSpaces">
                                          <xsl:with-param name="text"
select="(xalan:nodeset($vtblEnumValue)//EnumValueDescription)[1]"/>
                               </xsl:call-template>
                     </xsl:variable>
                               <xsl:variable name="End" >
                                          <xsl:call-template  name
="removeSpaces">
                                                    <xsl:with-param name
="text"
select="(xalan:nodeset($vtblEnumValue)//EnumValueDescription)[last()]"/>
                                          </xsl:call-template>
                               </xsl:variable>
           <xsl:variable name="ET" select="EnumeratedType"/>
           RANGE_TYPE ( UINT8, <xsl:value-of select="$ET"/>, <xsl:value-of
select="$Start"/>, <xsl:value-of select="$End"/> ) ;

-->

           </xsl:template>



<xsl:template match="tblEnumValues_WC" mode="makecopy">



<xsl:variable name="lastcheck">
<xsl:if test="last() = 1">
<xsl:value-of select="1"/>
</xsl:if>
</xsl:variable>


<xsl:choose>
<xsl:when test="position() = 1 or $lastcheck = 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:if test="$lastcheck=1">
);
</xsl:if>



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










</xsl:template>



<!--
-->
<!--
-->
<!--
-->


           <xsl:template name="removeSpaces">
                     <xsl:param name="text"/>
                     <xsl:value-of select="translate($text, '&#x20;', ''
)"/>
           </xsl:template>



<!--
-->
<!--
-->
<!--
-->


           <xsl:template name="padSpaces">
                     <xsl:param name="text"/>
                     <xsl:param name="size"/>
                     <xsl:variable name="spaces" select="'
'" />
                     <xsl:value-of select="$text"/>
                     <xsl:choose>
                               <xsl:when test="string-length($text) &lt;
$size">
                                          <xsl:value-of select="substring
($spaces,
1, $size - string-length($text) )"/>
                               </xsl:when>
                     </xsl:choose>
           </xsl:template>

</xsl:stylesheet>


Cheers,
Omprakash.V



This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

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.