diff options
author | pfullbright | 2011-02-08 23:12:25 +0000 |
---|---|---|
committer | pfullbright | 2011-02-08 23:12:25 +0000 |
commit | e0f30ce76b361218e802413484f66435bbdd5ba0 (patch) | |
tree | c708d1b8dd7175427517f0002f7333e317f391fe | |
parent | 5aca11b85e9bd7b46f7ea3be7dd99fb47b075148 (diff) | |
download | webtools.dali-e0f30ce76b361218e802413484f66435bbdd5ba0.tar.gz webtools.dali-e0f30ce76b361218e802413484f66435bbdd5ba0.tar.xz webtools.dali-e0f30ce76b361218e802413484f66435bbdd5ba0.zip |
handle imports in a schema
2 files changed, 23 insertions, 3 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java index 2c760a64c0..cc9f954415 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * Copyright (c) 2010, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -20,7 +20,6 @@ import org.eclipse.jpt.jaxb.core.JaxbProject; import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; import org.eclipse.jpt.jaxb.core.SchemaLibrary; import org.eclipse.jpt.jaxb.core.xsd.XsdUtil; -import org.eclipse.wst.xsd.contentmodel.internal.XSDImpl; import org.eclipse.xsd.XSDSchema; import org.eclipse.xsd.util.XSDResourceImpl; @@ -70,7 +69,7 @@ public class SchemaLibraryImpl } protected XSDSchema addSchema(String namespace, String resolvedUri) { - XSDSchema schema = XSDImpl.buildXSDModel(resolvedUri); + XSDSchema schema = XsdUtil.buildXSDModel(resolvedUri); XSDResourceImpl schemaResource = (XSDResourceImpl) schema.eResource(); if (schemaResource != null) { schemaResource.eAdapters().add(this.schemaResourceAdapter); diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java index daeae1ef2a..c4882c9b48 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java @@ -30,7 +30,9 @@ import org.eclipse.wst.xsd.contentmodel.internal.util.XSDSchemaLocatorAdapterFac import org.eclipse.xsd.XSDComplexTypeDefinition; import org.eclipse.xsd.XSDElementDeclaration; import org.eclipse.xsd.XSDSchema; +import org.eclipse.xsd.XSDSchemaContent; import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.impl.XSDImportImpl; import org.eclipse.xsd.impl.XSDSchemaImpl; import org.eclipse.xsd.util.XSDConstants; import org.eclipse.xsd.util.XSDResourceImpl; @@ -115,6 +117,7 @@ public class XsdUtil { resource.load(inputStream, null); xsdSchema = resource.getSchema(); } + handleImports(xsdSchema); } catch (Exception e) { JptJaxbCorePlugin.log(e); @@ -122,6 +125,24 @@ public class XsdUtil { return xsdSchema; } + private static void handleImports(XSDSchema xsdSchema) { + if (xsdSchema != null) { + for (XSDSchemaContent content : xsdSchema.getContents()) { + if (content instanceof XSDImportImpl) { + XSDImportImpl anImport = (XSDImportImpl) content; + try { + if (anImport.getSchemaLocation() != null) { + anImport.importSchema(); + } + } + catch (Exception e) { + JptJaxbCorePlugin.log(e); + } + } + } + } + } + public static Object getAdapter(Notifier notifier) { return adapterFactory.adapt(notifier); } |