[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Element - centric output

Subject: Element - centric output
From: Maulik Modi <MModi@xxxxxxxxxx>
Date: Wed, 2 Jan 2002 17:48:35 -0600
element centric
Hi,

I have the following xml document and want element centric output. The input
document is:

<input "bunch of ns declarations...">
  <attrs>
	<s:AttributeType name="CustomerID" />
	<s:AttributeType name="CompanyName"/>
	<s:AttributeType name="ContactName"/>
	<s:AttributeType name="ContactTitle"/>
  </attrs>
  <data>
	<z:row CustomerID="ALFKI" ContactName="Maria Anders"
ContactTitle="Sales Representative" />
	<z:row CustomerID="ANATR" CompanyName="Ana Trujillo Emparedados y
helados" ContactName="Ana Trujillo" ContactTitle="Owner" />
  </data>
</input>

I want to output an element-centric XML from it. I also want to create leaf
elements in the output if the attribute does not exist in the data/row but
does exist as a required name in AttributeType/@name. For example, in the
above XML, I would like the leaf element created for CompanyName for the
first row. How can I acheive this? I already have the attribute to element
translation working. I only need help for generating the leaf element if the
attribute does not exist in the data set. 

Expected output:
<RESPONSES>
	<RESPONSE>
		<CustomerID>ALFKI</CustomerID>
		<CompanyName/>
		<ContactName>Maria Anders</ContactName>
		<ContactTitle>Sales Representative</ContactTitle>
	</RESPONSE>
	<RESPONSE>
		<CustomerID>ANATR</CustomerID>
		<CompanyName>Ana Trujillo Emparedados y
helados</CompanyName>
		<ContactName>Ana Trujillo</ContactName>
		<ContactTitle>Owner</ContactTitle>
	</RESPONSE>
</RESPONSES>

Thanks in advance for your help.

Maulik




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.