[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Select Data for individual child node

Subject: Re: Select Data for individual child node
From: Rashi Bhardwaj <rashi.bhardwaj@xxxxxxxxx>
Date: Tue, 23 Nov 2010 22:18:47 +0530
Re:  Select Data for individual child node
Hello David,

Thanks for comments....unfortunetly we cant use xslt 2.0...so I need
to do the same with xslt 1.0. Is this possible with xslt 1.0?

And thanks for letting me know problem area of my code.....

Thanks,
Rashi

On Tue, Nov 23, 2010 at 5:56 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
>
> I didn't really understand your problem description, but this generates the
> required output:
>
> ['aaa'],['bbb', 'ccc', 'dddd', 'eeee', 'gggg'],['fffff']
>
>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>
>  <xsl:template match="test">
>  <xsl:for-each-group   select="a/b[c]" group-by="@name">
>   <xsl:if test="position()>1">,</xsl:if>
>   <xsl:text>['</xsl:text>
>   <xsl:value-of select="current-group()/c" separator="', '"/>
>   <xsl:text>']</xsl:text>
>  </xsl:for-each-group>
>  </xsl:template>
>
> </xsl:stylesheet>
>
>
> Note
>
> <xsl:text disable-output-escaping="no">
>
> you never need to use d-o-e ="no" as that is the default 9and you hardly
> ever need d-o-e at all)
>
> //c[1][ancestor::b/@name=$node]"
>
> That generates every c in the document that is the first child of any
> element that has an ancestor b with the required name. did you intend to
> select the first c in the document that is a descendant of such a b?
> that would be
> (//b[@name=$node]//c)[1]
> but note (unless your xslt processor is being kind and rewriting it for
you)
> // can be very expensive and you are better to use a key or for-each-group.
>
>
>
> <xsl:value-of select="./text()"/>
>
>
> you never need to start a path with ./  this is teh same as text() but
using
> text() makes the code fragile in the face of coments or other markup in the
> source, better just to use
>
> <xsl:value-of select="."/>
>
>
> David
>
>
>
>
>



--


Rashi Bhardwaj

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.