RE: Xsl problem (template matching)

Subject: RE: Xsl problem (template matching)
From: "Richard Lander" <rlander@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Dec 1999 09:26:15 -0500
 Jim,

No, you don't need to use '//'. I'm not too sure exactly what that would
mean in that context, but 'display-type' on is own would match all
display-type nodes. Now, if you were already in a template rule and you
wanted to match all the display-type decendants of the current node, then
you could try something like:

<apply-templates match=".//display-type"/>

As far as I can tell, prepending a template match with '//' is meaningless
when compared to the node on its own (display-type). '/' (/display-type) is
fine and will select display-type if it is the root element. '//'
(some_element//display-type) in the middle of the match is also fine.

Good luck,

Richard


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Jim Michael
Sent: Monday, December 20, 1999 8:42 AM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: RE: Xsl problem (template matching)


In order for your template to match under all nodes, would you not have to
use // as in:

<xsl:template match="//display-type">
	<!--rules here -->
</xsl:template>

If your display-type node sits directly beneath another node you are using a
template match for, then the // isn't necessary. Or is the above approach
poor form? I can think of instances where the // might be useful for
extracting deeply nested nodes of interest. Thanks.

Cheers,

Jim

> Don't worry, that's how XSL works. You can declare template
> rules so that
> they will only fire if elements are in particular contexts,
> or so that do
> they do so all the time.
>
> For example:
>
> <xsl:template match="display-type">
> <!--rules here -->
> </xsl:template>
>
> will fire for all display-type elements in your document, whereas:
>
> <xsl:template match="display-type[@value='bullets']">
> <!--rules here -->
> </xsl:template>
>
> and
>
> <xsl:template match="example/display-type">
> <!--rules here -->
> </xsl:template>
>
> will only fire in particular contexts.
>
> I hope that helps. Do take a look at the XPath spec @
http://w3.org/TR/xpath

Richard

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of bhavesh bhanushali
Sent: Saturday, December 18, 1999 12:16 AM
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Xsl problem (template matching)


Hi

I am newbie in xsl.
My problem is:-
I want to apply a particular template where ever that particular node exist
i.e independent of its parent elements.


for e.g
<example>
<name>xxxy</name>
<display-type value="bullets">
<training>xyz</training>
</display-type>
<section>aaaa</section>
<display-type value="bullets">
<topic>Hello</topic>
</display-type>
</example>

I want to match (display-type) node and use the same template whereever it
is present.
I hope u understand. Can Anyone suggest the solution.
Thanks in Advance

With Regards
Bhavesh

______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com?sr=mc.mk.mcm.tag001


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


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


 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