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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.