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

RE: Match document node of source document only?

Subject: RE: Match document node of source document only?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 22 May 2008 14:43:45 +0100
RE:  Match document node of source document only?
Either:

(a) Use modes

(b) apply-templates to the outermost element rather than to the document
node

(c) use a more specific pattern for the document node:
match="document-node(element(whatever))" 

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Mark Lundquist [mailto:lundquist.mark@xxxxxxxxx] 
> Sent: 22 May 2008 14:39
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Match document node of source document only?
> 
> Hi,
> 
> I've got a template where I have to do this trick (in XSLT 2.0):
> 
> 	<xsl:variable name="foo">
> 		<whatever>
> 			blah blah blah...
> 		</whatever>
> 	</xsl:variable>
> 	<xsl:apply-templates select="$foo"/>
> 
> This is in order to apply some transform (e.g., from an imported
> stylesheet) to sequences that originate in the stylesheet, 
> not in the source document.  My problem is that I also have 
> this template:
> 
> 	<xsl:template match="/">
> 		...
> 
> which is meant to transform the document node of the source 
> document, but the result tree fragment defined by variable 
> foo also has a document node, so now when I 
> <xsl:apply-templates select="$foo"/>, this template also 
> matches that result tree fragment document node and 
> transforms it.  Bleah!!!  How do I write a template that 
> matches the document node of the source document only?
> 
> I could do
> 
> 	<xsl:variable name="root" select="/"/>
> 
> 	<xsl:template match="/[. = $root]">
> 
> but that's really hacky and seems like it should not be necessary.   
> Any ideas?
> 
> cheers,
> -ml-

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.