Re: Bad element when DTD specified

Subject: Re: Bad element when DTD specified
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 03 Sep 1999 10:47:03 -0400
At 99/09/03 15:18 +0100, DPawson@xxxxxxxxxxx wrote:
I've just been going nuts for an hour.

Given an invalid XML document, which specifies a local DTD,
and does not match it,

Xt seems to 'fail' to style it, insofar as the events
which trigger a match on a particular element sequence
seem not to occur. It triggers on the root element '/'
but no other patterns are matched further down the tree.

I don't see this evidence with my own test (copied below).


As soon as I remove the doctype, it all 'works' as expected.

Is this expected behaviour?

I wouldn't have thought so. A validating XSLT processor could give you an error on your input as a guide (I've lost a lot of time trying to "fix" a transformation problem that was just bad input that hadn't been validated ... I now make it a practice to validate my input as a separate (but always executed) step when I process an XSLT script on input).


If the DTD is available, does XT
parse it (and not report errors?)

It does parse the DTD to find out which attributes are ID attributes in order to correctly assign an unique identifier to element nodes ... but it doesn't validate.


Can you post a small example of what you are doing?

........ Ken

T:\dave>type test.dtd
<!ELEMENT test ( salutation+ )>
T:\dave>type test.xml
<?xml version="1.0"?>
<!DOCTYPE test SYSTEM "test.dtd">
<test>
 <greeting>Hello</greeting>
 <greeting>World!</greeting>
</test>
T:\dave>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";>

<xsl:output method="xml"/>

<xsl:template match="greeting">
  <p><xsl:apply-templates/></p>
</xsl:template>

</xsl:stylesheet>

T:\dave>call xsl test.xml test.xsl test.out
T:\dave>type test.out

 <p>Hello</p>
 <p>World!</p>

T:\dave>call xml test.xml
Parsing: 'test.xml' for XML errors
test.xml: 4, 27: Element "<greeting>" is not valid in this context.
test.xml: 6, 8: Element "<test>" is not valid because it does not follow the rule, "(salutation)+".


T:\dave>

--
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   (Fax:-0995)
Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath      ISBN 1-894049-01-2
Next instructor-led training:  1999-09-24, 1999-11-08, 1999-12-05/06,
                             1999-12-07, 2000-02-27/28, 2000-05-11/12



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


Current Thread