Subject: Re: [xsl] Re:Excluding a complete branch while identity copying From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 13 Oct 2008 12:48:09 -0400 |
I think the problem here (for me) was forgetting that (in this 'recursive descent' style) the sytlesheet is defining the output rather than controlling the way that input is processed (i.e. I was thinking procedurally). So we get to the questions to clarify the behaviour :-
1. I had put apply-templates into the 'exclude this node' templates because I was mistakenly thinking that unless I did that the processing of the input would stop.
So the clarification is, when you're not taking control of how the input is processed (by NOT using apply-templates but explicitly pulling data from the input) then the XSLT processor continues through the input document in a recursive fashion from top to bottom and nodes are either processed by specific templates that contain a match expression that selects that node, or they are processed by the default template rules.
Is that correct ?
<xsl:template match="/"> <xsl:for-each select="/path/to/element"> <do><stuff/></do> </xsl:for-each> </xsl:template>
<xsl:template match="/"> <xsl:apply-templates select="/path/to/element"/> </xsl:template>
<xsl:template match="element"> <do><stuff/></do> </xsl:template>
<xsl:template match="*"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template>
2. The 'near' identity template that I used does appear to produce the same results as the one you provided. I suspect that the one provided by Ryan does also (thanks Ryan) :-
MINE :-
<xsl:template match="*|@*|text()"> <xsl:copy-of select="."/> </xsl:template>
YOURS :-
<xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template>
RYANs :-
<xsl:template match="@*|*"> <xsl:copy> <xsl:apply-templates select="@*"/>
<xsl:apply-templates/> </xsl:copy> </xsl:template>
Can you tell me which one of these is prefable and why ?
I hope that helps -- Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re:Excluding a complete b, David Carlisle | Thread | [xsl] XSelerator is available at so, Dimitre Novatchev |
Re: [xsl] XSelerator is available a, Dimitre Novatchev | Date | Re: [xsl] grouping based on string , Wendell Piez |
Month |