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

 
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.