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

RE: access the root element

Subject: RE: access the root element
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 3 Nov 2005 16:08:12 -0000
xslt default namespace
> I have an XML document (very large, 78k lines...

that's not especially large...

> <?xml version="1.0" encoding="UTF-8"?>
> <Metrics scope="eVistaDev" type="PackageRoot" date="2005-11-02"
> xmlns="http://metrics.sourceforge.net/2003/Metrics-First-Flat">
> <Cycle>
> <Package>A.Package.Name</package>
> </Cycle>
> <Metric>(further elements)</Metric>
> <Metric>(further elements)</Metric>
> ...
> <Metrics>
> 
> It is a completely wellformed XML file. I try to access the 
> attributes of
> the Metrics element (the root element). I have no luck with that. Can
> anybody tell me where is the error for that I'm blind for?

You're confusing the outermost element with the document node. "/" matches
the document node. The outermost element is a child of the document node.
The document node does not have attributes; for that you need to select the
outermost element. (Note: in the XPath 1.0 data model the document node is
known as the "root node")

>                 <xsl:for-each select="Metric[count(Value)=1]">


Even if your context node were the outermost (Metrics) element, this
wouldn't work, because your Metric element is in a namespace. Google for
"XSLT default namespace".

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

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.