[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] No html if XSD present?


Subject: Re: [xsl] No html if XSD present?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 19:46:53 -0500

At 2004-01-27 22:59 +0000, davidpbrown wrote:
I have an XML source from which I generate xhtml from an XSLT.

That works fine and there's no problem until I suggest a XSD in the XML.
Then it spews out only the text result with none of the tags!?

The only tag to survive is the XML <?xml version="1.0" encoding="utf-8"?>

The XSL, XSD and XML are all valid as per the Sun's Multischema XML
validator (thanks to G. Ken Holman for suggesting that in another post)

The XML's XSD declaration I have as
<file xmlns="http://www.example.com/ns/file.xsd"

I suspect that you've just added the default namespace to every element type used in the document.


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/ns/file.xsd">

I am processing these on my local hard drive but this seems to be ok, in
that the XSD declares that it is the http://www.example.com/ns/file.xsd
suggested, even though it isn't found at that location.

Note that namespace URIs are *not* locations for anything at all. There is never any kind of dereferencing. The URI string is just that: a string ... it isn't a location at all and there is no purpose for any XML processor to do any kind of fetching or resolving of a namespace URI.


What adding the declaration does is change the name of every element in scope in the document: instead of having a null URI namespace URI component to the name, all names now have the URI string.

Any ideas why no tags pass when XSD is present?

Because XPath expressions *never* use the default namespace. You will need to go into every location step that uses an element type of every location path in your stylesheet and add an explicit namespace prefix whose URI matches the default namespace of your input document. Using no prefix on an element type or attribute name in XPath explicitly matches only element types and attribute names in no namespace.


Make those changes and then the matches will start working again.

I hope this helps.

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

--
Public courses: sign up for one or both soon to reserve your seat!
Each week:  Monday-Wednesday: XSLT/XPath;  Thursday-Friday: XSL-FO
Washington, DC: 2004-03-15           San Francisco, CA: 2004-03-22
Hong Kong, China: 2004-05-17           Bremen, Germany: 2004-05-24
World-wide on-site corporate, government & user group XML 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


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords