G
Guest
I am having trouble figuring out how to make this work:
I have data being returned in a template (xml file) from a web interface.
In a simplified view one section of data might look like this.
<RESULTS>
<NAMES>
<RESULT>
<ADDRESS>some address here</ADDRESS>
<ALIASES>
<ALIAS>John Smith</ALIAS>
<ALIAS>J Smith</ALIAS>
<ALIAS>John Q Smith</ALIAS>
</ALIASES>
</RESULT>
<RESULT>
<ADDRESS>some other address here</ADDRESS>
<ALIASES>
<ALIAS>Betty Smith</ALIAS>
<ALIAS>B Smith</ALIAS>
<ALIAS>Betty R Smith</ALIAS>
</ALIASES>
</RESULT>
</NAMES>
<RESULTS>
What I am trying to do is assign each Address and Alias to a variable, which
I am able to do with the xsl template:
Using the following logic:
<xsl:for-each select="RESULTS/NAMES/RESULT">
<xsl:if test="position() = 1">
I can assign the Address to a respective variable, ie ResultAddress1 and
ResultAddress2.
When I try to do a nested for-each loop,
<xsl:for-each select="RESULTS/NAMES/RESULT">
<xsl:if test="position() = 1">
<xsl:for-each select="ALIASES">
<xsl:if test="position() = 1">
assign first Alias to a variable here
<xsl:if test="position() = 2">
assign second Alias to a variable here
<xsl:if test="position() = 3">
assign third Alias to a variable here
Unfortunately all I can get is the first alias, even if the name has 3
aliases, the test=position() = 1 is true for both loops.
---
How can perform a nested for-each loop using xsl and the sample data above.
In this model I would have 8 Variables defined to save data:
For results #1
ResultAddress1
Alias1_1
Alias1_2
Alias1_3
For results #2
ResultsAddress2
Alias2_1
Alias2_2
Alias2_3
Thanks for the help
J
I have data being returned in a template (xml file) from a web interface.
In a simplified view one section of data might look like this.
<RESULTS>
<NAMES>
<RESULT>
<ADDRESS>some address here</ADDRESS>
<ALIASES>
<ALIAS>John Smith</ALIAS>
<ALIAS>J Smith</ALIAS>
<ALIAS>John Q Smith</ALIAS>
</ALIASES>
</RESULT>
<RESULT>
<ADDRESS>some other address here</ADDRESS>
<ALIASES>
<ALIAS>Betty Smith</ALIAS>
<ALIAS>B Smith</ALIAS>
<ALIAS>Betty R Smith</ALIAS>
</ALIASES>
</RESULT>
</NAMES>
<RESULTS>
What I am trying to do is assign each Address and Alias to a variable, which
I am able to do with the xsl template:
Using the following logic:
<xsl:for-each select="RESULTS/NAMES/RESULT">
<xsl:if test="position() = 1">
I can assign the Address to a respective variable, ie ResultAddress1 and
ResultAddress2.
When I try to do a nested for-each loop,
<xsl:for-each select="RESULTS/NAMES/RESULT">
<xsl:if test="position() = 1">
<xsl:for-each select="ALIASES">
<xsl:if test="position() = 1">
assign first Alias to a variable here
<xsl:if test="position() = 2">
assign second Alias to a variable here
<xsl:if test="position() = 3">
assign third Alias to a variable here
Unfortunately all I can get is the first alias, even if the name has 3
aliases, the test=position() = 1 is true for both loops.
---
How can perform a nested for-each loop using xsl and the sample data above.
In this model I would have 8 Variables defined to save data:
For results #1
ResultAddress1
Alias1_1
Alias1_2
Alias1_3
For results #2
ResultsAddress2
Alias2_1
Alias2_2
Alias2_3
Thanks for the help
J