Subject: [xsl] Re: Sibling in the Pattern(match) From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Mon, 24 Nov 2003 06:59:41 +0100 |
"Dongling Ding" <dling61@xxxxxxxxx> wrote in message news:20031124022747.86939.qmail@xxxxxxxxxxxxxxxxxxxxxxxxxx > Hi, > > I want to perform a filering out transformation to a > source file. I copy most things, but leave out specfic > parts. > > The left out part can be done like this: > > <xsl:template match="execluded-nodes"> > "do nothing" > </xsl:template> > > <xsl:template match="child::Member[@name ='acc1']"/> > > There is a problem with this approach. It seems like > you only can specify "child" or "attribute" in the > match pattern. > > What can I do if I want to execlude all the nodes > having the same level as a selected nodel? There is no restriction on the axis that can be used within *predicates* of the match pattern. The only restriction in the predicates (in XSLT 1.0) is that no variable references are allowed. Therefore, you can specify the restricting condition like this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="*[not(preceding-sibling::*)]"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="*[preceding-sibling::*]"/> </xsl:stylesheet> When this transformation is applied on the following source.xml: <a> <b/> <c/> <d/> </a> the wanted result is produced: <a> <b/> </a> In case the condition contains a reference to an xsl:variable or an xsl:param, then this condition cannot be specified as part of the match pattern. I such a case one can test for the condition within the code of the template and do nothing if the condition is not satisfied -- this can be accomplished using an xsl:if Hope this helped. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Sibling in the Pattern(match), Dongling Ding | Thread | Re: [xsl] Re: Sibling in the Patter, Dongling Ding |
[xsl] Sibling in the Pattern(match), Dongling Ding | Date | RE: [xsl] XML generation from a tex, SHEIKH Sajjad |
Month |