Altova Mailing List Archives
>xsl-list Archive Home
>Recent entries
>Thread Prev - RE: [xsl] how to find out the first occurence of a node with a certain string value.
[Thread Next]
Re: [xsl] how to find out the first occurence of a node with a certain string value.
To:
Date: 3/26/2002 3:24:00 PM
> > I'm trying to find out if a node with certain string value is occuring > > first time. >From this I suggest the following: <xsl:if test="count(preceding-sibling::letter[text() = current()/text()]) = 0"> for first occurence, otherwise change the number at the end. Regards, Joerg > > I'm trying to find out if a node with certain string value is occuring > > first time. This is the XML snippet: > > ..... > > <letter>A</letter> > > <letter>D</letter> > > <letter>C</letter> > > <letter>D</letter> > > ...... > > > > I want to test if; > > <xsl:if test="starts-with($mod-init,'D')[1]"> or <xsl:if > > test="starts-with($mod-init,'D')[2]"> and so forth, but this code does > > not work. What should I do? > > > It's not easy to guess your requirements from looking at incorrect code > (Jeni Tennison is brilliant at it, but most of us fail miserably). But > perhaps what you are looking for is: > > <xsl:if test="starts-with($mod-init[1],'D')"> > > You can only apply a predicate such as [1] to a node-set, and the result of > starts-with is not a node-set, it is a boolean. > > Michael Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Disclaimer
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

