This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Checking value of a previous text node


with what you have described, it looks to me that you would want to group the names with quarter-names.. The following grouping method would help you.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:key name="name" match="/root/enrolledClasses/class" use="quarterName"/>
<xsl:template match="/">
<xsl:for-each select="/root/enrolledClasses/class[not(quarterName = preceding-sibling::class/quarterName)]">
<i><xsl:value-of select="quarterName"/></i><br/>
<xsl:for-each select = "key('name',quarterName)">
<xsl:value-of select="name"/><br/>
</xsl:for-each>
<hr/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

HTH
Vasu

From: "Ryan O'Leary" <ryan-portal@polyinteractive.com>
Reply-To: xsl-list@lists.mulberrytech.com
To: <XSL-List@lists.mulberrytech.com>
Subject: [xsl] Checking value of a previous text node
Date: Thu, 27 Jun 2002 20:48:20 -0700

Hi all. I've been having a lot of trouble trying to get this to work,
although I'm sure theres a simple answer. I have the following XML:

=== START XML ===

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <enrolledClasses>
        <class>
            <name>Behavior Disorders</name>
            <quarterName>Fall 2001</quarterName>
        </class>
        <class>
            <name>ADDITIONAL ENGR LAB</name>
            <quarterName>Summer 2002</quarterName>
        </class>
        <class>
            <name>SENIOR PROJECT</name>
            <quarterName>Summer 2002</quarterName>
        </class>
        <class>
            <name>C and UNIX</name>
            <quarterName>Spring 2002</quarterName>
        </class>
    </enrolledClasses>
</root>

===== END XML ======

And I would like to produce the following HTML:

===== START HTML =====

<i>Fall 2001</i><br />
Behavior Disorders <br />
<p>
<i>Summer 2002</i><br />
ADDITIONAL ENGR LAB<br />
SENIOR PROJECT<br />
<p>
<i>Spring 2002</i><br />
C and UNIX<br />
<p>

===== END HTML =====

I am having problems writing XSL that will recognize when the
quarterName value has changed and display the quarter only then. I've
tried all kinds of stuff, but I haven't gotten it to work. As a side
note, I can't rewrite the XML to group the classes by quarter because of
the way the XML gets populated.

If anyone could help me with some code that checks the current value of
quarterName against the last value to see if its changed, that would be
awesome!!

Thanks in advance.

- Ryan O'Leary
- ryan-portal@polyinteractive.com



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]