[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] save elments to an array and use later


Subject: Re: [xsl] save elments to an array and use later
From: henry human <henry_human@xxxxxxxx>
Date: Tue, 3 Dec 2013 10:22:12 +0000 (GMT)

thanks Martin
Now what if the conditon to save those elements is a little
different:
Example:
<root>
.....
 <child>
    <transfer>N</transfer>
   
<station>I</station>
    <test>A</test>
 <test1>A</test1>
<test2>O</test2>  
 <lement1>F</element1>  
<lement2>W</element1>  
<lement3>W</element3>  
</child> 
 <child>
    <transfer>F</transfer>
    <station>B</station>
   
<test>M</test>  
  <test1>A</test1> 
<test2>P</test2> 
 <lement1>P</element1>
 <lement2>F</element2> 
<lement3>F</element3> 
</child>
........
</root>
 
 if
test = 'A' and element1 = 'F' or test1 = 'A' and element2 = 'F' or test3 = 'A'
and element3 = 'F' .....
 
 
 



Martin Honnen <Martin.Honnen@xxxxxx> schrieb
am 11:04 Dienstag, 3.Dezember 2013:
henry human wrote:

>
> I want to save
specific child elements from the xml below to an array element and later loop
over the array.
> For example the element I am interested in is those with
<test>A</test>
> Any suggestion?
> Thanks
>
> <root>
>      <child>
>     
<transfer>J</transfer>
>      <station>B</station>
>      <test>C</test>
>
</child>
>   <child>
>      <transfer>N</transfer>
>      <station>I</station>
>      <test>A</test>
> </child>
>   <child>
>      <transfer>F</transfer>
> 
    <station>B</station>
>      <test>M</test>
> </child>
>   <child>
>     
<transfer>F</transfer>
>      <station>B</station>
>      <test>P</test>
>
</child>
>   <child>
>      <transfer>H</transfer>
>      <station>G</station>
>      <test>A</test>
> </child>
> </root>

/root/child[test = 'A'] gives you
the elements, if you want to store 
them use

<xsl:variable name="v1"
select="/root/child[test = 'A']"/>

in XSLT. The value of the variable is a
node set (XSLT 1.0) or sequence 
(XSLT 2.0) of `child` elements. XSLT does not
have arrays.


Current Thread
Keywords