Subject: Re: [xsl] Template matching similiar names From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx> Date: Mon, 7 Apr 2003 20:08:18 +0100 |
This should be easy i think... Tru this one <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates select="classes/class[@element = 'root']"/> </xsl:template> <xsl:template match="class"> <class element = "{@element}"> <doc>Docs for root</doc> </class> </xsl:template> </xsl:stylesheet> note that i have used a parent element for class elements. I have assumed the xml structure as follows.. <?xml version="1.0"?> <classes> <class element="root"> </class> <class element="roothome"> </class> </classes> Do proper alterations to reflect your xml and it will work cheers HTH Vasu Chakkera ----- Original Message ----- From: "Holbrook, R Cody (Cody)" <rch7@xxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, April 07, 2003 6:04 PM Subject: [xsl] Template matching similiar names > Hello All, > > I'm having difficulty distinguishing between classes with similiar names. > > I start with the following XML > > <class element="root"> > </class> > > <class element="roothome"> > </class> > > The template match I'm using is incorrect as I only want to have the doc tags added to the class with the element attribute root. > > > What I get back is this: > > <class element="root"> > <doc>Docs for root</doc> > </class> > > <class element="roothome"> > <doc>Docs for root</doc> > </class> > > > No matter what I've done, I get the same thing, in general my tries have looked like this: > > <xsl:template match="xsd:class..."> > <xsl:copy> > <xsl:copy-of select="@*"/> > <doc>Docs for root</doc> > .... > > Is there a way to make a very exact match with an attribute? > > Thanks, > > Cody Holbrook > > > > (and many variations, including two starts-with template matches that worked, but not well) > > 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 -> |
---|---|---|
[xsl] Template matching similiar na, Holbrook, R Cody (Co | Thread | RE: [xsl] Template matching similia, Martinez, Brian |
Re: [xsl] "--" question, david_n_bertoni | Date | [xsl] Replace blank rows, Kim Tran |
Month |