Subject: Element - centric output
From: Maulik Modi <MModi@xxxxxxxxxx>
Date: Wed, 2 Jan 2002 17:48:35 -0600
|
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
|