SunQuest
           XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 1st, 2003, 02:10 AM
mitch22 mitch22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 mitch22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XML/XSL problem again

Hi again!
This message is corresponding to the "XML/XSL problem" posted.
Can anybody explain to me which is the difference from the next two codes ? (because with the first I obtain the results what I want but in the second when I use another template I didn't obtain the necessary reslts)

First code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<html> <body><h2>Report</h2>
<table border="1">
<caption valign="top">FRANCE</caption>
<tr bgcolor="#9acd32">
<th>Client</th>
<th>Agence</th>
<th>Proposition</th>
<th>PropositionM</th>
<th>Code</th>
</tr>
<xsl:for-each select="dataa/propo">
<tr>
<td><xsl:value-of select="client"/></td>
<td><xsl:value-of select="agence"/></td>
<td><xsl:value-of select="proposition"/></td>
<td><xsl:value-of select="propositionM"/></td>
<td><xsl:value-of select="code"/></td>
</tr>
</xsl:for-each>
</table>
</body></html>
</xsl:template>
</xsl:stylesheet>

Second code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body><h2>Report</h2>
<table border="1">
<caption valign="top">FRANCE</caption>

<xsl:apply-templates select="//propo"/>
</table></body> </html>
</xsl:template>

<xsl:template match="propo">

<xsl:for-each select="dataa/propo">
<tr>
<td><xsl:value-of select="client"/></td>
<td><xsl:value-of select="agence"/></td>
<td><xsl:value-of select="proposition"/></td>
<td><xsl:value-of select="propositionM"/></td>
<td><xsl:value-of select="code"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Thanks in advanced,
Mitch.

Reply With Quote
  #2  
Old August 1st, 2003, 02:22 AM
tank80's Avatar
tank80 tank80 is offline
php-oriented object
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: 0x9832053
Posts: 173 tank80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 49 sec
Reputation Power: 7
Send a message via ICQ to tank80
well....in the first template, the for-each loop searches for "dataa/propo" nodes under the root node "/".
In the second template the loop is looking for "dataa/propo" nodes under each "propo" node. In this one the "<xsl:apply-templates select="//propo"/>" tag is already doing what the for-each loop is intended to do, because it applies a template to every "propo" node, so you can remove the loop.

hope i've explained myself clearly

Last edited by tank80 : August 1st, 2003 at 02:24 AM.

Reply With Quote
  #3  
Old August 1st, 2003, 03:48 AM
mitch22 mitch22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 mitch22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks a lot tank80...
If you have time maybe you can help me and with the other "XML/XSL problem"(there I pushed and a xml code).

I made a template like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" media-type="text/html; charset=ISO-8859-1"/>
<xsl:template match="/">

<html><body>
<table border="1">
<caption valign="top">FRANCE</caption>
<tr bgcolor="#9acd32">
<th>Client</th>
<th>Agence</th>
<th>Proposition</th>
<th>PropositionM</th>
<th>Code</th>
</tr>
<h4>Vous avez</h4>

<xsl:apply-templates select="//dataa"/>

</body> </html>
</xsl:template>

<xsl:template match="dataa">
<xsl:for-each select="propo">
<xsl:sort select="propositionM" order="ascending"/>
<xsl:sort select="code" order="ascending"/>

<xsl:if test='client="Ana"'>
<xsl:if test='proposition="good"'>

<tr>
<td><xsl:value-of select="client"/></td>
<td><xsl:value-of select="agence"/></td>
<td><xsl:value-of select="proposition"/></td>
<td><xsl:value-of select="propositionM"/></td>
<td><xsl:value-of select="code"/></td>
</tr>

</xsl:if>
</xsl:if>
</xsl:for-each>
</table>

<!-- Now I want to show my SUM(..)
I tried like this: - I declared a variable
<xsl:variable name="total" select="sum(propo[client="Ana"][proposition="good"]/price)"/>
<B>Total Sum</B>: <xsl:value-of select="$total"/>
but it didn't worked
-->
</xsl:template>

So, I ordered for client "Ana" and proposition "good" by propositionM and code; now I want to show SUM(price) for the selected items. Can you (or anybody) tell me how should I do ?

Thanks again,
Mitch.

Reply With Quote
  #4  
Old August 1st, 2003, 03:56 AM
mitch22 mitch22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 mitch22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks a lot tank80...
If you have time maybe you can help me and with the other "XML/XSL problem"(there I pushed and a xml code).

My source code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" media-type="text/html; charset=ISO-8859-1"/>
<xsl:template match="/">

<html><body>
<table border="1">
<caption valign="top">FRANCE</caption>
<tr bgcolor="#9acd32">
<th>Client</th>
<th>Agence</th>
<th>Proposition</th>
<th>PropositionM</th>
<th>Code</th>
</tr>
<h4>Vous avez</h4>

<xsl:apply-templates select="//dataa"/>

</body> </html>
</xsl:template>

<xsl:template match="dataa">
<xsl:for-each select="propo">
<xsl:sort select="propositionM" order="ascending"/>
<xsl:sort select="code" order="ascending"/>

<xsl:if test='client="Ana"'>
<xsl:if test='proposition="good"'>

<tr>
<td><xsl:value-of select="client"/></td>
<td><xsl:value-of select="agence"/></td>
<td><xsl:value-of select="proposition"/></td>
<td><xsl:value-of select="propositionM"/></td>
<td><xsl:value-of select="code"/></td>
</tr>

</xsl:if>
</xsl:if>
</xsl:for-each>
</table>

<!-- Now I want to show my SUM(..)
I tried like this: - I declared a variable
<xsl:variable name="total" select="sum(propo[client="Ana"][proposition="good"]/price)"/>
<B>Total Sum</B>: <xsl:value-of select="$total"/>
but it didn't worked
-->
</xsl:template>

So, I ordered for client "Ana" and proposition "good" by propositionM and code; now I want to show SUM(price) for the selected items. Can you (or anybody) tell me how should I do ?

Thanks again,
Mitch.

Reply With Quote
  #5  
Old August 1st, 2003, 04:37 AM
tank80's Avatar
tank80 tank80 is offline
php-oriented object
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: 0x9832053
Posts: 173 tank80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 49 sec
Reputation Power: 7
Send a message via ICQ to tank80
let's try it...
first, check the quotes:
you have this
Code:
<xsl:variable name="total" select="sum(propo[client="Ana"][proposition="good"]/price)"/> 
<B>Total Sum</B>: <xsl:value-of select="$total"/> 


double quotes in the select attribute text are closing the attribute's quotes, so change it like this:
Code:
<xsl:variable name="total" select="sum(propo[client='Ana'][proposition='good']/price)"/> 
<B>Total Sum</B>: <xsl:value-of select="$total"/> 


also, as a general advice, always enclose attributes between double quotes " " and use single quotes in the text ' '

Last edited by tank80 : August 1st, 2003 at 04:39 AM.

Reply With Quote
  #6  
Old August 1st, 2003, 07:44 AM
mitch22 mitch22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 mitch22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your advice.
Now the code is working.

<xsl:template match="dataa">
<xsl:for-each select="propo">
<xsl:sort select="propositionM" order="ascending"/>
<xsl:sort select="code" order="ascending"/>

<xsl:if test='client="Ana"'>
<xsl:if test='proposition="good"'>

<tr>
<td><xsl:value-of select="client"/></td>
<td><xsl:value-of select="agence"/></td>
<td><xsl:value-of select="proposition"/></td>
<td><xsl:value-of select="propositionM"/></td>
<td><xsl:value-of select="code"/></td>
</tr>

</xsl:if>
</xsl:if>
</xsl:for-each>
</table>
<B>Total Sum: </B>: <xsl:value-of select="$total"/>

</xsl:template>

But now I have another problem: I want to write the informations grouped by propositionM(so I have many propositionM corresponding to "Ana" client and "good" proposition...
I want to display the info like this:
propositionM 1 goodAfternoon
client/agence/intervention/price (corresponding for"goodAfternoon)

propositionM 1 goodEvening
client/agence/intervention/price (corresponding for"goodAfternoon)

propositionM 1 goodMorning
client/agence/intervention/price (corresponding for"goodAfternoon)


Could you (or somebody else) to give me an idea to resolve this problem ?

Thanks again,
Mitch.

Reply With Quote
  #7  
Old August 1st, 2003, 07:46 AM
mitch22 mitch22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 mitch22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry! I want to write these informations:


propositionM 1 goodAfternoon
client/agence/intervention/price (corresponding for"goodAfternoon)

propositionM 1 goodEvening
client/agence/intervention/price (corresponding for"goodEvening)

propositionM 1 goodMorning
client/agence/intervention/price (corresponding for"goodMorning)

Thanks!

Reply With Quote
  #8  
Old August 4th, 2003, 01:27 AM
mitch22 mitch22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 mitch22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Did you know how could I modify a variable in XML ?

Thanks,
Mitch.

Reply With Quote
  #9  
Old August 4th, 2003, 03:01 AM
mitch22 mitch22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 mitch22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry, guys!
I found that in XML I can't modify a variable. And I know I wasn't very clear.

But I have this xml code:

<?xml version="1.0" ?>
<dataa>
<propo>
<client>Bambi</client>
<agence>Big Teddy</agence>
<proposition>badd</proposition>
<propositionM>baddGuy</propositionM>
<intervention>1</intervention>
<activite>z</activite>
<code>Mis1</code>
<price>475</price>
</propo>
<propo>
<client>Bambi</client>
<agence>Big Teddy</agence>
<proposition>badd</proposition>
<propositionM>baddGuy</propositionM>
<intervention>2</intervention>
<activite>x</activite>
<code>Mis2</code>
<price>205</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodAfternoon</propositionM>
<intervention>1</intervention>
<activite>a</activite>
<code>Mis1</code>
<price>200</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodAfternoon</propositionM>
<intervention>2</intervention>
<activite>a</activite>
<code>Mis2</code>
<price>250</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodAfternoon</propositionM>
<intervention>3</intervention>
<activite>d</activite>
<code>Mis7</code>
<price>350</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodAfternoon</propositionM>
<intervention>4</intervention>
<activite>d</activite>
<code>Mis2</code>
<price>50</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodMorning</propositionM>
<intervention>1</intervention>
<activite>a</activite>
<code>Mis1</code>
<price>350</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodMorning</propositionM>
<intervention>2</intervention>
<activite>b</activite>
<code>Mis2</code>
<price>400</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodMorning</propositionM>
<intervention>3</intervention>
<activite>b</activite>
<code>Mis7</code>
<price>250</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodMorning</propositionM>
<intervention>4</intervention>
<activite>e</activite>
<code>Mis1</code>
<price>550</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodEvening</propositionM>
<intervention>1</intervention>
<activite>b</activite>
<code>Mis1</code>
<price>250</price>
</propo>
<propo>
<client>Ana</client>
<agence>Little Marie</agence>
<proposition>good</proposition>
<propositionM>goodMorning</propositionM>
<intervention>2</intervention>
<activite>a</activite>
<code>Mis2</code>
<price>500</price>
</propo>
</dataa>

Noe I want to group "intervention" per "code" for "Ana" client and "good" proposition.
I want an html in which I'll have the information like this:


<client>Ana</client>
<proposition>good</proposition>
<propositionM>goodAfternoon

<intervention>1</intervention>
<activite>a</activite>
<code>Mis1</code>
<price>100<price>

<intervention>2</intervention>
<activite>a</activite>
<code>Mis2</code>
<price>250<price>

<intervention>3</intervention>
<activite>d</activite>
<code>Mis7</code>
<price>350<price>

<intervention>4</intervention>
<activite>d</activite>
<code>Mis2</code>
<price>50<price>
</propositionM>

<propositionM>goodEvening</propositionM>
...
...
...

Maybe now I am more clear...
Could anybody help me with any idea for this problem ?


Thanks in advanced,
Mitch.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML/XSL problem again


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway