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
Frank GriffoSubject: Add missing element and attribute set to output tree
Author: Frank Griffo
Date: 26 Oct 2009 12:19 AM
I have the following source XML data where the <period> elements are missing <category> sub-elements. Each period should have no more / no less than 3 <category> sub-elements with name attribute = {Labor, Travel, and Material}.

What XSL would convert the source below to the desired output?

Thanks
Frank

Sourece XML:

<?xml version="1.0" encoding="UTF-16"?>
<root>
<period>1
<category name="Labor" cost="76323" />
<category name="Material" cost="62" />
</period>
<period>2
<category name="Labor" cost="63652" />
<category name="Material" cost="123" />
</period>
<period>3
<category name="Labor" cost="78875" />
<category name="Travel" cost="7436" />
</period>
</root>

Desired Output XML:

<?xml version="1.0" encoding="UTF-16"?>
<root>
<period>1
<category name="Labor" cost="76323" />
<category name="Material" cost="62" />
<category name="Travel" cost="0"/>
</period>
<period>2
<category name="Labor" cost="63652" />
<category name="Material" cost="123" />
<category name="Travel" cost="0"/>
</period>
<period>3
<category name="Labor" cost="78875" />
<category name="Travel" cost="7436" />
<category name="Material" cost="0"/>
</period>
</root>

Posttop
(Deleted User) Subject: Add missing element and attribute set to output tree
Author: (Deleted User)
Date: 29 Oct 2009 02:00 PM
Hi Frank,
which version of Stylus Studio are you using, and which processor have you selected in the Scenario Dialog?

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.