Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Question on flow

From: "tshad" <tfs@----------.--->
To: NULL
Date: 4/2/2008 8:32:00 AM

Martin Honnen wrote:
> tshad wrote:
>
>> It seems that only the 1st template is the driving template, similar
>> to Main() in C or the startup function in any program.  If I don't
>> call any other function, from a startup function then only the
>> startup function gets executed even if there there are other
>> functions in my program (discounting events, of course).
>>
>> In XSLT, it seems that the 1st template is like your startup routine.
>
> No, processing does not start at the first template. Processing starts
> at the root node (document node) of your primary XML input document,
> see <URL:http://www.w3.org/TR/xslt#section-Processing-Model>. Then
> the best matching template is used and its content determines which
> nodes are processed next. And there is a built-in template
> (<URL:http://www.w3.org/TR/xslt#built-in-rule>)
>   <xsl:template match="*|/">
>     <xsl:apply-templates/>
>   </xsl:template>
> which makes sure the child nodes of the root node are processed.
> So in your sample XML input the above built-in template is the first
> template to be applied, then the child nodes of the root node
> (document node) are processed which is the 'REPORT' element. As you
> have a matching template for 'REPORT' elements that template is
> applied. And the xsl:apply-templates in that template determine which
> nodes are processed next, and pattern matching determines which
> templates are applied to these nodes.

That makes sense.

But then what is happening as to the use of "/*" vs "/" vs "REPORT" in my
first template line.

Both "/*" and "REPORT" give me the same results.  But if I have "/" and
<xsl:copy>, I don't get a root tag.  If I do "/" and "<REPORTING> (in place
of the <xsl:copy>), it works fine with <REPORTING> as my root tag.

It seems the "/" drops the root node (with copy) and "/*" (with copy) uses 
the existing root node.

I assume the reason "/" and <REPORT> work is because "/" is dropping the 
root (document) node but I am supplying my own.

<xsl:template match="/">
  <xsl:copy>

doesn't work (missing root node)

<xsl:template match="/">
  <REPORT>

works - I assume because I am supplying the root node.

<xsl:template match="/*">
  <xsl:copy>

don't know why that doesn't work.

Thanks,

Tom
 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent