Subject: Re: : Sibling in the Pattern(match)
From: Dongling Ding <dling61@xxxxxxxxx>
Date: Tue, 25 Nov 2003 20:51:30 -0800 (PST)
|
Hi Dimitre,
It is the true for the
"Member[@name='acc1']/Member[@name='acc11'" in the
match attribute.
But if want to match the sibling of the member with
name "acc11" in this case, can I say something like
this?
match="*[preceding-sibling::Member[@name
='acc1']/Member[@name='acc11']]"
If I did this, it will remove the siblings of the
member with the name "acc1", not "acc11".
That is the question i have here.
Thanks
Dongling
--- Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> > However, "Member[@name
> > ='acc1']/Member[@name='acc11']]" seems not okay in
> the
> > match. It only recognized the
> "Member[@name='acc1'],
> > not the full path.
>
> Not true!
>
> Probably you are using some buggy XSLT processor?
>
> Here's the very simple xslt code:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output omit-xml-declaration="yes"/>
>
> <xsl:template match="@* | node()">
> <xsl:copy>
> <xsl:apply-templates select="@* | node()"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template
>
> match="Member[@name='acc1']/Member[@name='acc11']"/>
>
> </xsl:stylesheet>
>
> when applied on your source.xml:
>
> <D>
> <Member comment="" name="acc1">
> <Calc>+</Calc>
> <Member comment="" name="acc11">
> <Calc>+</Calc>
> <Member name="account3_1"/>
> </Member>
> <Member comment="" name="acc12">
> <Calc>+</Calc>
> <Member name="acc121"/>
> </Member>
> </Member>
> <Member comment="" name="acc2">
> <Calc>+</Calc>
> </Member>
> <Member comment="" name="acc3">
> <Calc>+</Calc>
> <Member comment="" name="acc31">
> <Calc>+</Calc>
> </Member>
> <Member comment="" name="acc11">
> <Calc>+</Calc>
> </Member>
> </Member>
> </D>
>
> the wanted result is produced:
>
> <D>
> <Member comment="" name="acc1">
> <Calc>+</Calc>
>
> <Member comment="" name="acc12">
> <Calc>+</Calc>
> <Member name="acc121"></Member>
> </Member>
> </Member>
> <Member comment="" name="acc2">
> <Calc>+</Calc>
> </Member>
> <Member comment="" name="acc3">
> <Calc>+</Calc>
> <Member comment="" name="acc31">
> <Calc>+</Calc>
> </Member>
> <Member comment="" name="acc11">
> <Calc>+</Calc>
> </Member>
> </Member>
> </D>
>
> As you can see, the first "Member" withname="acc11"
> is removed, but the
> second is in the result tree. I tested this with all
> 8 different XSLT 1.0
> processors I have installed -- all produced exactly
> the same result.
>
>
>
> =====
> Cheers,
>
> Dimitre Novatchev.
> http://fxsl.sourceforge.net/ -- the home of FXSL
>
>
>
>
>
>
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|