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
Andrew RaynerSubject: Probably very simple.
Author: Andrew Rayner
Date: 05 Jan 2007 06:27 PM
Originally Posted: 05 Jan 2007 05:56 PM
Hello, I am very new to XML/XSLT this is the second/third day I have been using it.

I have an XML document with the tags

<stagelist>
<stage name="Main Stage">
<band>
<name></name>
<time></time>
</band>
</stage>
<stage>
etc....

In my XSL document i want to style the document so i can do an if statment saying if the stage name is "Main Stage" display these bands. Else if its anything else displays these bands.

in my xsl document so far i have.
<table width="60%">
<b><i><xsl:value-of select="stagelist/stage/@name"/></i></b>
<tr>
<th align="left"><u>Band Name</u></th>
<th align="left"><u>Time</u></th>
</tr>
<xsl:for-each select="stagelist/stage/band">
<xsl:sort select="time"/>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="time"/></td>
</tr>
</xsl:for-each>
</table>

So i want to show two tables, one with all the bands from the stage with the name attribute "Main Stage" and the rest afterwards.

Please can anyone help with this?

Many thanks.

Andy

Postnext
Minollo I.Subject: Probably very simple.
Author: Minollo I.
Date: 07 Jan 2007 09:11 PM
What Stylus Studio version, edition and build number are you running? (Help > About)

Postnext
James DurningSubject: Probably very simple.
Author: James Durning
Date: 08 Jan 2007 01:47 PM
If you want to list it per stage you could have your for-each loop reference each stage, eg.:
<xsl:for-each select="stagelist/stage">
<table width="60%">
<b><i><xsl:value-of select="@name"/></i></b>
<tr>
<th align="left"><u>Band Name</u></th>
<th align="left"><u>Time</u></th>
</tr>
<xsl:for-each select="band">
<xsl:sort select="time"/>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="time"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>

to conditionally select the stage 'Main Stage': at least 3 different ways:
1. Seperate for-each 's
<xsl:for-each select="stagelist/stage[@name='Main Stage']">
...
and <xsl:for-each select="stagelist/stage[@name <> 'Main Stage']">
for the rest.

2. Use templates:
<xsl:apply-templates select="stagelist/stage"/>
and have two templates
<xsl:template match="stage[@name='Main Stage']">
...
<xsl:template match="stage"> <!-- automatically falls to this if it doesn't match the first one -->

3. Same for-each, but use an <xsl:choose>
<xsl:for-each select="stagelist/stage">
<xsl:choose>
<xsl:when test="@name='Main Stage'">...</xsl:when>
<xsl:otherwise>...</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

At least one of these should work for you.

Posttop
Andrew RaynerSubject: Probably very simple.
Author: Andrew Rayner
Date: 09 Jan 2007 05:55 AM
Thanks, thats great

   
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.