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

Re: XSLT and unexpected text ouput?

Subject: Re: XSLT and unexpected text ouput?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 28 Apr 2004 18:35:11 +0100
xslt discard template
  If I understand this right, the behavior of the default template is
  simply to render the text contents of nodes. 

Not directly, it simply recurses on elements and copies text nodes, ie
it is as if you had

<xsl:template match="*">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="text()">
  <xsl:value-of select="."/>
</xsl:template>

in your stylesheet. By actually having templates that match those things
you can change the behaviour, eg if you had

<xsl:template match="*"/>

Then the default behaviour on elements woul dbe to discard them and all
their contents.



  
  	<xsl:template match="/">
  		<xsl:apply-templates select="WHATEVER"/>
  	</xsl:template>
  
  The root node match says specifically apply this template WHATEVER,
  which by implication means to ignore all other nodes off the root which
  do NOT match this template.  Otherwise, if nodes are neither matched nor
  excluded, the default template applies to them.  Is that it?


The terminology here is very confused so I'm not sure what you mean, but
I think that you mean something that is incorrect.

There can only be one root node in a document (it essentially _is_ the
document, it isn't the top level element of the document)

The default template for / is the same as the one above for elements
and applies templates to all its children, there can't be any top level
text if teh input is well formed, and the default template for comments
and pis is to discard, so by default processing moves to the top level
element.


If that has multiple children and you only specify templates for one of
them, you will get the result you described: text from all the other
children will appear at the top level of the output.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.