[Home] [By Thread] [By Date] [Recent Entries]
Hello,
Your XML is invalid.. So I had to make a few assumptions.. Mainly that the match is based on the elements name,, not the text() within the element. I rattled it off quickly so I'm sure there is a nicer solution out there. Anyway, if your XML is indeed suppose to be: <?xml version="1.0"?> <record> <product1>Item1</product1> <product2>Item2</product2> <product3>Item3</product3> <serial1>serial 1</serial1> <serial2>serial 2</serial2> <serial3>serial 3</serial3> </record> Then: <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="record"> <xsl:apply-templates select="*[contains(name(), 'product')]"/> </xsl:template> <xsl:template match="*[contains(name(), 'product')]">
<xsl:variable name="serialNum" select="concat('serial',
substring-after(., 'Item'))"/>
<xsl:value-of select="."/><xsl:apply-templates
select="following-sibling::*[contains(name(), $serialNum)]"/>
</xsl:template><xsl:template match="*[contains(name(), 'serial')]">(<xsl:value-of select="."/>)<xsl:text> </xsl:text></xsl:template> </xsl:stylesheet> Will produce: Item1(serial 1) Item2(serial 2) Item3(serial 3) However, if the relationship is based on text() then you'll have to replace name() with text() and 'product' with 'Item' and tweek at match. Cheers, Spencer Tickner On 2/20/07, Senthilkumaravelan K <skumaravelan@xxxxxxxxxxxxxx> wrote: Hi All, I have structure as <record> <product1>Item1</product1> <product2>Item2</product2> <product3>Item2</product2> ...... ...... <serial1>serial 1</serial1> <serial2>serial 2</serial2> <serial3>serial 3</serial1> ..... ......
|

Cart



