aspose file tools*
The moose likes XML and Related Technologies and the fly likes Loading a schema that refers to another one. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Loading a schema that refers to another one." Watch "Loading a schema that refers to another one." New topic
Author

Loading a schema that refers to another one.

Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
I have a schema that includes another one: <xsd:include schemaLocation="SchemaCommon.xsd" />

I am using a document builder to validate my XML like this:



When I run this, I get:

schema_reference.4: Failed to read schema document 'SchemaCommon.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
src-resolve: Cannot resolve the name 'RecordType' to a(n) 'type definition' component.
...


Is there a way to append the schema files together somehow?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1372
Try <xsd:import schemaLocation="SchemaCommon.xsd" />
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I'm guessing your problem is in line 5 of the code you posted. Does that res.getFile() method return a complete URL, or just the file part of the URL? I'm guessing (guessing again) that you need to pass a URL as the value of that attribute and not just a file path. That would definitely be true if the URL referred to a jar entry, but you didn't say anything about that.
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
BINGO to using import instead! That did the trick.

Thanks.
 
Consider Paul's rocket mass heater.
 
subject: Loading a schema that refers to another one.