Thanks for the suggestion! This works (in a Xerces SAXParser, as well) if you also set the feature "http://xml.org/sax/features/external-general-entities " to true. (The space at the end seems to be required.)

The Xerces-specific code that I used is:

SAXParser parser = new SAXParser(symbolTable, grammarPool);
parser.setEntityResolver(er);
parser.setErrorHandler(eh);
try {
parser.setFeature(Xerces2Constants.NAMESPACES_FEATURE_ID, true);
parser.setFeature(Xerces2Constants.VALIDATION_FEATURE_ID, true);
parser.setFeature(Xerces2Constants.SCHEMA_VALIDATION_FEATURE_ID, true);
parser.setFeature(Xerces2Constants.SCHEMA_FULL_CHECKING_FEATURE_ID, true);
// this will allow the parser not to emit DTD-related
// errors, as the jaxp spec demands
parser.setProperty(
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
"http://www.w3.org/2001/XMLSchema";);
// This causes the external subset to be parsed.
parser.setFeature(
"http://xml.org/sax/features/external-general-entities ", true);
InputSource in = new InputSource(docReader);
in.setSystemId(docUri);
parser.parse(in);
...


The first comment is copied out of the Xerces implementation.

Bob

George Cristian Bina wrote:
Hi Neil, Bob,

> I haven't actually tried this, but what happens if you use the JAXP
> property "http://java.sun.com/xml/jaxp/properties/schemaLanguage";, set to
> "http://www.w3.org/2001/XMLSchema";?


It works, I replied to Bob with the same advise about two months ago:
http://marc.theaimsgroup.com/?l=xerces-j-dev&m=111156796913646&w=2

[Bob]
 > A number of XML editors have started supporting this no
 > concept, raising user expectations this is a valid combination.

Well, we added support for this at users requests more that a year ago I think.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Neil Graham wrote:

Hi Bob,

I haven't actually tried this, but what happens if you use the JAXP property "http://java.sun.com/xml/jaxp/properties/schemaLanguage";, set to "http://www.w3.org/2001/XMLSchema";? If you set isValidating to true on a SAXParserFactory, and set this property on the SAXParser instance, I believe you should get the behaviour you desire.

Cheers,
Neil
Neil Graham
Manager, XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  [EMAIL PROTECTED]





Bob Foster <[EMAIL PROTECTED]> 05/18/2005 02:14 AM
Please respond to
j-users


To [email protected] cc

Subject
Re: How to use entities with XML Schema?






Joseph Kesselman wrote:

Schema has no concept of entities, so to do this you have to validate
against a DTD (or an internal subset) to expand the entities, then


validate

again against the schema. I _think_ simply turning on both kinds of
validation and having the proper doctype in the source file will do the
right thing.



Nope. If you have a DOCTYPE with either an internal or external DTD, Xerces validates against the DTD.



Officially (officiously?), the folks who designed schemas expect us to


stop

using entities and migrate to some other variety of macro/external-data
reference.



Not their problem, eh?

It's mine. A number of XML editors have started supporting this no concept, raising user expectations this is a valid combination.

Bob Foster


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to