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

RE: Getting the root element.

Subject: RE: Getting the root element.
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Date: Thu, 24 Jul 2003 06:54:47 -0400
xsl root
Be advised though, that doesn't always work ... at least maybe not in the
way you think.  I guess it depends on which "document" root node you need.

If you've constructed xml within a variable, lets say, and then you
apply-templates on that given instance, xpathing--within context--to "/"
will take you to the root of the xml "document" within that given variable.

What I mean by "within context" is operations conducted on/within the
context node.  For example, if you xpath to "/" within a predicate or a
for-each that's is operating on the context node.

To get around this, what I do is pre-load a "this" variable at "global"
scope with "/" ... or, you could do it locally--but, I don't think that
makes sense if you plan to access that path within multiple/separate code
paths.

To illustrate what I'm babbling about:

xml:
<xml/>

xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
 
  <xsl:output method="text"/>
	
  <xsl:variable name="this" select="/"/>

  <xsl:template match="/">
  
     <xsl:variable name="my-instance">
        <node/>
     </xsl:variable>
    
     <xsl:apply-templates select="msxsl:node-set($my-instance)/node"/>
    
  </xsl:template>

  <xsl:template match="node">
     context "/" name: <xsl:value-of select="name(/*[1])"/>;
     global "/" name : <xsl:value-of select="name($this/*[1])"/>;
  </xsl:template>
   
</xsl:stylesheet>

Anyhow, this may not be an issue for you.

-Jeff


-----Original Message-----
From: Jarno.Elovirta@xxxxxxxxx [mailto:Jarno.Elovirta@xxxxxxxxx]
Sent: Thursday, July 24, 2003 6:02 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Getting the root element.


Hi,

> Q:
> When deep within the structure (In my case recursing down a 
> branch) what it
> the most elegent way of getting the document root node?

/

Cheers,

Jarno - Covenant: Bullet (Club Version)

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.