[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] defining nodes to apply template to
Subject: Re: [xsl] defining nodes to apply template to From: ADAM PATRICK <adampatrick@xxxxxxxxxxxxxx> Date: Tue, 9 Aug 2005 14:40:42 +0100 (BST) |
Thanks for the reply but at present with this xsl using instant saxon 6.5.3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- select all text nodes --> <xsl:template match="blah[not((preceding-sibling::*|.)='STOP')]"> <xsl:call-template name="CheckTag"> <xsl:with-param name="STR" select="."/> </xsl:call-template> </xsl:template> <!-- search through nodes only displaying nodes that comply with the rules --> <xsl:template name="CheckTag"> <xsl:param name="STR"/> <xsl:if test="$STR='TEXT'"> <req_id> <xsl:value-of select="."/> </req_id> </xsl:if> </xsl:template> <!-- Change root element --> <xsl:template match="root"> <item> <xsl:apply-templates/> </item> </xsl:template> </xsl:stylesheet> i get this xml <?xml version="1.0" encoding="utf-8"?><item> <req_id>TEXT</req_id> <req_id>TEXT</req_id> <req_id>TEXT</req_id> STOP TEXT TEXT </item> I would like.... <?xml version="1.0" encoding="utf-8"?> <item> <req_id>TEXT</req_id> <req_id>TEXT</req_id> <req_id>TEXT</req_id> </item> any help appreciated.... On Thu, 2005-08-04 at 16:43 +0100, ADAM PATRICK wrote: > <root> > <item> > <blah>TEXT</blah> > <blah>TEXT</blah> > <blah>TEXT</blah> > <blah>STOP</blah> > <blah>TEXT</blah> > <blah>TEXT</blah> > </item> > </root> > i want to apply a template to all <blah> nodes before > the text STOP appears after that I do not want to > apply the template in the <blah> node. > i believe the rough answer is to do with XPATH and > setting the template match correctly using > preceding-sibling > but can't quite work it out... > any help appreciated. The following template matches the blah elements you DO want to process (xpath 2.0): <xsl:template match="blah[not((preceding-sibling::*|.)='STOP')]"/> sdc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] defining nodes to apply t, David Carlisle | Thread | Re: [xsl] defining nodes to apply t, David Carlisle |
Re: [xsl] Converting Word document , Sajeesh N Kakkat | Date | Re: [xsl] How to assign a sequence , andrew welch |
Month |