XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
h dixonSubject: Using a template instead of choose?
Author: h dixon
Date: 11 Apr 2007 10:15 AM
Originally Posted: 11 Apr 2007 10:14 AM
This table illustrates several products that are sold in random locations along with the various prices for each location.

loc1 loc2 loc3 loc4
-------------------------
prod1 | 10.00 12.00
prod2 | 11.00 11.00 10.00
prod3 | 12.00


The XML for this table is:

<price_summ>
<prod name="prod1">
<loc name="loc1">
<price>10.00</price>
</loc>
<loc name="loc3">
<price>12.00</price>
</loc>
</prod>
<prod name="prod2">
<loc name="loc1">
<price>11.00</price>
</loc>
<loc name="loc2">
<price>11.00</price>
</loc>
<loc name="loc4">
<price>10.00</price>
</loc>
</prod>
<prod name="prod3">
<loc name="loc2">
<price>12.00</price>
</loc>
</prod>
</price_summ>

I can apply a template on <prod> and would like to do so on <loc>, but how do I fill-in the location cells that do not have a value.

I've used the algorithm listed below, but THERE HAS TO BE A BETTER WAY!

(BTW, the alorithm below is an example of my procedural thinking.)

Any ideas?

template select="prod"

<tr>
<td>value-of select="prod/@name"</td>

choose
when select="loc[@name="loc1"]
<td>value-of "loc[@name="loc1]/price</td>
/when
other
<td>&nbsp;</td>
/other
/choose
choose
when select="loc[@name="loc2"]
<td>value-of "loc[@name="loc2]/price</td>
/when
other
<td>&nbsp;</td>
/other
/choose
choose
when select="loc[@name="loc3"]
<td>value-of "loc[@name="loc3]/price</td>
/when
other
<td>&nbsp;</td>
/other
/choose
choose
when select="loc[@name="loc4"]
<td>value-of "loc[@name="loc4]/price</td>
/when
other
<td>&nbsp;</td>
/other
/choose

</tr>
/template


Unknowndel_me.txt
formated text of the message

Posttop
(Deleted User) Subject: Using a template instead of choose?
Author: (Deleted User)
Date: 13 Apr 2007 04:12 AM
I don't think that your problem can be solved by applying a template, as you want to force both a display order and a default value; you could play with xsl:key to simulate a grouping operation, but given that you are just handling 4 locations, your code could be the quickest way to achieve it.

Alberto

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.