[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] converting attributes to nested tags recursively
Hi, I have a file like the following <tagA attribreq="attribreqvalue1" attrib1="fds" attrib2="hdg"> <TagB>Text1</TabB> <tagA attribreq="attribreqvalue1" attrib1="fds" attrib2="hdg"> </tagA> And I am trying to convert it to the following <attribreq attrib="attribreqvalue1"> <tag name="attrib1" value="fds"> <tag name="attrib2" value="hdg"> <tagB>Text1</tagB> </tag> </tag> </attribreq> <attribreq attrib="attribreqvalue1"> <tag name="attrib1" value="fds"> <tag name="attrib2" value="hdg"/> </tag> </attribreq> I would like to do it recursively something like the following. So that I can optionally add specific matches for processing specific tags. <xsl:template match="@*"> <tag> <xsl:attribute nam="name"><xsl:value-of select="name()"/></xsl:attribute> <xsl:attribute nam="value"><xsl:value-of select="current()"/></xsl:attribute> <xsl:template select="parent::*/(@*|tagB)"/> </tag> </xsl:template> <xsl:template match="tagB"> <xsl:copy-of select="."/> </xsl:template> The number of attributes will vary. Thanks in advance Edward XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|