Subject: Re: [xsl] Testing for following text() From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 31 Oct 2007 13:20:44 -0400 |
How can I test if there is a text node following and restrict the test to a certain parent element?
In the example I'd like to test if there is text following after the <s/> element up to the enclosing end tag of the <b> element.
This test should fire at the first s element because of the following BBB text, but not at the second s element in spite of the following AAA text. The structure below the b element may contain any number of nesting levels and element.
I'd like to include the test in a template which tackles the s element, like <xsl:template match="s[some-test]">
t:\ftemp>type sascha.xml <a> aaa <b> bbb <c> ccc <s/> </c> BBB </b> AAA <b> bbb <c> ccc <s/> </c> </b> AAA </a>
t:\ftemp>type sasha.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/"> <xsl:for-each select="//s"> <xsl:value-of select="position()"/>: <xsl:text/> <xsl:choose> <xsl:when test="following::text()[generate-id(ancestor::b[1])= generate-id(current()/ancestor::b[1])] [normalize-space()]">yes</xsl:when> <xsl:otherwise>no</xsl:otherwise> </xsl:choose> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template>
</xsl:stylesheet> t:\ftemp>xslt sascha.xml sasha.xsl con 1: yes 2: no
-- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Jul'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Testing for following tex, Andrew Welch | Thread | [xsl] How can I test the last prece, Sascha Mantscheff |
Re: [xsl] Testing for following tex, Andrew Welch | Date | [xsl] Accessing External Java Libra, Carl Bourne |
Month |