Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » XSDInclude and XSDImport
XSDInclude and XSDImport [message #7114] Tue, 17 December 2002 10:22 Go to next message
Eclipse UserFriend
Originally posted by: carsten.karkola.mailbox.tu-dresden.de

Hello,

I tried the sample code from XSDSchemaQueryTools.java, the code to call
mapImpInclRedef() is:

for (Iterator resources = resourceSet.getResources().iterator();
resources.hasNext(); ) {
// Check for schema resources.
Resource resource = (Resource)resources.next();
if (resource instanceof XSDResourceImpl) {
XSDResourceImpl xsdResource = (XSDResourceImpl)resource;

// Get the schema's element and serialized it to System.out.
xsdSchema = xsdResource.getSchema();
xsdSchema.setSchemaLocation(xsdResource.getURI().toString()) ;
System.out.println("\n<!-- *** " + xsdResource.getURI() + " *** -->\n");
}
}

// Recurse to map all imports/includes/redefines
// method copied from XSDSchemaQueryTools.java
mapImpInclRedef(xsdSchema, hash, 0);

Has the URI to be an absolute URI? If I check the HashMap, I only get

<!-- *** .schema-teachmldoc.xml\teachml.xsd *** -->
XSDInclude-level0-unresolved: null
XSDInclude-level0-unresolved: null
XSDImport-level0-unresolved: null
XSDImport-level0-unresolved: null
XSDInclude-level0-unresolved: null
XSDInclude-level0-unresolved: null

But I'm interested in the imported and included schema file location, to
move these files with my document, what is wrong?

Thank you,
Carsten
Re: XSDInclude and XSDImport [message #7139 is a reply to message #7114] Tue, 17 December 2002 10:43 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Carsten,

In order for relative locations to resolve, the location of the schema
document must be an absolute URI. URIs don't use "\", they only use "/". So
if you have a file path, the following will give you a good absolute URI:

URI uri = URI.createFileURI(new
java.io.File(filePath).getAbsoluteFile().getCanonicalPath()) ;


carsten wrote:

> Hello,
>
> I tried the sample code from XSDSchemaQueryTools.java, the code to call
> mapImpInclRedef() is:
>
> for (Iterator resources = resourceSet.getResources().iterator();
> resources.hasNext(); ) {
> // Check for schema resources.
> Resource resource = (Resource)resources.next();
> if (resource instanceof XSDResourceImpl) {
> XSDResourceImpl xsdResource = (XSDResourceImpl)resource;
>
> // Get the schema's element and serialized it to System.out.
> xsdSchema = xsdResource.getSchema();
> xsdSchema.setSchemaLocation(xsdResource.getURI().toString()) ;
> System.out.println("\n<!-- *** " + xsdResource.getURI() + " *** -->\n");
> }
> }
>
> // Recurse to map all imports/includes/redefines
> // method copied from XSDSchemaQueryTools.java
> mapImpInclRedef(xsdSchema, hash, 0);
>
> Has the URI to be an absolute URI? If I check the HashMap, I only get
>
> <!-- *** .schema-teachmldoc.xml\teachml.xsd *** -->
> XSDInclude-level0-unresolved: null
> XSDInclude-level0-unresolved: null
> XSDImport-level0-unresolved: null
> XSDImport-level0-unresolved: null
> XSDInclude-level0-unresolved: null
> XSDInclude-level0-unresolved: null
>
> But I'm interested in the imported and included schema file location, to
> move these files with my document, what is wrong?
>
> Thank you,
> Carsten

--
Ed Merks
Re: XSDInclude and XSDImport [message #564240 is a reply to message #7114] Tue, 17 December 2002 10:43 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Carsten,

In order for relative locations to resolve, the location of the schema
document must be an absolute URI. URIs don't use "\", they only use "/". So
if you have a file path, the following will give you a good absolute URI:

URI uri = URI.createFileURI(new
java.io.File(filePath).getAbsoluteFile().getCanonicalPath()) ;


carsten wrote:

> Hello,
>
> I tried the sample code from XSDSchemaQueryTools.java, the code to call
> mapImpInclRedef() is:
>
> for (Iterator resources = resourceSet.getResources().iterator();
> resources.hasNext(); ) {
> // Check for schema resources.
> Resource resource = (Resource)resources.next();
> if (resource instanceof XSDResourceImpl) {
> XSDResourceImpl xsdResource = (XSDResourceImpl)resource;
>
> // Get the schema's element and serialized it to System.out.
> xsdSchema = xsdResource.getSchema();
> xsdSchema.setSchemaLocation(xsdResource.getURI().toString()) ;
> System.out.println("\n<!-- *** " + xsdResource.getURI() + " *** -->\n");
> }
> }
>
> // Recurse to map all imports/includes/redefines
> // method copied from XSDSchemaQueryTools.java
> mapImpInclRedef(xsdSchema, hash, 0);
>
> Has the URI to be an absolute URI? If I check the HashMap, I only get
>
> <!-- *** .schema-teachmldoc.xml\teachml.xsd *** -->
> XSDInclude-level0-unresolved: null
> XSDInclude-level0-unresolved: null
> XSDImport-level0-unresolved: null
> XSDImport-level0-unresolved: null
> XSDInclude-level0-unresolved: null
> XSDInclude-level0-unresolved: null
>
> But I'm interested in the imported and included schema file location, to
> move these files with my document, what is wrong?
>
> Thank you,
> Carsten

--
Ed Merks


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:XSDInclude and XSDImport
Next Topic:Problem Including schemas
Goto Forum:
  


Current Time: Thu Apr 25 07:22:21 GMT 2024

Powered by FUDForum. Page generated in 0.03108 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top