The only thing I can spot which made a difference when using your example is
that :
<!ELEMENT test:complex-structure (EMPTY)>
should be:
<!ELEMENT test:complex-structure EMPTY>
but I got a different SAX parse error pointing this out. Once this was
corrected it parsed happily with the namespace.
I use the following set of features, but the first two are the default
values anyway aren't they?
parser.setFeature("http://xml.org/sax/features/namespaces",true);
parser.setFeature("http://xml.org/sax/features/namespace-prefixes",false);
parser.setFeature("http://xml.org/sax/features/validation", true);
My only other question is, is your dtd as simple as below or are there more
element definitions? If so there may be another syntax problem which is
causing the SAX not to see the test:top-element declaration. I have had
many a problem with incorrect dtds and the errors the SAX parser produces
may not highlight the actual problem. My client's problem is generating
syntactically correct MIXED declarations.
Sorry I can be of no more help.
Hilary
----- Original Message -----
From: Julian Templeman <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; Hilary Bannister
<[EMAIL PROTECTED]>
Sent: 03 April 2001 20:02
Subject: Re: Using Namespaces and DTDs...
Hilary said:
>An simple example of a DTD (called all-tests.dtd) would be:
>
><!ELEMENT test:top-element
> (test:simple-structure | test:complex-structure | test:complex-structure2
|
>test:complex-structure3 | test:complex-structure4)+>
><!ATTLIST test:top-element
> xmlns:test CDATA #FIXED "http://deltaxml.com/docs/dtds/test/test-co1>
>....
>
>and the xml document would be:
>
><?xml version="1.0"?>
><!DOCTYPE test:top-element SYSTEM "all-tests.dtd">
><test:top-element ><test:complex-structure/>
></test:top-element>
OK... that's how I understood it ought to work. So I took the example
and made up an XML file ike this:
<?xml version="1.0"?>
<!DOCTYPE test:top-element SYSTEM "test1.dtd">
<test:top-element
xmlns:test="http://deltaxml.com/docs/dtds/test/test-co1">
<test:complex-structure/>
</test:top-element>
And a DTD like this:
<!ELEMENT test:top-element (test:complex-structure)+>
<!ATTLIST test:top-element
xmlns:test CDATA #FIXED
"http://deltaxml.com/docs/dtds/test/test-co1">
<!ELEMENT test:complex-structure (EMPTY)>
The Java code creates a SAX parser, turns validation and namespace
awareness on, and then tries to parse the file. The result is the same
as before, with a parser error in line 3 of the XML: "test:top-element
must be declared"
If I turn validation off then the problem doesn't occur, but then
neither does validation, so it's hardly useful :-)
Any hints as to what is going on will be gratefully received!
julian
Templeman Consulting Limited
London and North Wales
http://www.templeman-consulting.co.uk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]