Regression Apache Xerces ? DOCTYPE and XMLSchema

B

BODIN

I have an XML document, which is actually physically stored in 2
separated files.

doc1.xml and doc2.xml

I NEED a WAY FOR THIS SIMPLE NEED : XML file splitted into two
physical files,
and use of XML Schema.


USING DTD : OK.
---------------
doc2.xml is included within doc1.xml with an external ENTITY when
using a DTD, and this works fine.

<!DOCTYPE PROJECT SYSTEM "leon/conf/dtd/leon.dtd"
[
<!-- Inclusion des actions standard -->
<!ENTITY DOC2 SYSTEM 'leon/conf/xml/leon.xml'>
]>

<PROJECT id="compta" rootAction="compta_dashboard">
&DOC2;
</PROJECT>

USING XML Schema : OK if no Entities
------------------------------------
<PROJECT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="leon/conf/xml/leon.xsd" id="compta"
rootAction="compta_dashboard">

<!-- . . . -->
</PROJECT>

But here I need to COPY PASTE the DOC2.XML file content which is ugly
since I have actually many files like doc2.xml to include

********************************************
*** Here come troubles with Xerces parsers :
********************************************
1) I tried to add the DOCTYPE with no DTD (supported by an old
version of xerces Parser)

<!DOCTYPE PROJECT
[
<!-- Inclusion des actions standard -->
<!ENTITY DOC2 SYSTEM 'leon/conf/xml/leon.xml'>
]>

<PROJECT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="leon/conf/xml/leon.xsd" id="compta"
rootAction="compta_dashboard">

&DOC2;
</PROJECT>

This is *NOT* working since DOCTYPE is PREFERRED to the XMLSchema and
it says that my root element PROJECT is undefined :-(

2) I tried to play with features :
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/schema",
true);

It did'nt worked either

3) I tried to get rid of the DOCTYPE, got xerces 2.6 (recent) and use
the new XInclude syntax :
<PROJECT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="leon/conf/xml/leon.xsd" id="compta"
rootAction="compta_dashboard">

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="doc2.xml" parse='xml' encoding="ISO-8859-1"/>
</PROJECT>

This SEEMS to include the doc2.xml file, but how stupid ! It says that
no grammar (DTD) is found for doc2.xml !
Of course because it is an XML Schema.

I also tried :
<PROJECT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="leon/conf/xml/leon.xsd" id="compta"
rootAction="compta_dashboard">

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="doc2.xml" parse='text' encoding="ISO-8859-1"/>
</PROJECT>

But this is not validating : doc2.xml is considered as a String and
not as a NodeSet ...

-----------------------------------------------------

Did anyone succeed in using Xerces and XMLSchema + entities ?
The only solution I see is to have my own Reader for the XML source
for xerces
and replace the entities of my own before the parsers gets it, but
this what the parser is expected to do ???

Thanks a lot for your help/support
Nicolas BODIN
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top