Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: How to choose the first nonempty element [Thread Next] Re: How to choose the first nonempty elementTo: NULL Date: 4/2/2008 10:43:00 AM On Apr 2, 6:08=A0pm, Martin Honnen <mahotr...@yahoo.de> wrote: > khalil...@hotmail.com wrote: > > If I have an xml data such as the following: > > > <csv> > > > <line> > > <field></field> > > </line> > > > <line> > > <field></field> > > </line> > > > <line> > > <field>2</field> > > </line> > > > <line> > > <field>3</field> > > </line> > > > </csv> > > > I need to go though all <line> elements and get the first NON-Empty > > <field> > > in the example above, it should print 2 > > =A0 =A0(/csv/line/field[node()])[1] > selects the first field element that is not empty. > > > I need the solution in xsl 2.0 > > =A0 =A0<xsl:stylesheet > =A0 =A0 =A0xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" > =A0 =A0 =A0version=3D"2.0"> > > =A0 =A0 =A0<xsl:template match=3D"/"> > =A0 =A0 =A0 =A0<xsl:value-of select=3D"(/csv/line/field[node()])[1]"/> > =A0 =A0 =A0</xsl:template> > > =A0 =A0</xsl:stylesheet> > > That would work with XSLT 1.0 as well. > > -- > > =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML > =A0 =A0 =A0 =A0http://JavaScript.FAQTs.com/- Hide quoted text - > > - Show quoted text - thanks Martin for your help | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
