Subject: Re: [xsl] many node values into one?? From: "Jay Bryant" <jay@xxxxxxxxxxxx> Date: Wed, 8 Jun 2005 18:22:39 -0500 |
Hi, Wendi, That question has many possible answers, depending on the XML source, what you really want, and which version of XSLT you use. The best thing to do is show us a small but complete snippet of your XML source, your best XSL attempt, and your desired output (be it XML, HTML, text, or whatever). However, here's a shot at a generic answer: Assuming you have a structure like this: <x> <y>Banana</y> <y>Strawberry</y> </x> you can join them thus (in XSLT 1.0 or XSLT 2.0): <xsl:template match="x"> <out> <xsl:for-each select="y"> <xsl:value-of select="."/> </xsl:for-each> </out> </xsl:template> or thus (in XSLT 2.0): <xsl:template match="x"> <out><xsl:value-of select="y" separator=""/></out> </xsl:template> If you have a structure like this: <x> <y>Banana</y> <z>Strawberry</z> </x> you can join them thus (in XSLT 1.0 or XSLT 2.0): <xsl:template match="x"> <out><xsl:value-of select="y"/><xsl:value-of select="z"/></out> </xsl:template> or thus (in XSLT 2.0): <xsl:template match="x"> <out><xsl:value-of select="y|z" separator=""/></out> </xsl:template> I tested all of those and got <out>BananaStrawberry</out> as the result each time. Note that there are other ways to do it, some of which may be better (depending on what you are actually trying to do). HTH Jay Bryant Bryant Communication Services ----- Original Message ----- From: "Wendi Turner" <wenditurner@xxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>; <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Cc: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, June 08, 2005 5:31 PM Subject: [xsl] many node values into one?? > how can i get to node values to translate into one node value?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] many node values into one, David Carlisle | Thread | [xsl] Importing compiled stylesheet, Andrew Welch |
Re: [xsl] many node values into one, David Carlisle | Date | Re: [xsl] Weird XPath evaluation di, Jay Bryant |
Month |