/** * Register schema * * @param schema schema to be registered */ public synchronized void register(XSDSchema schema) { schemaRegistry.put(schema.getSchemaLocation(), schema); }
public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI) { try { URI contextUri = new URI(xsdSchema.getSchemaLocation()); if (contextUri.isOpaque()) { // probably a jar:file: URL, which is opaque and thus not // supported by URI.resolve() URL contextUrl = new URL(xsdSchema.getSchemaLocation()); return (new URL(contextUrl, schemaLocationURI)).toString(); } else { return contextUri.resolve(schemaLocationURI).toString(); } } catch (URISyntaxException e) { throw new RuntimeException(e); } catch (MalformedURLException e) { throw new RuntimeException(e); } } }));
/** * Resolve imports and includes to local resources. * * @param schema the parent schema from which the import/include originates * @param uri the namespace of an import (ignored in this implementation) * @param location the URL of the import or include (may be relative) * @see SchemaLocationResolver#resolveSchemaLocation(org.eclipse.xsd.XSDSchema, * java.lang.String, java.lang.String) */ @Override public String resolveSchemaLocation( final XSDSchema schema, final String uri, final String location) { return resolver.resolve(location, schema.getSchemaLocation()); }
public String resolveSchemaLocation( XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI) { try { URI contextUri = new URI(xsdSchema.getSchemaLocation()); if (contextUri.isOpaque()) { // probably a jar:file: URL, which is opaque and // thus not // supported by URI.resolve() URL contextUrl = new URL(xsdSchema.getSchemaLocation()); return (new URL(contextUrl, schemaLocationURI)) .toString(); } else { return contextUri .resolve(schemaLocationURI) .toString(); } } catch (URISyntaxException e) { throw new RuntimeException(e); } catch (MalformedURLException e) { throw new RuntimeException(e); } } }));
schemaLocation = getSchemaLocation(); } else { schemaLocation = schema.getSchemaLocation();
schemaLocation = getSchemaLocation(); } else { schemaLocation = schema.getSchemaLocation();
file = findSchemaFile( schema.getSchemaLocation() ); logger.log( Level.SEVERE, "Could not find: " + schema.getSchemaLocation() + " to copy." );
file = findSchemaFile( schema.getSchemaLocation() ); logger.log( Level.SEVERE, "Could not find: " + schema.getSchemaLocation() + " to copy." );
public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI) { try { URI contextUri = new URI(xsdSchema.getSchemaLocation()); if (contextUri.isOpaque()) { // probably a jar:file: URL, which is opaque and thus not // supported by URI.resolve() URL contextUrl = new URL(xsdSchema.getSchemaLocation()); return (new URL(contextUrl, schemaLocationURI)).toString(); } else { return contextUri.resolve(schemaLocationURI).toString(); } } catch (URISyntaxException e) { throw new RuntimeException(e); } catch (MalformedURLException e) { throw new RuntimeException(e); } } }));
protected HashMap createFileMap(List visitedSchemas) { HashMap fileMap = new HashMap(); for (Iterator i = visitedSchemas.iterator(); i.hasNext(); ) { XSDSchema theSchema = (XSDSchema)i.next(); String location = theSchema.getSchemaLocation(); IFile file = computeFile(location); if (file != null) { fileMap.put(file, Boolean.TRUE); } } return fileMap; }
@Override public String getText(Object object) { XSDSchema xsdSchema = (XSDSchema)object; String result = xsdSchema.getSchemaLocation(); if (result == null) { return ""; } else { return URI.createURI(result).lastSegment(); } }
public String resolveSchemaLocation(XSDSchema schema, String uri, String location) { String schemaLocation; if (schema == null) { schemaLocation = getSchemaLocation(); } else { schemaLocation = schema.getSchemaLocation(); } String locationUri = null; if ((null != schemaLocation) && !("".equals(schemaLocation))) { String schemaLocationFolder = schemaLocation; int lastSlash = schemaLocation.lastIndexOf('/'); if (lastSlash > 0) { schemaLocationFolder = schemaLocation.substring(0, lastSlash); } if (schemaLocationFolder.startsWith("file:")) { schemaLocationFolder = schemaLocationFolder.substring(5); } File locationFile = new File(schemaLocationFolder, location); if (locationFile.exists()) { locationUri = locationFile.toURI().toString(); } } if ((locationUri == null) && (location != null) && location.startsWith("http:")) { locationUri = location; } return locationUri; } };
public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI) { String baseLocation = xsdSchema.getSchemaLocation(); String result = URIResolverPlugin.createResolver().resolve(baseLocation, namespaceURI, schemaLocationURI); if (result == null) { result = namespaceURI; } if (result == null) { result = ""; } return result; }
public IFile getFile(Object component) { IFile result = null; if (component instanceof ComponentSpecification) { result = ((ComponentSpecification)component).getFile(); } else if (component instanceof SearchMatch) { result = ((SearchMatch)component).getFile(); } else if (component instanceof XSDConcreteComponent) { XSDConcreteComponent concreteComponent = (XSDConcreteComponent)component; XSDSchema schema = concreteComponent.getSchema(); if (schema != null) { // TODO (cs) revisit and test more // String location = schema.getSchemaLocation(); String platformResource = "platform:/resource"; if (location != null && location.startsWith(platformResource)) { Path path = new Path(location.substring(platformResource.length())); result = ResourcesPlugin.getWorkspace().getRoot().getFile(path); } } } return result; }
private void addDeclarationUpdate(TextChangeManager manager) { String fileStr = getModel().getSchemaLocation(); URI uri = URI.createPlatformResourceURI(fileStr); try { URL url = new URL(uri.toString()); url = Platform.resolve(url); if(url != null){ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile file = root.getFileForLocation(new Path(url.getFile())); if(file != null ){ TextChange change = manager.get(file); addDeclarationUpdate(change); } } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public String getLocationURI() { if (getLocationURIGen() == null) { XSDConcreteComponent thePrimaryComponent = getPrimaryComponent(); if (thePrimaryComponent != null) { XSDSchema xsdSchema = thePrimaryComponent.getSchema(); if (xsdSchema != null) { return xsdSchema.getSchemaLocation(); } } } return getLocationURIGen(); }
public String getLocationURI() { if (getLocationURIGen() == null) { XSDConcreteComponent thePrimaryComponent = getPrimaryComponent(); if (thePrimaryComponent != null) { XSDSchema xsdSchema = thePrimaryComponent.getSchema(); if (xsdSchema != null) { return xsdSchema.getSchemaLocation(); } } } return getLocationURIGen(); }
public AttributeDescriptor getDescriptor(final Name descriptorName, XSDComplexTypeDefinition typeDef, XSDElementDeclaration elemDecl, CoordinateReferenceSystem crs) { AttributeDescriptor descriptor = descriptorRegistry.get(descriptorName); if (descriptor == null) { try { if (elemDecl == null) { elemDecl = getElementDeclaration(descriptorName); } } catch (NoSuchElementException e) { String msg = "Type not found for " + descriptorName + " at type container " + (typeDef == null ? null : typeDef.getTargetNamespace() + "#" + typeDef.getName() + " at " + typeDef.getSchema().getSchemaLocation()); NoSuchElementException nse = new NoSuchElementException(msg); nse.initCause(e); throw nse; } descriptor = createAttributeDescriptor(typeDef, elemDecl, crs); LOGGER.finest("Registering attribute descriptor " + descriptor.getName()); register(descriptor); } return descriptor; }
public static void openXSDEditor(XSDConcreteComponent xsdComponent) { XSDSchema schema = xsdComponent.getSchema(); if (schema != null) { String schemaLocation = URIHelper.removePlatformResourceProtocol(schema.getSchemaLocation()); IPath schemaPath = new Path(schemaLocation); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath); if (file != null && file.exists()) { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (workbenchWindow != null) { IWorkbenchPage page = workbenchWindow.getActivePage(); try { IEditorPart editorPart = IDE.openEditor(page, file, true); if (editorPart instanceof InternalXSDMultiPageEditor) { InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart; xsdEditor.openOnGlobalReference(xsdComponent); } } catch (PartInitException pie) { } } } } }
return XSDConstants.resolveSchemaLocation(xsdSchema.getSchemaLocation(), namespace, schemaLocation);