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
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext 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>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
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.