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

Re: recursive function?

Subject: Re: recursive function?
From: "Werner, Wolfgang" <mail@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Jan 2005 09:27:37 +0100
xsl recursive function
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

this should do.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
~  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
~  <xsl:template match='/Result'>
~    <xsl:for-each select='Person[City]'>
~      <xsl:value-of select='Name'/>
~      <xsl:text> - </xsl:text>
~      <xsl:value-of select='City'/>
~      <xsl:text>&#10;</xsl:text>
~    </xsl:for-each>

~    <xsl:if test='Person[not(City)]'>
~      <xsl:text>Persons not connected to city</xsl:text>
~      <xsl:text>&#10;</xsl:text>
~    </xsl:if>
~    <xsl:for-each select='Person[not(City)]'>
~      <xsl:value-of select='Name'/>
~      <xsl:text>&#10;</xsl:text>
~    </xsl:for-each>
~  </xsl:template>
</xsl:stylesheet>

Btw, Bart and Lisa are - of course - connected to Springfield. Tsss ;-)

hth,
Wolfgang

Tore Stensrud wrote:
| A simple version of my Xml looks like this;
|
| <Result>
|
| <Person>
|  <Name>Pete</Name>
|  <City>New York</City>
| </Person>
|
| <Person>
|  <Name>Tom</Name>
|  <City>Chicago</City>
| </Person>
|
| <Person>
|  <Name>Lisa</Name>
| </Person>
|
| <Person>
|  <Name>Bart</Name>
| </Person>
|
| </Result>
|
|
| I would like mye page to look something like this:
|
| Pete - New York
| Tom - Chicago
|
| People not connected to city:
| Lisa
| Bart
|
|
| In my for-each Person loop I know i can check if City exists and if not
| write the line "People not  connected to city:". But how can I do this
| only once - before the first person not having a City node? (The ones
| without City will always come last in the listing). I guess I will have
| to use a recursive funcion, but how will this work when I'm using the
| for-each looping through the records?
|
| Thanks
|
| Tore
|
| _________________________________________________________________
| MSN Hotmail http://www.hotmail.com Med markedets beste SPAM-filter.
Gratis!
|
|
|
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB9LF5qjaicDyx8o8RAuS/AJ9TF4anw7xTgAkMfra4MDIkrPfYPwCdHUDt
FBevtT9ridj+8jm3AvJOTjs=
=TRqA
-----END PGP SIGNATURE-----

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.