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

Re: Checking value of a previous text node

Subject: Re: Checking value of a previous text node
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Fri, 28 Jun 2002 09:06:02 +0200
Re:  Checking value of a previous text node
Hello Ryan,

your problem is a really simlpe grouping problem. Have a look at http://www.dpawson.co.uk/xsl/sect2/N4486.html or at more special techniques like Muenchian Grouping at http://www.jenitennison.com/xslt/grouping/muenchian.xml.

The code for Muenchian Grouping:

<xsl:key name="classes" match="class" use="quarterName"/>

<xsl:template match="enrolledClasses">
<xsl:apply-templates select="classes[generate-id() = generate-id(key('classes', quarterName))]" mode="group"/>
</xsl:template>


<xsl:template match="classes" mode="group">
  <i><xsl:value-of select="quarterName"/></i><br/>
  <p>
    <xsl:apply-templates select="key('classes', quarterName)"/>
  </p>
</xsl:template>

<xsl:template match="classes" mode="all">
  <xsl:value-of select="name"/><br/>
</xsl:template>

(untested)

Regards,

Joerg


Ryan O'Leary wrote:
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@xxxxxxxxxxxxxxxxxxx


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


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.