File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes schema import error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "schema import error" Watch "schema import error" New topic

schema import error

Tapio Niemela
Ranch Hand

Joined: Jan 06, 2006
Posts: 77
hi, I'm studying xml schemas etc but have ran into problem I can't figure out.. has an example of importing schema into another schema..I'm trying to validate corresponding(simplified) schema to find out how it is's the camera.xsd

and here's the Nikon.xsd

finally simple xml (camera.xsd resides on com/xml):

I'm getting this error message when trying to validate the xml file.

error: src-resolve: Cannot resolve the name 'nikon:body' to a(n) 'type definition' component.

Can someone please help me out ?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 633
To make it works, there are changes on each of the document.

[1] sample xml

[1.1] The body node and its children are lived in the namespace of As such they are living in namespace which is clearly not the intention. I set it up with a default namespace attached to body, that requires less labour and clearer. If you want an explicit prefix, you've to declared it in the root or at the body and then qualify the names body and description with the prefix.

[2] camera.xsd

[2.1] The line referring to the body is clearly problematic. In the Nikon.xsd, there is no type named nikon:body scripted as a top element. It is only of that kind of structure that you can refer a type with type="nikon:body".

[2.2] Besides, the top level element is xsl:element of name "body" in the Nikon.xsd. Hence, to refer to that construction, in the camera.xsd with xsl:import, you should use "ref" attribute with the fully qualified name rather than anything else, like this.

[3] Nikon.xsd

[3.1] And then in the schema describing namespace, you have to explicitly define the elementFormDefault attribute as qualified. The reason is more subtle. It is because, without, the child elements (such as xsd:element @name="description") hidden in the top element (xsd:element @name="body") would have some trouble in determining the namespace they are living in.

With the above changes, the setup would be working as intended.
I agree. Here's the link:
subject: schema import error
It's not a secret anymore!