[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: trouble looping using xsl:for-each and xsl:if

Subject: RE: trouble looping using xsl:for-each and xsl:if
From: "Miller, Mark" <Mark.Miller@xxxxxxxxxxxxxxxx>
Date: Thu, 3 Dec 2009 15:39:13 -0500
RE:  trouble looping using xsl:for-each and xsl:if
Martin,

Your solution works perfectly!

Thanks for your help.

Mark J. Miller
MEADS International, Inc.


> -----Original Message-----
> From: Martin Honnen [mailto:Martin.Honnen@xxxxxx]
> Sent: Thursday, December 03, 2009 1:54 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  trouble looping using xsl:for-each and xsl:if
>
> Miller, Mark wrote:
> > I have gone round and round on this problem and seem to be getting
> > nowhere.
> > What do I have to change in my xsl file to get the desired output.
I
> > know I am close, but cannot see the forest for the trees.
> >
> > It seems like my xsl:if statements are being ignored after the first
> one
> > executes.  I do not understand why the first cell in correct and the
> > last cell is correct but all the in-between cells are in error.
>
> The xsl:if does not change the context node so you will need to select
> the relationship you are interested in into a variable and then use
> that
> variable to populate your table cells:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
> <xsl:template match="ematrix">
> <html>
> <body>
>    <table border='1'>
>    <tr>
>      <th>Name</th>
>      <th>B</th>
>      <th>C</th>
>      <th>L</th>
>    </tr>
>    <xsl:for-each select="businessObject">
>    <xsl:sort select="objectName"/>
>      <tr>
>        <td nowrap='nowrap'><xsl:value-of select="objectName"/></td>
>        <td>
>          <xsl:variable name="rs"
>
select="fromRelationshipList/relationship[relationshipDefRef
> = 'Subordinate Submittal' and
attributeList/attribute[name='Responsible
> IPT']/string = 'BMC4I']"/>
>          <xsl:if
> test="$rs">
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Due
> Customer']/datetime,1,10)"/></p>
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Promise
> Date']/datetime,1,10)"/></p>
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Submitted
> Date']/datetime,1,10)"/></p>
>          </xsl:if>
>        </td>
>        <td>
>          <xsl:variable name="rs"
>
select="fromRelationshipList/relationship[relationshipDefRef
> = 'Subordinate Submittal' and
attributeList/attribute[name='Responsible
> IPT']/string = 'CMR']"/>
>          <xsl:if
> test="$rs">
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Due
> Customer']/datetime,1,10)"/></p>
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Promise
> Date']/datetime,1,10)"/></p>
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Submitted
> Date']/datetime,1,10)"/></p>
>          </xsl:if>
>        </td>
>        <td>
>          <xsl:variable name="rs"
>
select="fromRelationshipList/relationship[relationshipDefRef
> ='Subordinate Submittal' and attributeList/attribute[name='Responsible
> IPT']/string = 'LAUNCHER']"/>
>          <xsl:if
> test="$rs">
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Due
> Customer']/datetime,1,10)"/></p>
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Promise
> Date']/datetime,1,10)"/></p>
>            <p><xsl:value-of
> select="substring($rs/attributeList/attribute[name='Submitted
> Date']/datetime,1,10)"/></p>
>           </xsl:if>
>        </td>
>      </tr>
>      </xsl:for-each>
>    </table>
> </body>
> </html>
> </xsl:template>
> </xsl:stylesheet>
> --
>
> 	Martin Honnen
> 	http://msmvps.com/blogs/martin_honnen/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.