[xsl] creating nodes from text

Subject: [xsl] creating nodes from text
From: omprakash.v@xxxxxxxxxxxxx
Date: Wed, 6 Apr 2005 15:15:38 +0530
        I am working on an inverse transform where Iam trying to get back
the original xml from the transformed output. Towards this, Iam trying to
make all the text in certain places in the result into element nodes. Iam
facing a problem while adding attributes to the element Iam creating thus.

My input xml is as follows:

<a href="file:///N400002">(-)</a>slideshow
     <td>title</td><td>Sample Slide Show</td>
     <td>date</td><td>Date of publication</td>
     <td>author</td><td>Yours Truly</td>

The  text of the first td that is the child of /table/tr  (slideshow) is my
The attributes are stored 1 per row in the next td in a table of their own.

My xsl looks like this:

     <xsl:if test="*[1][name() = 'a'] and not(. = '')">

     <xsl:variable name="elemname" select="normalize-space(text())"/>

          <xsl:element name="{$elemname}">

          <xsl:for-each select="../*[2][name() = 'td']/*[1]/*[1]">

               <xsl:variable name="attrname" select="*[1]"/>
               <xsl:variable name="attrval" select="*[2]"/>

               <xsl:attribute name="{$attrname}">
               <xsl:value-of select="td[1]"/>



The problem is:

I am getting the error "Attribute '{$attrname}' outside of element.". Iam
only adding the attributes in a for-each to the slideshow element I have
The other parst I don't understand are, the above works (not considering
the above problem) only when I use wildcards in the for-each like
<xsl:for-each select="../*[2][name() = 'td']/*[1]/*[1]">.

The other question is do I need the variables or could I do without them.

Be much grateful for any help.


This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

Current Thread