xsl-list
[Top] [All Lists]

Re: [xsl] How to insert Root Element in XML Output

2006-05-03 06:47:46
Gary E. Daniels wrote:
Hi. Newbie here. I have an XSL Stylesheet that produces XML as output. How do I code the XSL sheet to add a Root Element to the outputted XML document? Below is an example of the current XML output and the desired XML output with the root element <foo>. Thanks.
Gary


Current XML Output-----

<?xml version="1.0" encoding="utf-8"?>

File #<field id="4"><label>File No.:</label><value>09-06-00120-01</value></field>| Address <field id="1001"><label>Property Address:</label><value>3901 N Hamilton Ave</value></field>|
City <field id="1002"><label>City:</label><value>Chicago</value></field>|
State <field id="1003"><label>State:</label><value>IL</value></field>|
Zip <field id="1004"><label>Zip:</label><value>60618</value></field>|
Neighborhood <field id="3051"><label>NEIGHBORHOOD (NAME):</label><value>North Center</value></field>|

==========================================================================

Desired XML Output------

<?xml version="1.0" encoding="utf-8"?>
<foo>
File #<field id="4"><label>File No.:</label><value>09-06-00120-01</value></field>| Address <field id="1001"><label>Property Address:</label><value>3901 N Hamilton Ave</value></field>|
City <field id="1002"><label>City:</label><value>Chicago</value></field>|
State <field id="1003"><label>State:</label><value>IL</value></field>|
Zip <field id="1004"><label>Zip:</label><value>60618</value></field>|
Neighborhood <field id="3051"><label>NEIGHBORHOOD (NAME):</label><value>North Center</value></field>|
</foo>

I don't know wat your XSL looks like; but you can probably get whhat you
want by adding a template rule like this:

<xsl:template match="/">
  <xsl:element name="foo">
  <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

--
Jack.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>