[xsl] problem adding a new element to an XML document using xsl:element...

Subject: [xsl] 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
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