Tree xml logic

G

ghenaweb

I need to get this results with this xml tree.

Ciccio-Salvatore
lollo-sasa

How can I do using xsl with a for-each statement ??



<root>
<rossi>
<padre>
<nome>Ciccio</nome>
</padre>
</rossi>
<rossi>
<padre>
<nome>lollo</nome>
</padre>
</rossi>
<verdi>
<padre>
<nome>Salvatore</nome>
</padre>
</verdi>
<verdi>
<padre>
<nome>Sasa</nome>
</padre>
</verdi>

</root>
 
J

Joseph Kesselman

Describe the *logic* of what you want to do, not just the results.
Otherwise people are likely to give you solutions that don't work for
your next data file.
 
G

ghenaweb

Hi Joseph...


in primis I wriong the group.

in secundis...

If you have not the right solutions...
please dont write anything.

Thanks a lot.


Joseph Kesselman ha scritto:
 
G

Ghena

<xsl:for-each
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']//GroupList/Group/OutwardList/Outward"
<xsl:variable name="root"
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']/GroupList/Group/ReturnList/Return"
/>

<xsl:variable name="totale">
<xsl:choose>
<xsl:when test="Price/Amount">
<xsl:value-of select="number(Price/Amount) +
number($root/Price/Amount)"/>
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select="//Group/Price/Amount/text()"/>
</xsl:eek:therwise>
</xsl:choose>
</xsl:variable>

</xsl:for-each>


the problem is :

number($root/Price/Amount)
display always the same (first) value

I dont know how get the relative value of OutwardList/Outward with the
ReturnList/Return ones.

Perhaps using ancestor or some axes... ?
you could find the document here...

www.lastminutesud.it/test/901968736.xml
Thanks a lot.
 
J

Joseph Kesselman

Ghena said:
number($root/Price/Amount)
display always the same (first) value

Because $root is always the same set of nodes, and number() returns the
numeric value if the first node in that set.
I dont know how get the relative value of OutwardList/Outward with the
ReturnList/Return ones.

Yes, you need relative paths. The simplest solution is

<xsl:value-of select="number(Price/Amount) +
number(../../OutwardList/Outward/Price/Amount)"/>
 
G

Ghena

Perhaps is not clear....

Do you mean ?

<xsl:value-of select="number(Price/Amount) +
number(../../ReturnList/Return/Price/Amount)"/>

with your method I get two similar data...

number(Price/Amount) is equal to
.../../OutwardList/Outward/Price/Amount


Joseph Kesselman ha scritto:
 
J

Joe Kesselman

Ghena said:
number(Price/Amount) is equal to
../../OutwardList/Outward/Price/Amount

In that case, yes, you're in the context of the Outward element, and you
need to navigate up and back down to the Return to find the other value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,005
Messages
2,570,264
Members
46,859
Latest member
HeidiAtkin

Latest Threads

Top