|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: template matching everywhere
Hi JF,
At 06:06 PM 3/4/2004, you wrote: I would like to write a template that match a particular element but this element could be located anywhere No problem: templates are generally written to match elements no matter where they appear (though you can go to extra trouble to restrict this behavior).
The way the XSLT processing model works, you don't translate TOBEMATCHED while processing its parent; you output the result you want from TOBEMATCHED when you process TOBEMATCHED itself: <xsl:template match="TOBEMATCHED">
<!-- this works wherever TOBEMATCHED occurs, assuming the node
is selected for processing at all -->
<output>
<xsl:apply-templates/>
</output>
</xsl:template>...which will replace every TOBEMATCHED element with an <output> element. For example suppose you have to proceed an HTML document and you want to replace each <b> tag with an <em> tag and did other work on other it may help you understand what I want to do.
Assuming you do not override the default node traversal of the document, this will result in all <b> elements occuring anywhere with <em> elements (and will go on to process the rest of the document too). This is so basic to XSLT that I wonder where the gap is. Have you looked at any introductory material on the XSLT processing model? It might also be instructive to you to try a simple stylesheet containing nothing but a template or two like this one. My guess is that if you can't get this to work, it's because you are making things too complicated. Maybe posting a complete sample with a stylesheet that you believe should work, but doesn't, can help us understand where to direct your attention. Cheers, Wendell
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
|

Cart








