|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I have the xml and xsl below and the result when transformed that I'm trying to get is the following order of species. Is this even possible through xslt? I don't know if I'm approaching this the right way with a recursive template, I cannot find a way to pass the value of from of call of the template to the next. Any help or tips would be appreciated.
Order of: human Order of: human, ape Order of: human, ape, monkey <?xml version="1.0" encoding = "ISO-8859-1"?> <?xml-stylesheet type = "text/xsl" href="transform.xsl"?> <species> <animal name = "lizzard" order = "reptile" id = "1"></animal> <animal name = "monkey" order = "primate" id = "2"></animal> <animal name = "ape" order = "primate" id = "3"></animal> <animal name = "human" order = "primate" id = "4"></animal> <animal name = "crockadile" order = "reptile" id = "5"></animal> </species> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:variable name = "limit" select = "count(species/animal[@order='primate'])" /> <xsl:variable name = "order-of" select = "'Order of: '" /> <xsl:template match = "species/animal" name = "printorder"> <xsl aram name = "header" select = "$order-of" /><xsl aram name = "count" select = "0" /><xsl:if test = "@order = 'primate'"> <xsl:for-each select = "@name"> <xsl:variable name = "nextname" select = "." /> <xsl:variable name = "newtext" select = "concat($header,$nextname)" /> <xsl:value-of select = "$newtext" /> <br /> <xsl:if test = "$count <= $limit"> <xsl:call-template name = "printorder" > <xsl:with-param name = "header" select = "$newtext" /> <xsl:with-param name = "count" select = "$count + 1" /> </xsl:call-template> </xsl:if> </xsl:for-each> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > recursive template problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|