RE: [xsl] Template matching similiar names

Subject: RE: [xsl] Template matching similiar names
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Mon, 7 Apr 2003 13:39:27 -0400
[ Holbrook, R Cody (Cody) ]

> I'm having difficulty distinguishing between classes with 
> similiar names.
> 

No, you are trying to distinguish between __elements__ with different
attributes.

> I start with the following XML
> 
> <class element="root">
> </class>
> 
> <class element="roothome">
> </class>

[snip]

> 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?

Assuming that the "xsd" prefix has been bound to an appropriate
namespace (you did not show this) and that your "class" elements are in
that namespace (you did not show that either), then here is the kind of
expression you seem to be after (I show two possiblities since I am
unclear about what you want to achieve) -

1) This works when you want to single out specific classes whose name
you know.
match='xsd:class[@element="roothome"]'

2) This will display the name of the class
<xsl:template match="xsd:class...">
      <doc>Docs for <xsl:value-of select='@element'/>
            <!-- something appropriate goes here -->
      </doc>
    ...
</xsl:template>

Cheers,

Tom P

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread