XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Gary DanielsSubject: How to set output order?
Author: Gary Daniels
Date: 14 Apr 2006 08:33 PM


Hi. Newbie here looking for some help. I need to have my output always in the same order. The XSL Stylesheet that follows, parses data from a "Multi-page" XML document. Each "Page" or node has an "@id" (W1S, W2S, W4S, W7S, WSA). Most of the documents that are parsed have nodes in this order, however, some have "page" or node W4S following "page" or node W7S, instead of node W2S. This causes a different sequence of elements, which, in turn, results in the output having a similarly different sequence. How would I be able to modify the XSL Stylesheet to "force" the output to always appear in the same sequence, regardless of the sequence of the elements in the XML document being parsed? Thanks in advance for your assistance.

Gary





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

<xsl:output method="text"/>

<xsl:template match="AppraisalForm">


<!-- Select specific Node or Form based on its id --><xsl:if test="@id='W1S'">
File #<xsl:value-of select="field[@id='4']/value"/>|
Address <xsl:value-of select="field[@id='1001']/value"/>|
City <xsl:value-of select="field[@id='1002']/value"/>|
</xsl:if>

<!-- Select a different specific Node or form based on its id --><xsl:if test="@id='W2S'">
Water <xsl:value-of select="field[@id='14116']/value"/>|
Sewer <xsl:value-of select="field[@id='14126']/value"/>|
Heat <xsl:value-of select="field[@id='14127']/value"/>|
</xsl:if>

<!-- Select a different specific Node or form based on its id --> <xsl:if test="@id='W4S'">
OAR SP <xsl:value-of select="field[@id='60293']/value"/>|
GIM SP <xsl:value-of select="field[@id='60291']/value"/>|
Sale Date <xsl:value-of select="field[@id='60016']/value"/>|</xsl:if>

<!-- Select a different specific Node or form based on its id --><xsl:if test="@id='W5S'">
Vac Percent <xsl:value-of select="field[@id='80090']/value"/>|</xsl:if>

<!-- Select a different specific Node or form based on its id --><xsl:if test="@id='W7S'">
Year <xsl:value-of select="field[@id='150955']/value"/>|
Source <xsl:value-of select="field[@id='152539']/value"/>|
Rental Inc <xsl:value-of select="field[@id='150982']/value"/>|
Laundry <xsl:value-of select="field[@id='150984']/value"/>|
</xsl:if>


<!-- Select a different specific Node or form based on its id --><xsl:if test="@id='WSA'">
OAR Val <xsl:value-of select="field[@id='97015']/value"/>|
GIM Val <xsl:value-of select="field[@id='97000']/value"/>|
Value <xsl:value-of select="field[@id='150615']/value"/>|
</xsl:if>


</xsl:template></xsl:stylesheet>

Posttop
Minollo I.Subject: How to set output order?
Author: Minollo I.
Date: 14 Apr 2006 08:58 PM
If you can rely on alphabetical order, you can add a root template that forces an order on the AppraisalForm template:

<xsl:template match="/">
<xsl:apply-templates select="//AppraisalForm">
<xsl:sort select="@id"/>
</xsl:apply-templates>
</xsl:template>

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.