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(_at_)CraneSoftwrights(_dot_)com
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--