You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Daniel Jackson <af...@gmail.com> on 2008/03/02 18:23:46 UTC

Re: setExternalSchemaLocation and xs:import

Hi Boris,

After trying several things I decided to go with the in-memory schema
including the others.
However this didn't work as expected.
Instead of asking a praticular question I'd like to explain my main goal to
understand if my approach to it is the correct one. It will be a bit long so
please bare with me :).

My program recieves as input an XML file. My goal is to check if this XML
file passes schema validation. The XML file must contain 'xmlns'es. In the
program I go over all the 'xmlns', that's how I know which schemas I need
inorder to validate.
My program also has a multimap consisting of key=the targetnamespace of a
schema, and value=the file itself.

After I collected all my xmlnses I go to that list and start searching the
appropriate schemas.
First problem is here. How do I know which schema to take? Suppose I have
several schemas with the same target namespace, I can't know which schema is
the one I need. So here the solution you proposed with the in-memory schema
seems to fit. I just take all the schemas with the wanted target namespace
and create a big one that includes the rest. I load this in-memory schema
using loadGrammar. However when I try myparser.parse()... I get an error
saying some element in the XML can't be found. That element is infact
defined in one of the included schemas. I would expect the parser to call
resolveEntity for the schemas referenced from the in-memory one but this
doesn't happen. I tried messing with this abit and noticed that if I only
set setExternalSchemaLocation without using loadGrammar I get several calls
to resolveEntity, as expected - but this complicates things for me. What is
the right way to handle this situation?

Suppose I don't have several schemas matching my 'xmlns'es. I use
loadGrammar on all of the requested schemas and hit the parsing. Now my
problem is abit different, what if a schema tries to include another schema?
The include only has a schemaLocation attribute, which I can't rely on. So
I'm left with the target namespace of the current schema that is trying to
include the other one. In ResourceIdentifier I have BaseURI and SystemId
that can help me figure out what's the target namespace of the current
schema file, but is there a better approach to this?

Thanks in advance.

Thanks in advance.


