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

Re: XSL / XML initial tag incompatibility

Subject: Re: XSL / XML initial tag incompatibility
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Mar 2005 13:15:19 -0500
initial tag
At 2005-03-23 20:46 +0300, yechiel lewis wrote:
I'm fairly new to XSL and have a problem matching the initial tags in my XSL file with the corresponding tags in the matching XML file.

If I remove the initial XML tags, the XSL works, but not otherwise.

What am I missing in the XSL to make it work for the corresponding XML file below?

All of your XPath expressions need to have the elements qualified with a prefix. Your document element (what you call "the inital tag") contains a declaration of the default namespace, which means all of the unprefixed elements in your XML are namespace qualified.


XPath respects unprefixed element names as always in no namespace, so this obligates the stylesheet writer to use prefixed names in XPath expressions when the names being matched are namespace qualified.

So, where you have:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www .w3.org/1999/XSL/Transform">
...
<xsl:template match="Unit">


you will need:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:jeff="http://www.CpmXmlReport.co.il">
 ...
  <xsl:template match="jeff:Unit">

when your XML reads:

<Report xmlns="http://www.CpmXmlReport.co.il">
  ...
  <Unit ID="1" Type="LAN">

Of course you can use any prefix you wish, I'm not sure which one you might want to use, but the above will work because prefixes are irrelevant in XML Namespaces.

I hope this helps.

....................... Ken


-- World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

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.