[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: Sibling in the Pattern(match)
Just make a quick point here. The reason I put the path her is that there mihgt be the same member name as "acc11" but in different location. So, in my case there is no unique member name for members. How can I use Xpath type of thing to indicate the exact member I am looking for.... <xsl:template match="*[preceding-sibling::Member[@name ='acc1']/Member[@name='acc11']]"/> Thanks Dongling --- Dongling Ding <dling61@xxxxxxxxx> wrote: > > > 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> > > > > Thanks! > > It works in your example. But for my example, how > can > I filter out the member "acc12"? > > <xsl:template > match="*[preceding-sibling::Member[@name > ='acc1']/Member[@name='acc11']]"/> > > It filtered members "acc2" and "acc3" instead of > "acc12" and its child "acc121"? > > Here is the 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="acc32"> > <Calc>+</Calc> > </Member> > </Member> > </D> > > > > Dongling > > > > > > __________________________________ > 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 > __________________________________ 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|