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

Re: [newbie]   in xslt-file


Subject: Re: [newbie]   in xslt-file
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 2 Nov 2000 17:22:56 -0400 (EST)

Vincent,

>However, this does not work. The parser (msxml3.dll) gives an error ("the
>stylesheet does not contain a document element. The stylesheet may be empty,
>or it may not be a well-formed XML document"). The document appears to be OK
>when i leave the &nbsp; out of it.
>
>I tought the &nbsp; entity was predefined in xml. Does anyone know the
>numeric form of that character, or does anyone has other ideas why this does
>not work?

The &nbsp; entity is not predefined in XML.  The only entities that are are
&lt;, &gt;, &amp;, &quot; and &apos;.  To define the &nbsp; entity, include
the following in your DTD:

<!ENTITY nbsp '&#160;'>

Or of course you can use &#160; wherever you currently use &nbsp;.  I use
the HTML4.01 spec (from the W3C site) as my source of character references,
but there are plenty of other resources out there that list them.

The reason that MSXML reports a problem with the document element is that
the error is arising from the MSXSL processor, which is being passed a DOM
with no content, due to the fact that the document could not be parsed into
the DOM in the first place, because of the missing entity definition.  I
guess that you're using MSXML within some scripting (the parse error is
reported if you use MSXML in IE without scripting), in which case I
recommend that you add something like:

  XSLDOM.load(XSLfile);

  if (XSLDOM.parseError.errorCode != 0) {
    error = XSLDOM.parseError;
    alert('Error parsing XSLT file:\n' + error.reason + '[' + error.url + 
          ': line ' + error.line + ', col ' + error.linepos + ']');
    return;
  }

which will help you identify any well-formedness errors, like this one, in
the stylesheet.

Cheers,

Jeni

Jeni Tennison
http://www.jenitennison.com/




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



Current Thread
Keywords