starbuck
asked on
how to do a double loop with xsl:for-each??
I got a xml output like below and wanna display something following the rules:
stooren/stoor@present = 'T' and stooren/stoor@id = flora/TXT
How to work with xsl file? Thanks in advance.
<flora><TXT>034</TXT><flor a>
<flora><TXT>035</TXT><flor a>
<flora><TXT>036</TXT><flor a>
<stooren>
<stoor id="034" present="T"/>
<stoor id="035" present="F"/>
<stoor id="036" present="T"/>
</stooren>
stooren/stoor@present = 'T' and stooren/stoor@id = flora/TXT
How to work with xsl file? Thanks in advance.
<flora><TXT>034</TXT><flor
<flora><TXT>035</TXT><flor
<flora><TXT>036</TXT><flor
<stooren>
<stoor id="034" present="T"/>
<stoor id="035" present="F"/>
<stoor id="036" present="T"/>
</stooren>
ASKER
Hi Mike,
Thanks for your help. Based on above XML for the output I just display all elements value of flora child whoes TXT value is same with the id of stoor and 'T' value of present. In fact "T" means true and 'F' means false, TXT value is same with id value, and above xml results from 2 xml files. Now I just want to show the 'true' flora Do you understand it now? My email is enstbrest@yahoo.com that is also my MSN. Hope get help from you, XML expert.
regards,
Leon
Thanks for your help. Based on above XML for the output I just display all elements value of flora child whoes TXT value is same with the id of stoor and 'T' value of present. In fact "T" means true and 'F' means false, TXT value is same with id value, and above xml results from 2 xml files. Now I just want to show the 'true' flora Do you understand it now? My email is enstbrest@yahoo.com that is also my MSN. Hope get help from you, XML expert.
regards,
Leon
ASKER
Hi Mike,
I just tried your way but doesnt work very well. Below is my detailed XML file:
<?xml version = '1.0'?>
<index>
<flora num="1"><ACA>Kromhals</ACA ><TXT>0779 </TXT><PAO >AC</PAO>< /flora>
<flora num="2"><ACA>Gewone ossentong</ACA><TXT>0054</ TXT><PAO>C G</PAO></f lora>
<flora num="3"><ACA>Bernagie</ACA ><TXT>0147 </TXT><PAO >AC</PAO>< /flora>
<flora num="4"><ACA>Akkervergeet- mij-nietje </ACA><TXT >0840</TXT ><PAO>CD</ PAO></flor a>
<flora num="5"><ACA>Veldereprijs< /ACA><TXT> 1347</TXT> <PAO>C</PA O></flora>
<flora num="6"><ACA>Grote ereprijs</ACA><TXT>1358</T XT><PAO>AC </PAO></fl ora>
<flora num="7"><ACA>Grasklokje</A CA><TXT>01 98</TXT><P AO>C</PAO> </flora>
<SOORTEN>
<SOORT id="779" present="F"/>
<SOORT id="54" present="F"/>
<SOORT id="147" present="F"/>
<SOORT id="840" present="T"/>
<SOORT id="1347" present="F"/>
<SOORT id="1358" present="T"/>
<SOORT id="198" present="F"/>
</SOORTEN>
</index>
Could you give me a detailed XSL codes with some explaination? Many thanks.
regards,
Leon
I just tried your way but doesnt work very well. Below is my detailed XML file:
<?xml version = '1.0'?>
<index>
<flora num="1"><ACA>Kromhals</ACA
<flora num="2"><ACA>Gewone ossentong</ACA><TXT>0054</
<flora num="3"><ACA>Bernagie</ACA
<flora num="4"><ACA>Akkervergeet-
<flora num="5"><ACA>Veldereprijs<
<flora num="6"><ACA>Grote ereprijs</ACA><TXT>1358</T
<flora num="7"><ACA>Grasklokje</A
<SOORTEN>
<SOORT id="779" present="F"/>
<SOORT id="54" present="F"/>
<SOORT id="147" present="F"/>
<SOORT id="840" present="T"/>
<SOORT id="1347" present="F"/>
<SOORT id="1358" present="T"/>
<SOORT id="198" present="F"/>
</SOORTEN>
</index>
Could you give me a detailed XSL codes with some explaination? Many thanks.
regards,
Leon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way, I had to use the number() function because the @id and <TXT> don't exactly match because of the leading zero.
Regards,
Mike Sharp
Regards,
Mike Sharp
ASKER
Hi, Mike,
Thanks very much. It does work but now I am thinking about another way. Because the above XML is combined dynamicly from 2 servers. Now I include one result to another one. How to do it directly without combination. It is to use document() to do it? Like below?
<xsl:apply-templates select="document(www.abc.com/flora.asp?soorten=$soorten)/SOORTEN/SOORT[@present ='T']"/>
How to use it correctly?
regards,
Leon
Thanks very much. It does work but now I am thinking about another way. Because the above XML is combined dynamicly from 2 servers. Now I include one result to another one. How to do it directly without combination. It is to use document() to do it? Like below?
<xsl:apply-templates select="document(www.abc.com/flora.asp?soorten=$soorten)/SOORTEN/SOORT[@present
How to use it correctly?
regards,
Leon
<xsl:apply-templates select="document(concat('http://www.abc.com/flora.asp?soorten=', $soorten))/SOORTEN/SOORT[@ present='T ']"/>
<root>
<flora><TXT>034</TXT><flor
<flora><TXT>035</TXT><flor
<flora><TXT>036</TXT><flor
<stooren>
<stoor id="034" present="T"/>
<stoor id="035" present="F"/>
<stoor id="036" present="T"/>
</stooren>
</root>
and your current context is the <root> element:
<xsl:for-each select="stooren/stoor[@pre
<xsl:for-each select="../../flora[TXT = current()/@id]">
for each stoor, this selects the flora with the TXT element that's the same as the id attribute of the current stoor.
</xsl:for-each>
</xsl:for-each>
If you can be a bit more specific about what your desired output is (perhaps with an example), I can help you better. Also, I assume you're talking about a *single* XML document as in my example?
Regards,
Mike Sharp