Neil,  
Thanks for this explanation.  I actually did wade a little into the source
code and saw this EntityResolver in the TraverseSchema class that would find
the location of the included schema.  When I set it to null in the
traverseInclude method, it would find the correct location because the
default has been thrown away. And, my document parsed fine. So, I understand
where you are coming from when you are saying that if the EntityResolver
already exists it uses it instead of going off of the current document.  I
don't know if I am convinced that using the default is the best way to
handle included schemas but I have considered a work around of having our
XML docs refer to an in house URL and the schemas to use the URL in their
includes (http:// instead of file://). (Maybe this would help you too
Armin?)  I would love to get more involved in the development of Xerces.  I
think it would be nice to have a more robust EntityResolver.  Is there
documentation that explains how classes relate to each other and
descriptions of what classes are for?  I guess I am looking for general to
specific intro material besides wading even more into the source without a
good handle on things.  Thanks for taking the time to write about this, I
really do appreciate all the work that has been done on this parser.

-David

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 19, 2001 5:06 PM
To: [EMAIL PROTECTED]
Subject: RE: Schema not found


Hi David and Armin,

I think this is the problem.  Say a user wants to take control over what
documents get resolved to by schemaLocation attributes.  So she registers
an EntityResolver with the parser she's using.  In this situation, she'll
expect Xerces to use her EntityResolver whether it's parsing an instance
doc or a schema.  To Xerces, one EntityResolver is as good as another; so
we always use our default entityResolver unless the user tells us
otherwise.

Now the DefaultEntityResolver doesn't know anything about anything; the
world looks the same to it when it's called from an instance document as
when called from a schema.  It just looks at the system property user.dir
(if no absolute URI is specified) and goes from there.  So naturally its
behaviour is the same when called from a schema as from an instance doc.

So the right solution appears to be this:  If xerces's default treatment is
not to your liking, write your own EntityResolver and handle it yourself.
IMHO, while making our DefaultEntityResolvre context sensitive--or invoking
different default EntityResolvers in different places--might make us more
compatible with XMLSpy, it would also make our default resolution less
predictable.

Hope that helps,
Neil

Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  416-448-3519, T/L 778-3519
E-mail:  [EMAIL PROTECTED]



"NeSmith, David" <[EMAIL PROTECTED]> on 07/19/2001 11:28:01 AM

Please respond to [EMAIL PROTECTED]

To:   "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:
Subject:  RE: Schema not found


I guess what Armin and I were saying is that the included schema should be
able to be referenced by the original schema by a relative path extending
from the original schema. If you reference all schemas relative to your XML
file, then when you open your original schema (which is in a seperate
directory than your XML file) in say, XML Spy, then it can't find the
included schema.  Also, it doesn't appear to be the case that XERCES 1.4.1
is looking for the schema in the prog executing directory.  Try to parse
Armin's XML file in a seperate directory from your execution directory and
you will get an error XSD not found in the XML file's directory.

-David

-----Original Message-----
From: Etienne Roy [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 19, 2001 10:26 AM
To: [EMAIL PROTECTED]
Subject: Re: Schema not found



Armin,

Xerces look up the files relatively to the directory you're runnning your
prog in, and not the one your first schema is:

> > [Warning] :0:0: File "file:///home/dave/tmp/ML_primitive.xsd" not
found.

Your prog in running in home/dave/tmp/ where it's looking for ML_primitive,
that is not here but in xsd/.
If you change <include schemaLocation="ML_primitive.xsd"/> to <include
schemaLocation="xsd/ML_primitive.xsd"/> in ML.xsd, that works.
Same thing if you move both schemas in tmp/ and remove the relative path in
your instance.

> I have a schema which includes another schema. Xerces doesn't find the
> included schema, if the schema files and the xml file are in different
> directories. What can I do? I know I asked the same question a few days
ago,
> but there was no answer. I really need a solution to the problem.

Cheers

--
Etienne


---------------------------------------------------------------------
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]

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

Reply via email to