XSLT - replace a node with a tree

Nounteepype

New Member
I have following source xml\[code\]<forms> <x> <y> <x-component select="foobar" /> </y> </x> <component name="foobar"> <some> <component> <value>text</value> </component> </some> </component></forms>\[/code\]I'm trying to transform it to following:\[code\]<?xml version="1.0" encoding="UTF-8"?><forms> <x> <y> <component name="foobar"> <some> <component> <value>text</value> </component> </some> </component> </y> </x></forms>\[/code\]My xsl file is\[code\]<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="x-component"> <yoba> <xsl:attribute name="z"> <xsl:value-of select="@select"/> </xsl:attribute> <xsl:apply-templates select="/forms/component[@name=@select]/*" /> </yoba> </xsl:template> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="/"> <xsl:apply-templates select="*"/> </xsl:template></xsl:stylesheet>\[/code\]How can I pass value of the \[code\]select\[/code\] attribute of the current node for this line (instead of PLACEHOLDER):\[code\]<xsl:apply-templates select="/forms/component[@name=<PLACEHOLDER>]/*" />\[/code\]
 
Back
Top