[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: build-in template question

Subject: Re: build-in template question
From: Garvin Riensche <g.riensche@xxxxxxx>
Date: Fri, 05 Sep 2008 00:42:07 +0200
Re:  build-in template question
Jonas Mellin schrieb:
Garvin Riensche wrote, On 2008-09-05 00:17:
Hello,

I have a question concerning text nodes. If I have an xml file like

<root>
  <e>text</e>
</root>

and a template like

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

than, the output will be "<e>text</e>".

Is the text insterted to the output by xsl:copy or by the build-in template

<xsl:template match="text()|@*">
  <xsl:value-of select="."/>
</xsl:template>
?
During evaluation of applicable templates on a particular node, the most specific template is chosen. If two or more templates is of the same level of specification, then the template with the highest priority is chosen. I have forgotten what happens if two templates cannot be separated (a situaiton that I try to avoid), although a qualified guess is that an XSLT 1.0 processor does something and an XSLT 2.0 processor returns an error message. Anyway, in this case, the match="e" is more specifc than match="text()|@*" so the first template is chosen.

I think the "match='e'" doesn't compete with the "match='text()|@*'" because "e" is neither a text, nor an attribute node. So that template for e is chosen which copies the element node "e". In the definition of xsl:copy it is said:
"If the context item is a node, evaluating the xsl:copy instruction constructs a copy of the context node, and the result of the xsl:copy instruction is this newly constructed node. By default, the namespace nodes of the context node are automatically copied as well, but the attributes and children of the node are not automatically copied."
Because "text" is a child of "e" I think it is not copied by xsl:copy.
But If "e" if replaced by the sequence constructor of the template how can the build-in template match the text-node, which got already replaced?


regards,
Garvin

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.