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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to