JDOM XMLSchema + DTD validation error

View: New views
3 Messages — Rating Filter:   Alert me  

JDOM XMLSchema + DTD validation error

by Geert Delanote-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

How do you combine XMLSchema validation with the use of DTD's (for entities)?

I have an XMLSchema describing my XML instances. An instance is a
combination of some parts. The parts can be used in multiple wholes.
So I thought to work in the following way :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE whole [
<!ENTITY p7 SYSTEM "p7.xml">
<!ENTITY p8 SYSTEM "p8.xml">
]>
<whole xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="mySchema.xsd">
&p7;
&p8;
</whole>

My Java code is :
SAXBuilder builder = new SAXBuilder(true);
builder.setFeature("http://apache.org/xml/features/validation/schema", true);
doc = builder.build(new File("PathToMyFile"));

Parsing the input file gives the following error : "Element type
"whole" must be declared."

Anyone an idea what I'm doing wrong?
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

RE: JDOM XMLSchema + DTD validation error

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try new SAXBuilder(false).

You don't actually want DTD validation, you just want entity expansion,
which should happen anyway.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: jdom-interest-bounces@...
> [mailto:jdom-interest-bounces@...] On Behalf Of Geert Delanote
> Sent: 24 June 2009 10:11
> To: jdom-interest@...
> Subject: [jdom-interest] JDOM XMLSchema + DTD validation error
>
> How do you combine XMLSchema validation with the use of DTD's
> (for entities)?
>
> I have an XMLSchema describing my XML instances. An instance
> is a combination of some parts. The parts can be used in
> multiple wholes.
> So I thought to work in the following way :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE whole [
> <!ENTITY p7 SYSTEM "p7.xml">
> <!ENTITY p8 SYSTEM "p8.xml">
> ]>
> <whole xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="mySchema.xsd">
> &p7;
> &p8;
> </whole>
>
> My Java code is :
> SAXBuilder builder = new SAXBuilder(true);
> builder.setFeature("http://apache.org/xml/features/validation/
> schema", true); doc = builder.build(new File("PathToMyFile"));
>
> Parsing the input file gives the following error : "Element
> type "whole" must be declared."
>
> Anyone an idea what I'm doing wrong?
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you
> rhost.com

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: JDOM XMLSchema + DTD validation error

by Geert Delanote-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There is no validation at all anymore then?

My workaround now is :
                        SAXBuilder builder = new SAXBuilder(false);
                        Document doc = builder.build(new File("PathToMyFile"));
                        doc.setDocType(null);
                        SAXBuilder valBuilder = new SAXBuilder(true);
                        valBuilder.setFeature("http://apache.org/xml/features/validation/schema",
true);
                        valBuilder.build(new StringReader(new
org.jdom.output.XMLOutputter().outputString(doc)));

Using the same builder twice with the extra statement
builder.setValidation(true) doesn't work : I don't understand why...


On Wed, Jun 24, 2009 at 11:38 AM, Michael Kay<mike@...> wrote:

> Try new SAXBuilder(false).
>
> You don't actually want DTD validation, you just want entity expansion,
> which should happen anyway.
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay
>
>> -----Original Message-----
>> From: jdom-interest-bounces@...
>> [mailto:jdom-interest-bounces@...] On Behalf Of Geert Delanote
>> Sent: 24 June 2009 10:11
>> To: jdom-interest@...
>> Subject: [jdom-interest] JDOM XMLSchema + DTD validation error
>>
>> How do you combine XMLSchema validation with the use of DTD's
>> (for entities)?
>>
>> I have an XMLSchema describing my XML instances. An instance
>> is a combination of some parts. The parts can be used in
>> multiple wholes.
>> So I thought to work in the following way :
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE whole [
>> <!ENTITY p7 SYSTEM "p7.xml">
>> <!ENTITY p8 SYSTEM "p8.xml">
>> ]>
>> <whole xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:noNamespaceSchemaLocation="mySchema.xsd">
>> &p7;
>> &p8;
>> </whole>
>>
>> My Java code is :
>> SAXBuilder builder = new SAXBuilder(true);
>> builder.setFeature("http://apache.org/xml/features/validation/
>> schema", true); doc = builder.build(new File("PathToMyFile"));
>>
>> Parsing the input file gives the following error : "Element
>> type "whole" must be declared."
>>
>> Anyone an idea what I'm doing wrong?
>> _______________________________________________
>> To control your jdom-interest membership:
>> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you
>> rhost.com
>
>
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...