By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,463 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

Regression Apache Xerces ? DOCTYPE and XMLSchema

P: n/a
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
Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.