tags:

views:

91

answers:

2

I have a xml file like this

<Root>
 ...
 <x></x>
 <node>
  ...
  <x></x>
  <y></y>
 </node>
</Root>

My xslt is

<xsl:template match="/">
 <!-- proceed the treatment of the statement before x-->
 <tr>
  <xsl:apply-templates match="Root/x"/>
 </tr>
 <tr>
  <xsl:apply-templates match="Root"/>
 </tr>
</xsl:template>

<xsl:template match="x">
  ...
</xsl:template match="x">

<xsl:template match="Root">
 <!--Proceed the treatment of the statement before x-->
 <tr>
  <xsl:apply-templates match="x"/>
 </tr>
 <!--Deal with y-->

The template which matches "/" will create a table and fill it with all the nodes in the xml file. x can appear in every element like "node" and maybe different each time. "node" can also appear several times with different content.

But when I use this xslt, after dealing with x, it creates a new table for the elements after x, So node will be in a new table and also for y.

Does anyone know how to do? Thank u

A: 

To divo,

match="x" template deals with the child elements of "x". Sorry for making you misunderstand, i just ignored the code for creating the table. The table is created in the match="/" template. Thanks

+1  A: 

It looks like you are processing stuff in your "/" template, then processing it all again in the "Root" template, since the "/" template explicitly applies the Root template as well.

Try deleting the definition of the "/" template and just doing all the work in the template for "Root"

Bill Michell