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

problem adding a new element to an XML document using

Subject: problem adding a new element to an XML document using xsl:element...
From: Garry Cronin <garry.cronin@xxxxxxxxxx>
Date: Thu, 23 Sep 2004 15:22:07 +0100
garry cronin
I'm trying to transform the following small XML file:

<?xml version = '1.0'?>
<ROWSET>
  <ROW num="1">
     <PARTNO>1735</PARTNO>
     <PARTNAME>Gizmo</PARTNAME>
  </ROW>
  <ROW num="2">
     <PARTNO>7364</PARTNO>
     <PARTNAME>Bowl</PARTNAME>
  </ROW>
</ROWSET>

into to this one

<?xml version = '1.0'?>
<ROWSET>
  *<TABLE>mytable</TABLE>*
  <ROW num="1">
     <PARTNO>1735</PARTNO>
     <PARTNAME>Gizmo</PARTNAME>
  </ROW>
  <ROW num="2">
     <PARTNO>7364</PARTNO>
     <PARTNAME>Bowl</PARTNAME>
  </ROW>
</ROWSET>

As you can see, all I want to do is use an XSL stylesheet to insert a new <TABLE> element and corresponding value in the output XML file, and leave everything else unchanged. Here's my stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>


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

 <xsl:template match="ROWSET">
   <xsl:element name="TABLE">
     <xsl:text>mytable</xsl:text>
     <xsl:apply-templates/>
   </xsl:element>
 </xsl:template>

</xsl:stylesheet>

When run, the output is:

<TABLE>mytable1735Gizmo7364Bowl</TABLE>

Any ideas what I'm doing wrong? It's important to note that I won''t necessarily know the names of the subelements of <ROW>, as these represent column names in an Oracle table.

thanks in advance
- Garry

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.