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)
-> + Add Condition check in a multi... (3)
-> + Eliminating Duplicates with XS... (3)
-> + Empty tags in XML (2)
-> + XML to XML transformations (5)
-> + XSLT problem (3)
-> + XSLT and Array (6)
-> + Problem with transforming XMLs... (3)
-> + Logging in XSLT? (3)
-> + svg can not view with msxml pr... (3)
-> - Newbie Sorting Question (5)
-> ->Newbie Sorting Question
-> ->Newbie Sorting Question
-> ->Newbie Sorting Question
-> ->Newbie Sorting Question
-> + xslt - get values from fist no... (5)
-> + RenderX logo at the buttom of ... (2)
-> + consolidate same nodes into on... (4)
-> + HOW DO I GET THE XSLT MAPPER? (2)
-> + Newbie - dublicating attribute... (2)
-> + Correct use of sum() (3)
-> + Using the sum() function (4)
-> + Prublem in XSLT (6)
-> + Newbie XPath Question (10)
-> + Reference to variable or param... (3)
-- Previous [1381-1400] [1401-1420] [1421-1440] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Jerry JanofskySubject: Newbie Sorting Question
Author: Jerry Janofsky
Date: 08 Aug 2006 01:38 PM
Please correct me if I am wrong...

I am writing an XSLT stylesheet to transform data from an XML document. I just realized that I need to make sure my XSLT creates the same output irrelevant of the order of sibbling elements in in XML doc.

For instance, what if I have the following address node:

<address>
<state>MA</state>
<zip>01757</zip>
<street>258 Main Street, Suite 212</street>
<city>Milford</city>
</address>

If my template is like the follwing then it comes out wrong. Does this mean I need to make sure the address element has its sub elements in the correct order or do I have to fix my template?

<xsl:template match="address">
<xsl:apply-templates />
</xsl:template>

Postnext
Ivan PedruzziSubject: Newbie Sorting Question
Author: Ivan Pedruzzi
Date: 08 Aug 2006 03:00 PM
Jerry,

<xsl:apply-template/> processes child nodes in the same order they are located in the input document.

what do you mean by "it comes out wrong"?

Could you please post a full example XSLT + input XML and the expected result?

Which XSLT processor are you running?
Which Stylus Studio build?

Thank You
Ivan Pedruzzi
Stylus Studio Team

Postnext
Jerry JanofskySubject: Newbie Sorting Question
Author: Jerry Janofsky
Date: 08 Aug 2006 03:50 PM
Ivan, I just meant the order of output wouldn't be City,State,Zip. I guess I know the answer now though. Thanks.

Postnext
Michael GrimleySubject: Newbie Sorting Question
Author: Michael Grimley
Date: 08 Aug 2006 03:33 PM
You have at least three options:

1. If you use a schema to validate your XML, you can ensure that the elements will always be in the order you expect.

2. Change your template to get the info you need in the order that you need it. For example:

a. <xsl:template match="address">
<xsl:apply-templates select="street"/>
<xsl:apply-templates select="city"/>
<xsl:apply-templates select="state"/>
<xsl:apply-templates select="zip"/>
</xsl:template>

b. <xsl:template match="address">
<p><xsl:value-of select="street"/>
<br/><xsl:value-of select="city"/>
<br/><xsl:value-of select="state"/>
<br/><xsl:value-of select="zip"/>
</xsl:template>

Posttop
Jerry JanofskySubject: Newbie Sorting Question
Author: Jerry Janofsky
Date: 08 Aug 2006 03:47 PM
Ok, thanks for the info.

   
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.