• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

schema validation/parser problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the xerces 2.5 java parser to do schema validation and have
run into a problem that I am not sure if it's with my schema or the
parser.
The problem is this:
I have a base schema (base.xsd) and I extend it with a (extension.xsd)
which defines a new complex type by extending one of the types defined
in the base.xsd. ( I use "<xs:import>" since the extension.xsd has a different target namespace)
An instance document using the base.xsd:
<base:RootMsg xmlns:base="http://www.foo.com/base"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.foo.com/base base.xsd"
language="en-us">
....
</base:RootMsg>
validates just fine.
But when I create an instance document using extension.xsd:
<base:RootMsg xmlns:base="http://www.foo.com/base"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.foo.com/userextension extension.xsd"
language="en-us" xmlns="http://www.foo.com/userextension">
....
</base:RootMsg>
I get an error right away complaining about "base:RoogMsg" not being
defined, when debuging this I see that the error occurs before the
parser tries to load the "extension.xsd" schema. the schema is loaded
just fine and it will validate against the type that is defined there
but it won't validate against anything in the base.xsd.
Is there something wrong with my instance document? or does this sound
like a parser problem?
thanks in advance for your help.
Eugene
[ March 24, 2004: Message edited by: Eugene Yusim ]
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I could think is there is some problem with the name space you are using, though not in the instance, it may be in the "userextension extension.xsd". Please check whether you are using proper namespace of the base.xsd in the import element of extension.
 
Eugene Yusim
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, got it figured out.
the schemaLocation of the instance document that uses the extension.xsd must also include the base.xsd, so it would look like this:
xsi:schemaLocation="http://www.foo.com/base base.xsd http://www.foo.com/userextension extension.xsd"
 
G Buddha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eugene,
Though this method works, actually what you are trying to do here is explicitly mentioning both the Schema "base.xsd" and "userextension extension.xsd". This is something wrong. Once you imported the "base.xsd" in "userextension extension.xsd" with proper namespace of "base.xsd" then the instance document should not have any problem. If it is still not recognizing "base.xsd" without explicitly mentioning it, it means either your import statement is wrong or the parser you are using is not recognizing import statement at all. In either case, you will run into problem if any of the element in "userextension extension.xsd" has type declared / refered to another element in "base.xsd".
You can check validity of both the schema's in the following site.(Scroll down the site you may find Schema Check)
Schema Check
If that doesn't help, Post the import statement in extension.xsd as well as the Namespace declaration in base.xsd. Let us examine if there is any problem with your schema.
Regards,
G
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic