[xsl] Applying a transform to a tranform

Subject: [xsl] Applying a transform to a tranform
From: "Todd Kleine" <tkleine@xxxxxxxxxxxxx>
Date: Tue, 9 Sep 2003 17:04:31 -0400
I have a situation where I would like apply a transform to the transform of
an xml document.  Is there a way to do this in one xslt document?

For example the original xml looks like

<rowset>
  <row>
    <id>1</id>
    <value>value 1</value>
    <parent>0</parent>
  </row>
  <row>
    <id>2</id>
    <value>value 2</value>
    <parent>1</parent>
  </row>
  <row>
    <id>3</id>
    <value>value 3</value>
    <parent>0</parent>
  </row>
</rowset>

The first transform (which I have written and works) results in:

<tree>
  <branch>
     <id>1</id>
     <value>value 1</value>
     <branch>
        <id>2</id>
        <value>value 2</value>
     </branch>
  </branch>
  <branch>
    <id>3</id>
    <value>value3</value>
  </branch>
</tree>

Now in the same xslt document I would like to transform this into the html
code to represent a "tree" control.  I have written the transform document
to do this and it works when supplied with an xml document of the
"tree/branch" type.  The problem I am having is making the first transform
happen on the original document and then the second transform on the first
transform results.

I thought the following logic would work but it doesn't

<xsl:apply-templates select="rowset"/>  -- to transform into tree like xml
<xsl:apply-templates select="tree"/> -- to transform into html tree control

It appears as though this is transforming the original doc in both instances
(i.e. the rowset template select doesn't "pass" the results of its transform
forward).

Is it possible to make the second transform use the results of the first in
the same doc??
Thanks in advance!






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread