This is a discussion on "[HELP] XSL silly question" within the Other Programming Languages section. This forum, and the thread "[HELP] XSL silly question are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[HELP] XSL silly question
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Hi, I am a newbie in XML and XSL, and having the following XSL question.
The XML data: <document> <segment Id="A"> <type Id="A01">Blue</type> <type Id="A02">Water</type> </segment> <segment Id="A"> <type Id="A01">Green</type> <type Id="A02">Grass</type> </segment> </document> Problem: I would like to select the value of "A02" when the "A01" is Green. How can it be implemented in XSL? Any help will be much appreciated!! Windbizz from HK |
|
|
|
#2
|
|||
|
|||
|
Re: [HELP] XSL silly question
Hello,
please try following xsl for your problem.... <?xml version="1.0"?> <xsl:stylesheet xmlns <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="segment"> <P> Segment matched<xsl:value-of select="@Id"/> <xsl:for-each select="type"> <xsl:if test=".='Green' and @Id='A01'"><br> Value of A02 when A01 is Green:</br> <xsl:for-each select="../type"> <xsl:choose> <xsl:when test="@Id='A02'"> <xsl:value-of select="."/> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:if> </xsl:for-each> </P> </xsl:template></xsl:stylesheet> Does this solve your problem? Regards, |
![]() |
| Tags |
| help, xsl, silly, question |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Silly Golf | jimboready | Free Web Site Critique | 2 | Feb 29th, 2008 13:57 |
| Help!! A silly Question | nutbolt | Flash & Multimedia Forum | 4 | Feb 7th, 2007 16:30 |
| Silly Question | ScottR | PHP Forum | 3 | Nov 4th, 2006 21:14 |
| Probably a VERY silly question but... | dharma | Web Page Design | 6 | Sep 4th, 2006 10:33 |
| very silly and easy question | saltedm8 | Web Page Design | 2 | Aug 22nd, 2006 22:35 |