Hi John,

I'm not sure why you need the resolver at all. In the code you posted, 
you're compiling the schema using the JAXP SchemaFactory:

File schemaLocation = new File("file:///c:/data/sample/shiporder.xsd");
Schema schema = factory.newSchema(schemaLocation);

Presumably you're setting this Schema object [1] on the SAXParserFactory, 
right? SAXParsers created from the SAXParserFactory will use this schema 
for validation. You don't need to (and can't) tell it where to find the 
schema during the parse. The validator already has it and won't ask your 
resolver for any other sources.

Thanks.

[1] 
http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/SAXParserFactory.html#setSchema(javax.xml.validation.Schema)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

<[EMAIL PROTECTED]> wrote on 08/14/2007 01:58:39 PM:

> Hello Michael,
> 
> Thank you for your response.  If I cannot replace the DTD specified in
> the DOCTYPE tag, then short of removing the tag all together, does this
> mean there is no way for me to get XML validation to work (since that
> does require notifying the parser about my schema XSD file).  Or can I
> get this functionality by returning null from the resolver and then
> assigning a schema to the parser/validator?
> 
> I tried to reduce my "schema" tag definition in my xsd to:
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";> but I still get
> the error.  I suppose my error is result of the resolver issue rather
> than the namespace declaration.
> 
> John
> 
> 
> > 
> > I have an XML document which has a DOCTYPE tag referencing a DTD.
> > Instead I want to reference an XSD which specifies this document 
> > structure.  I use the XMLCatalogResolver to detect the publicId in the
> 
> > DOCTYPE and replace it with a URI pointing to the XSD.
> 
> You can't replace the DTD with a schema. Whatever you return from this
> call to the resolver needs to be a DTD (in other words must match [1]
> the extSubset [2] production from the XML 1.0 specification) or null if
> you want the parser to use its default resolution mechanism.
> 
> > I think this
> > part is working, however I get an error during the sax parsing:  "The 
> > markup declarations contained or pointed to by the document type 
> > declaration must be well-formed."  I believe the XML is well-formed 
> > because if I omit the DOCTYPE tag from the XML document the parsing 
> > occurs without error.  The namespace in the XSD is 
> > "http://www.ncbi.nlm.nih.gov"; and I don't have any reference to 
> > namespace in the XML document.  Is this what the error is refering to?
> 
> If your schema has a target namespace and your instance document
> declares no namespaces you need to change one of them in order for your
> document to be valid. Either add a namespace declaration to the instance
> document or remove the target namespace from the schema document.
> 
> <snip/>
> 
> > TIA,
> > John
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> Thanks.
> 
> [1] http://www.w3.org/TR/2006/REC-xml-20060816/#ExtSubset
> [2] http://www.w3.org/TR/2006/REC-xml-20060816/#NT-extSubset
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [EMAIL PROTECTED]
> E-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> 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]

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

Reply via email to