Boris Kolpackov-2 wrote:
> 
> Hi Daniel,
> 
> Daniel Jackson <af...@gmail.com> writes:
> 
>> I have schema A that includes schema B, both have a
>> targetNamespace="http://www.foo.com".
>> I have a XML file that uses as his default namespace
>> "http://www.foo.com",
>> meaning it's root element has a xmlns="http://www.foo.com".
>>
>> When running Xerces C++ with schema validation I need to determine what
>> to
>> send the parser on it's setExternalSchemaLocation. Assuming I don't know
>> which schema is the "main" one (in my case it's A), should I send both A
>> and
>> B in the setExternalSchemaLocation? What's the way to handle this?
> 
> The value of the schema location property is a map of namespace-to-
> schema. Each entry specifies a schema for a particular namespace. As
> a result, you can only specify one schema for a distinct namespace.
> 
> If there is really no way to know which file is the "root schema",
> then the only way to overcome this is to create (perhaps at runtime)
> a schema that includes all the schema files for the same namespace.
> If you are using setExternalSchemaLocation then this file will have
> to be real. If, however, you use loadGrammar, you can create this
> schema in memory. The latter method is discussed here:
> 
> http://www.codesynthesis.com/pipermail/xsd-users/2007-December/001403.html
> 
> Boris
> 
> -- 
> Boris Kolpackov, Code Synthesis Tools
> Open source XML data binding for C++:  
> http://codesynthesis.com/products/xsd
> Mobile/embedded validating XML parsing:
> http://codesynthesis.com/products/xsde
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/setExternalSchemaLocation-and-xs%3Aimport-tp15532404p15790523.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Daniel Jackson <af...@gmail.com>.
Hello,

I was looking into XMLGrammarPool and GrammarResolver and noticed that both
have a way of caching an existing Grammar object. My main goal is to keep
the Grammar objects themselves and load those into the parser objects,
directly or through the resolver or some other way... I want to achieve this
because even though I want to cache the schemas I don't want every parser
object I create to use the same XMLGrammarPool, so every time I create a
parser I'll see what schemas it needs, then get the matching Grammar objects
and build my XMLGrammarPool.
Well I tried doing what I just described but it didn't work. At first I
created a dummy parser object and used loadGrammar to load my schemas.
loadGrammar returns Grammar*, I kept those aside and added them to a
different XMLGrammarPool (I also tried adding them to a GrammarResolver).
After I finished loading all my schemas to both pools, I parsed a valid XML
file using the parser object that I used loadGrammar on and the file passed
validation. Then I tried using a parser object initialized with the other
XMLGrammarPool and it failed due to some type missing.

Something else I was wondering about the XMLGrammarPool is what does it do
with the referenced schemas? If I use loadGrammar on schema A that includes
B, will the parser object add schema B to the pool aswell? If so I'm
guessing I don't get 2 Grammar* objects from loadGrammar but maybe schema B
is somehow saved inside schema A's Grammar*?

I hope you understand what I mean, it's getting abit complicated :)

Thanks!


Boris Kolpackov-2 wrote:
> 
> Hi Daniel,
> 
> Daniel Jackson <af...@gmail.com> writes:
> 
>> That looks perfect. One question though, can I use XMLGrammarPool with a
>> SAX
>> parser too?
> 
> Yes, the second argument to XMLReaderFactory::createXMLReader is
> XMLGrammarPool.
> 
> Boris
> 
> -- 
> Boris Kolpackov, Code Synthesis Tools
> Open source XML data binding for C++:  
> http://codesynthesis.com/products/xsd
> Mobile/embedded validating XML parsing:
> http://codesynthesis.com/products/xsde
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/setExternalSchemaLocation-and-xs%3Aimport-tp15532404p15855610.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi Daniel,

Daniel Jackson <af...@gmail.com> writes:

> That looks perfect. One question though, can I use XMLGrammarPool with a SAX
> parser too?

Yes, the second argument to XMLReaderFactory::createXMLReader is
XMLGrammarPool.

Boris

-- 
Boris Kolpackov, Code Synthesis Tools
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Daniel Jackson <af...@gmail.com>.
Hey,


Boris Kolpackov-2 wrote:
> 
> Hi,
> 
> Actually, there is a way to achieve the same without implementing
> own XMLGrammarPool. It is described here:
> 
> http://marc.info/?l=xerces-c-users&m=119053289924010&w=2
> 
> 

That looks perfect. One question though, can I use XMLGrammarPool with a SAX
parser too?
-- 
View this message in context: http://www.nabble.com/setExternalSchemaLocation-and-xs%3Aimport-tp15532404p15843843.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi,

David Bertoni <db...@apache.org> writes:

> Parser objects are not thread-safe, although the validation objects are.
> You could write some code to make sure all parser objects use the same set
> of schema validators by implementing your own XMLGrammarPool.

Actually, there is a way to achieve the same without implementing
own XMLGrammarPool. It is described here:

http://marc.info/?l=xerces-c-users&m=119053289924010&w=2

Boris

-- 
Boris Kolpackov, Code Synthesis Tools
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by David Bertoni <db...@apache.org>.
Daniel Jackson wrote:
> 
> David Bertoni wrote:
>> There may be differences in how the two parsers build a schema from the 
>> constituent parts.  The schema recommendation is a little loose in this 
>> area, so there can be inconsistencies.
>>
>> It sounds like Xerces-C is unable to find the definitions for part(s) of 
>> the schema.  The likely cause is the limitation that single top-level 
>> schema document must include all of the other components for the target 
>> namespace URI.
>>
> 
> Yes, Xerces-C can't find the definitions but they are out there in the
> schemas. I mean I checked the error saying some element can't be found and I
> went and found that element defined somewhere. And the problematic schema
> did include/import the right schema. I could also see calls to resolveEntity
> resolving the  "missing" schema.
Xerces-C uses a hash table keyed on the target namespace URI.  If you use 
loadGrammar(), the parser will build a Grammar object for each of the 
target namespaces that it reaches by parsing the entity in the InputSource 
you provide.  If you try to load another grammar that contains more 
components for a target namespace URI the parser has already seen, it will 
skip those components, since it already has a grammar for that namespace URI.

> 
> So if I understand you correctly in the situation I described with the docx
> schemas I should create the in-memory schema that includes all others per
> namespace?
It doesn't have to be in memory.  You could simply create a top-level 
schema document that includes all of the other entities that contain the 
schema components you're interested in.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Daniel Jackson <af...@gmail.com>.

David Bertoni wrote:
> 
> There may be differences in how the two parsers build a schema from the 
> constituent parts.  The schema recommendation is a little loose in this 
> area, so there can be inconsistencies.
> 
> It sounds like Xerces-C is unable to find the definitions for part(s) of 
> the schema.  The likely cause is the limitation that single top-level 
> schema document must include all of the other components for the target 
> namespace URI.
> 

Yes, Xerces-C can't find the definitions but they are out there in the
schemas. I mean I checked the error saying some element can't be found and I
went and found that element defined somewhere. And the problematic schema
did include/import the right schema. I could also see calls to resolveEntity
resolving the  "missing" schema.

So if I understand you correctly in the situation I described with the docx
schemas I should create the in-memory schema that includes all others per
namespace?
-- 
View this message in context: http://www.nabble.com/setExternalSchemaLocation-and-xs%3Aimport-tp15532404p15843769.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by David Bertoni <db...@apache.org>.
Daniel Jackson wrote:
> 
> 
> 
> Boris Kolpackov-2 wrote:
>> Hi Daniel,
>>
>> Sorry for the previous email -- hit send accidently.
>>
>> Daniel Jackson <af...@gmail.com> writes:
>>
>>> So basically if I have schema A that includes schema B (both have the
>>> same
>>> namespace) and I create an in-memory schema that includes both of them
>>> and
>>> has the same namespace, I could use loadGrammar to load all 3 and then
>>> the
>>> XML file should pass validation. Is this correct?
>> Yes, if the XML file conforms to the vocabulary defined by A and B.
>>
> 
> I tried this and noticed something. When loading the in-memory schema I get
> 2 calls to resolveEntity trying to resolve the 2 includes, therefore I don't
> really need to call loadGrammar for schemas A and B right?
Correct.  You should only load the main schema file and let the parser 
resolve the includes.  Otherwise, you'll find things won't work correctly, 
since the parser only allows one grammar per namespace.

> 
> 
> Boris Kolpackov-2 wrote:
>>
>>> I want to handle the resolving of entities during the validation
>>> (here resolveEntity comes along) and if I try loading using
>>> loadGrammar it simply tries on it's own. Maybe there's a way to
>>> make loadGrammar call resolveEntity when it parses the grammar?
>> I would expect it to. Can you make sure that you set your entity
>> resolver before you call loadGrammar?
>>
>> Boris
>>
> 
> You are correct, I set the entity resolver after calling loadGrammar.
> 
> 
> Going abit off-topic I have a general question about the XML parsing
> objects.
> I wish to reuse the parsing object itself (say XercesDOMParser) -- meaning I
> don't want to keep creating a new one and call loadGrammar repeatedly since
> the loading of schemas in my program takes quite a while. Can the parser
> object handle multiple calls to parser.parse()... from different threads? If
> it is what will happen if in thread A I call parser.parse() and in thread B
> I'll call parser.loadGrammar?
Parser objects are not thread-safe, although the validation objects are. 
You could write some code to make sure all parser objects use the same set 
of schema validators by implementing your own XMLGrammarPool.  It's tricky, 
but it can be done, because I implemented such a scheme at my previous job.

> 
> And one last thing, I tried validating a XML file taken from a .docx zip
> file (document.xml) with the schemas provided by Microsoft (there are a few
> dozens) and I get alot of errors while calling loadGrammar to load the
> schemas needed for that XML file saying element X cannot be found etc. Does
> this make sense? I tred validating the same XML using XML Spy or MSXML and
> it works fine.
There may be differences in how the two parsers build a schema from the 
constituent parts.  The schema recommendation is a little loose in this 
area, so there can be inconsistencies.

It sounds like Xerces-C is unable to find the definitions for part(s) of 
the schema.  The likely cause is the limitation that single top-level 
schema document must include all of the other components for the target 
namespace URI.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Daniel Jackson <af...@gmail.com>.



Boris Kolpackov-2 wrote:
> 
> Hi Daniel,
> 
> Sorry for the previous email -- hit send accidently.
> 
> Daniel Jackson <af...@gmail.com> writes:
> 
>> So basically if I have schema A that includes schema B (both have the
>> same
>> namespace) and I create an in-memory schema that includes both of them
>> and
>> has the same namespace, I could use loadGrammar to load all 3 and then
>> the
>> XML file should pass validation. Is this correct?
> 
> Yes, if the XML file conforms to the vocabulary defined by A and B.
> 

I tried this and noticed something. When loading the in-memory schema I get
2 calls to resolveEntity trying to resolve the 2 includes, therefore I don't
really need to call loadGrammar for schemas A and B right?


Boris Kolpackov-2 wrote:
> 
> 
>> I want to handle the resolving of entities during the validation
>> (here resolveEntity comes along) and if I try loading using
>> loadGrammar it simply tries on it's own. Maybe there's a way to
>> make loadGrammar call resolveEntity when it parses the grammar?
> 
> I would expect it to. Can you make sure that you set your entity
> resolver before you call loadGrammar?
> 
> Boris
> 

You are correct, I set the entity resolver after calling loadGrammar.


Going abit off-topic I have a general question about the XML parsing
objects.
I wish to reuse the parsing object itself (say XercesDOMParser) -- meaning I
don't want to keep creating a new one and call loadGrammar repeatedly since
the loading of schemas in my program takes quite a while. Can the parser
object handle multiple calls to parser.parse()... from different threads? If
it is what will happen if in thread A I call parser.parse() and in thread B
I'll call parser.loadGrammar?

And one last thing, I tried validating a XML file taken from a .docx zip
file (document.xml) with the schemas provided by Microsoft (there are a few
dozens) and I get alot of errors while calling loadGrammar to load the
schemas needed for that XML file saying element X cannot be found etc. Does
this make sense? I tred validating the same XML using XML Spy or MSXML and
it works fine.

Thanks alot.

-- 
View this message in context: http://www.nabble.com/setExternalSchemaLocation-and-xs%3Aimport-tp15532404p15824173.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi Daniel,

Sorry for the previous email -- hit send accidently.

Daniel Jackson <af...@gmail.com> writes:

> So basically if I have schema A that includes schema B (both have the same
> namespace) and I create an in-memory schema that includes both of them and
> has the same namespace, I could use loadGrammar to load all 3 and then the
> XML file should pass validation. Is this correct?

Yes, if the XML file conforms to the vocabulary defined by A and B.


> I just tried this and got a RuntimeException, predictably since it tried
> loading the other schemas from the in-memory one and failed because the
> schemaLocation value didn't point to the correct physical path. This is why
> I said I can't rely on the schemaLocation attribute.

Ok, I think I now understand what's going on. The files mentioned in
schemaLocation are resolved relative to the path of the including
schema. What you need to do is pass a path as a system id to
MemBufInputSource (if that's what you are using). That path should
point to the directory where you have included schemas and can have
some non-existent name for the file. For  example, if your schemas
are in /tmp/bar then you would pass "/tmp/bar/fake.xsd" as a system
id. Then all the schemas included by fake.xsd will be resolved
relative to /tmp/bar/.


> I want to handle the resolving of entities during the validation
> (here resolveEntity comes along) and if I try loading using
> loadGrammar it simply tries on it's own. Maybe there's a way to
> make loadGrammar call resolveEntity when it parses the grammar?

I would expect it to. Can you make sure that you set your entity
resolver before you call loadGrammar?

Boris

-- 
Boris Kolpackov, Code Synthesis Tools
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi Daniel,

std::istringstream istr (entry_schema);
xml::sax::std_input_source isrc (istr, "entry-schema.xsd");
Wrapper4InputSource wrap (&isrc, false);

Daniel Jackson <af...@gmail.com> writes:

>
>
> Daniel Jackson wrote:
> >
> > So basically if I have schema A that includes schema B (both have the same
> > namespace) and I create an in-memory schema that includes both of them and
> > has the same namespace, I could use loadGrammar to load all 3 and then the
> > XML file should pass validation. Is this correct?
> >
>
> I just tried this and got a RuntimeException, predictably since it tried
> loading the other schemas from the in-memory one and failed because the
> schemaLocation value didn't point to the correct physical path. This is why
> I said I can't rely on the schemaLocation attribute. I want to handle the
> resolving of entities during the validation (here resolveEntity comes along)
> and if I try loading using loadGrammar it simply tries on it's own. Maybe
> there's a way to make loadGrammar call resolveEntity when it parses the
> grammar? But I can get a similar behaviour if I don't use loadGrammar,
> instead I just use setExternalSchemaLocation with "<the namespace of the
> in-memory schema> <some dummy string>" and then the parser calls
> resolveEntity several times and everything is fine.

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Daniel Jackson <af...@gmail.com>.

Daniel Jackson wrote:
> 
> So basically if I have schema A that includes schema B (both have the same
> namespace) and I create an in-memory schema that includes both of them and
> has the same namespace, I could use loadGrammar to load all 3 and then the
> XML file should pass validation. Is this correct?
> 

I just tried this and got a RuntimeException, predictably since it tried
loading the other schemas from the in-memory one and failed because the
schemaLocation value didn't point to the correct physical path. This is why
I said I can't rely on the schemaLocation attribute. I want to handle the
resolving of entities during the validation (here resolveEntity comes along)
and if I try loading using loadGrammar it simply tries on it's own. Maybe
there's a way to make loadGrammar call resolveEntity when it parses the
grammar? But I can get a similar behaviour if I don't use loadGrammar,
instead I just use setExternalSchemaLocation with "<the namespace of the
in-memory schema> <some dummy string>" and then the parser calls
resolveEntity several times and everything is fine.

-- 
View this message in context: http://www.nabble.com/setExternalSchemaLocation-and-xs%3Aimport-tp15532404p15799982.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Daniel Jackson <af...@gmail.com>.
Hi Boris,


Boris Kolpackov-2 wrote:
> 
> Another alternative would simply be to pre-load all of your schemas
> with loadGrammar (this would also involve creating in-memory "includer"
> schemas for schemas with the same namespace) and then let the parser
> figure out what to use. The advantage of this approach is that you
> don't need to parse your XML documents twice.
> 

So basically if I have schema A that includes schema B (both have the same
namespace) and I create an in-memory schema that includes both of them and
has the same namespace, I could use loadGrammar to load all 3 and then the
XML file should pass validation. Is this correct?


Boris Kolpackov-2 wrote:
> 
> Well, if you can't rely on your schemas being complete/valid, then you
> probably won't be able to validate an XML document against them. This
> does not make much sense to me, though: how can you not rely on the
> schemaLocation attributes inside the schemas that presumably came with
> your application?
> 

I can rely on my schemas but I can't rely on the schemaLocation value being
the correct one. The only thing I can rely on is the file name in the
schemaLocation (not including the path etc.) and the namespace of the
including schema. That's how I can find the needed schema. I go to my map
and search for that namespace, then I should get more than one schema with
that namespace and here I have the file name that distinguishes between the
schemas. 

-- 
View this message in context: http://www.nabble.com/setExternalSchemaLocation-and-xs%3Aimport-tp15532404p15799964.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: setExternalSchemaLocation and xs:import

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi Daniel,

Daniel Jackson <af...@gmail.com> writes:

> My program recieves as input an XML file. My goal is to check if this XML
> file passes schema validation. The XML file must contain 'xmlns'es. In the
> program I go over all the 'xmlns', that's how I know which schemas I need
> inorder to validate.
>
> After I collected all my xmlnses I go to that list and start searching the
> appropriate schemas.

Another alternative would simply be to pre-load all of your schemas
with loadGrammar (this would also involve creating in-memory "includer"
schemas for schemas with the same namespace) and then let the parser
figure out what to use. The advantage of this approach is that you
don't need to parse your XML documents twice.


> First problem is here. How do I know which schema to take? Suppose I have
> several schemas with the same target namespace, I can't know which schema is
> the one I need. So here the solution you proposed with the in-memory schema
> seems to fit. I just take all the schemas with the wanted target namespace
> and create a big one that includes the rest. I load this in-memory schema
> using loadGrammar. However when I try myparser.parse()... I get an error
> saying some element in the XML can't be found. That element is infact
> defined in one of the included schemas. I would expect the parser to call
> resolveEntity for the schemas referenced from the in-memory one but this
> doesn't happen. I tried messing with this abit and noticed that if I only
> set setExternalSchemaLocation without using loadGrammar I get several calls
> to resolveEntity, as expected - but this complicates things for me. What is
> the right way to handle this situation?

This should work. If you can send a small test case that reproduces this
then I will take a look.


> Suppose I don't have several schemas matching my 'xmlns'es. I use
> loadGrammar on all of the requested schemas and hit the parsing. Now my
> problem is abit different, what if a schema tries to include another schema?
> The include only has a schemaLocation attribute, which I can't rely on.

Well, if you can't rely on your schemas being complete/valid, then you
probably won't be able to validate an XML document against them. This
does not make much sense to me, though: how can you not rely on the
schemaLocation attributes inside the schemas that presumably came with
your application?

Boris

-- 
Boris Kolpackov, Code Synthesis Tools
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org