Re: [xsl] XSL / XML initial tag incompatibility

Subject: Re: [xsl] XSL / XML initial tag incompatibility
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Mar 2005 13:15:19 -0500
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">
<xsl:template match="Unit">

you will need:

<xsl:stylesheet version="1.0" xmlns:xsl="";
  <xsl:template match="jeff:Unit">

when your XML reads:

<Report xmlns="";>
  <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. Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness Legal business disclaimers:

Current Thread