Subject: RE: Basic XSL techniques From: Mike Brown <mbrown@xxxxxxxxxxxxx> Date: Wed, 19 Jan 2000 13:31:57 -0700 |
Guralnik wrote: > I'm having a difficulty in understanding what's the exact > difference between select/match, that is, which is better > to use in each case. You don't have a choice. Certain instructions have a select attribute, others have a match attribute, but never both. You "select" a set of nodes that you want to process. You declare that a template "matches" nodes that have a certain pattern. An XSLT processor starts at the root node and finds the template that best matches that node. It executes the instructions in that template. Then it is done. An apply-templates instruction in that one template tells the processor to select another set of nodes and, for each of those nodes, find the template that best matches it and execute the instructions in it. Many templates may match a given node; there are rules in the spec for determining which template will be chosen. I believe this answers another of your questions: > <xsl:template match="..."> > ...do something... > <xsl:apply-templates/> > </xsl:template> > > Can this template become self-recurring, that is, be > called from within itself? Yes, recursion is possible, and there are some built-in templates defined in the spec that prescribe this, effectively causing an XSLT processor to descend through the elements of a source tree by default, adding copies of the text node children of those elements to the result tree along the way. However, you are apparently using IE 5.0, which does not implement these built-in templates, and in fact does not implement very much of the XSLT 1.0 recommendation at all. You may want to consider doing server-side processing with XT, SAXON, or LotusXSL/Xalan. Infinite recursion is also possible, and may cause your XSLT processor to die with an error/exception related to being out of memory. > For example, my document begins by select-ing a specific > ELEMENT from a XML file that contains multiple ELEMENT nodes. No; templates are not executed in a specific order. Templates only say "if the XSLT processor decides that this template provides the best match for the node *that it is already looking at*, here are some instructions to execute." They are like subroutines, whereas the main program is hidden inside the XSLT processor. I think once you add the templates that are supposed to be built-in, and understand what the processor is doing (starting at the root node, finding a template that best matches, etc), then it will become more obvious what is wrong with your particular stylesheet. > What is the reason for using scoped templates? > that is, something like: > > <xsl:template> > > <xsl:apply-templates> > > <xsl:template match="...">1st template</xsl:template> I can't think of any reason for it, because xsl:template cannot occur within xsl:template. That is, you cannot declare one template inside of another. You can still use xsl:apply-templates or xsl:call-template to invoke another template, but that's not the same thing. Since your XSL is in the IE 5.0 syntax and uses things like '%Do block', someone else will need to help you with that. At the very least, your xsl:template elements should always have match attributes, not select. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Basic XSL techniques, Guralnik | Thread | WHAT IS THE "::" SYNTAX USED FOR ??, Jonathan Asbell |
Re: displaying an html non-breaking, Brett McLaughlin | Date | RE: Making balanced two-column tabl, Mike Brown |
Month |