Subject: RE: FW: [xsl] How to navigate the tree from a selected node to the root? From: "Nirmala R" <nirmala.r@xxxxxxxxxx> Date: Tue, 22 Oct 2002 13:19:42 +0530 |
Hello Joerg, Thank you very much for the answer. It solved my doubt. Thanks & Regards, Nirmala -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Joerg Heinicke Sent: Tuesday, October 22, 2002 10:36 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: FW: [xsl] How to navigate the tree from a selected node to the root? Hello Nirmala, > I need a little enhancement. > > <?xml version="1.0"?> > <?xml-stylesheet type="text/xsl" href="try.xsl"?> > > <books> > <book name="name2"> > <otherdetails price="10"/> > <otherdetails price="25"/> <!-- Newly added --> > </book> > > <book name="name1"> > <otherdetails price="20"/> > <otherdetails price="35"/> <!-- Newly added --> > </book> > </books> > > Now applying the stylesheet as you have mentioned, I get the output as > > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet type="text/xsl" href="try.xsl"?> > <books> > <book name="name2"> > <otherdetails price="10"/> > <otherdetails price="25"/> > </book> > </books> > > My requirement is that I want to get > > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet type="text/xsl" href="try.xsl"?> > <books> > <book name="name2"> > <otherdetails price="10"/> > </book> > </books> > > The sibling of otherdetails also should not be selected. > > Hence I tried the stylesheet like > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="xml" indent="yes"/> > > <xsl:template match="books"> > <xsl:copy> > <xsl:apply-templates select="@* | book[otherdetails/@price = '10']" /> > </xsl:copy> > </xsl:template> > > <xsl:template match="@*|node()"> > <xsl:if test="node()/otherdetails/@price='10'"> <!-- I know, this is not > correct, but i need something like this --> remove the <xsl:if/> > <xsl:copy> > <xsl:apply-templates select="@*|node()"/> > </xsl:copy> > </xsl:if> > </xsl:template> and add a further template matching on book: <xsl:template match="book"> <xsl:copy> <xsl:apply-templates select="@* | otherdetails[@price = '10']"/> </xsl:copy> </xsl:template> > </xsl:stylesheet> > > Basically, I should be able to differentiate within the template > match="@*|node(), whether > it is an attribute or a book node. If it is a book node and if > otherdetails/@price is not 10, > then that should not be included in the output xml. > > Can you please tell me how could I do that? > > Thanks in advance, > Best Regards, > Nirmala So it's only a further special case in the identity transformation. Hope this helps, Joerg XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: FW: [xsl] How to navigate the t, Joerg Heinicke | Thread | [xsl] Re: Functional Language, Dimitre Novatchev |
[xsl] Re: Accounting for Arbitrary , Dimitre Novatchev | Date | Re: [xsl] how to make default actio, Jörg Heinicke |
Month |