[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] creating nodes from text
Hi, 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: <table> <tr> <td> <a href="file:///N400002">(-)</a>slideshow </td> <td> <table> <tr> <td>title</td><td>Sample Slide Show</td> </tr> <tr> <td>date</td><td>Date of publication</td> </tr> <tr> <td>author</td><td>Yours Truly</td> </tr> </table> </td> <td> <text></text> </td> </tr> The text of the first td that is the child of /table/tr (slideshow) is my element. 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]"/> </xsl:attribute> </xsl:for-each> </xsl:element> 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 created. 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. Cheers, Omprakash.V 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|