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

RE: XML Root Element

Subject: RE: XML Root Element
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 4 Mar 2005 22:13:37 -0000
xml root
The top of the tree is a root node (1.0 terminology) or document node (2.0).
This is what "/" refers to. It's not an element: it's the parent of the
outermost element (and any comments and processing instructions that precede
or follow the outermost element). The root node has no name.

The outermost element can be obtained using /*, and its name is name(/*).

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

> -----Original Message-----
> From: c p [mailto:bugs75il@xxxxxxxxx] 
> Sent: 04 March 2005 22:00
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XML Root Element
> 
> Is there a way I can get the name of the root element?
>  For example, in the following xml:
> -------------------------------------------------
> <?xml version='1.0' encoding='UTF-8'?>
> <?xml-stylesheet type='text/xsl' href='my.xsl'?>
> <myxmlroot>
>   <sometag></sometag>
> </myxmlroot>
> -------------------------------------------------
> 
> Is there a way I can get the string "myxmlroot" which
> is the name of my root element?
> 
> I have tried doing something like this via my.xsl:
> -------------------------------------------------
> <?xml version='1.0' encoding='UTF-8'?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:template match="/">
>   <xsl:value-of select="name()"/>
> </xsl:template>
> </xsl:stylesheet>
> -------------------------------------------------
> 
> 
> The name() function does not work by putting it in the
> "/" template.  It prints the documents root (system
> root I think?) and not the root element name which is
> what I want.  How do I get to this?
> 
> Thanks,
> C
> 
> 
> 	
> 		
> __________________________________ 
> Celebrate Yahoo!'s 10th Birthday! 
> Yahoo! Netrospective: 100 Moments of the Web 
> http://birthday.yahoo.com/netrospective/

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.