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

AW: access the root element

Subject: AW: access the root element
From: "Huditsch Roman" <Roman.Huditsch@xxxxxxxxxxxxx>
Date: Thu, 3 Nov 2005 16:48:53 +0100
xslt select root element
Hallo Kai,

There seem to be at least two problems in your XSLT stylesheet.

1., If you want to match an element within a namespace (as it is in your
source document),
you need to define that namespace in your stylesheet, too.
Therefore the beginning of your stylesheet needs to be like:
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:m="http://metrics.sourceforge.net/2003/Metrics-First-Flat">

That allows you to access the nodes in your source file by using the namespace
prefix ("m" in my namespace declaration).
Having that in mind
<xsl:for-each select="Metric[count(Value)=1]">
changes to
<xsl:for-each select="m:Metric[count(Value)=1]">


2. You are trying to acces an <Metric> element directly below "/", which does
not select what you want according to your source file.
You need to select m:Metrics/m:Metric[count(Value)=1] since Metrics is your
root element, not Metric.

I hope this helps.

liebste Gr|_e,
Roman Huditsch
_______________________________________

Roman Huditsch
IT and Electronic Publishing
LexisNexis ARD Orac
Marxergasse 25
1030 Vienna
Austria
ph: +43-1-534 52-1514
f: +43-1-534 52-140
e-mail roman.huditsch@xxxxxxxxxxxxx
www.lexisnexis.at


> -----Urspr|ngliche Nachricht-----
> Von: Kai Hackemesser [mailto:kaha@xxxxxx]
> Gesendet: Donnerstag, 3. November 2005 16:34
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff:  access the root element
>
> I'm desparating.
>
> I have an XML document (very large, 78k lines, generated by
> the Eclipse Plugin "Eclipse Metrics") where I want to write
> an XSL for. The XML is formed like that:
> <?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?
>
> this is the xsl file I have written so far:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="2.0">
>     <xsl:output method="html"/>
>     <xsl:template match="/">
>         <html>
>             <head>
>                 <title>Metrics Report from <xsl:value-of
> select="@date"
> /></title>
>             </head>
>             <body >
>                 <H1><xsl:value-of select="@date" />,
> <xsl:value-of select="@type" /></H1>
>                 <h2>Overview for calculated Metrics</h2>
>                 <!-- 1. Overview over Project -->
>                 <h3>Overall Metrics</h3>
>                 <ul>
>                 <xsl:for-each select="Metric[count(Value)=1]">
>                     <li><xsl:value-of select="@id"/> -
> <xsl:value-of select="@description"/> : <xsl:value-of
> select="./Value/@value"/></li>
>                 </xsl:for-each>
>                 </ul>
>                 <!-- 2. Overview over Packages -->
>             </body>
>         </html>
>     </xsl:template>
> </xsl:stylesheet>

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.