Refine search
(XSDResourceImpl) resourceSet.createResource(URI.createURI(".xsd")); xsdMainResource.setURI(uri); Map<Object, Object> options = resourceSet.getLoadOptions(); Map<?, ?> response = getOrCreateResponseFrom(options); byte[] resourceData = readUriResource(uri, resourceSet, response); xsdMainResource.load(in, options); } finally { Long timeStamp = (Long) response.get(URIConverter.RESPONSE_TIME_STAMP_PROPERTY); if (timeStamp != null) { xsdMainResource.setTimeStamp(timeStamp); XSDSchema schema = xsdMainResource.getSchema(); if (schema != null) {
/** * Encode the provided SimpleFeatureType into an XSD file, using a target namespace * * <p>When encoding the simpleFeatureType: * * <ul> * <li>target prefix/namespace can be provided by prefix and namespace parameters. This is the * default for the entire XSD document. * <li>simpleFeatureType.geName().getNamespaceURI() is used for the simpleFeatureType itself, * providing simpleFeatureType.getUserData().get("prefix") is defined * </ul> * * @param simpleFeatureType To be encoded as an XSD document * @param prefix Prefix to use for for target namespace * @param namespace Target namespace */ public void encode(OutputStream out, SimpleFeatureType simpleFeatureType) throws IOException { XSDSchema xsd = xsd(simpleFeatureType); XSDResourceImpl.serialize(out, xsd.getElement(), encoding.name()); }
/** * Creates an {@link XSDResourceImpl}. * @param uri the URI of the new resource. * @return an XSDResourceImpl. */ @Override public Resource createResource(URI uri) { return new XSDResourceImpl(uri); } }
public static void serialize(OutputStream outputStream, Element element, String encoding) { try { doSerialize(outputStream, element, encoding); } catch (Exception exception) { exception.printStackTrace(); } }
(xsdSchema.getSchemaLocation() != null || ((XSDSchemaImpl)xsdSchema).getPendingSchemaLocation() != null)) Resource resource = xsdSchema.eResource(); if (resource != null) namespace = xsdSchema.getTargetNamespace(); Resource resolvedResource = resourceSet.getResource(uri, false); if (resolvedResource == null) InputStream inputStream = resourceSet.getURIConverter().createInputStream(uri); resolvedResource = resourceSet.createResource(URI.createURI("*.xsd")); resolvedResource.setURI(uri); resolvedResource.load(inputStream, resourceSet.getLoadOptions()); resolvedSchema = ((XSDResourceImpl)resolvedResource).getSchema();
resourceSet./*{@link ResourceSet#getURIConverter */getURIConverter/*}*/()./*{@link URIConverter#getURIMap */getURIMap/*}*/().put (URI.createURI("http://www.example.com/logical.xsd"), URI.createURI("file://c:/physical.xsd")); resourceSet.getResource(URI.createURI(xsdSchemaURI), true); for (/*{@link */Resource/*}*/ resource : resourceSet./*{@link ResourceSet#getResources */getResources/*}*/()) /*{@link */XSDSchema/*}*/ xsdSchema = xsdResource./*{@link XSDResourceImpl#getSchema */getSchema/*}*/(); for (/*{@link */XSDSchemaContent/*}*/ xsdSchemaContent : xsdSchema./*{@link XSDSchema#getContents */getContents/*}*/()) if (xsdSchemaDirective./*{@link XSDSchemaDirective#getResolvedSchema */getResolvedSchema/*}*/() == null) System.out.println("Unresolved schema in " + xsdResource./*{@link Resource#getURI */getURI/*}*/()); /*{@link #printComponent */printComponent/*}*/(System.out, xsdSchemaDirective);
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_LOCATION, Boolean.TRUE); resourceSet./*{@link ResourceSet#getResource */getResource/*}*/(URI.createURI(xsdSchemaURI), true); for (/*{@link */Resource/*}*/ resource : resourceSet./*{@link ResourceSet#getResources */getResources/*}*/()) /*{@link */XSDSchema/*}*/ xsdSchema = xsdResource./*{@link XSDResourceImpl#getSchema */getSchema/*}*/(); System.out.println("\n<" + "!-- *** " + xsdResource./*{@link Resource#getURI */getURI/*}*/() + " *** -->\n"); /*{@link #printComponent */printComponent/*}*/(System.out, xsdSchema); if (xsdSchema./*{@link XSDSchema#getAllDiagnostics */getAllDiagnostics/*}*/().isEmpty()) xsdSchema.validate(); for (/*{@link */XSDDiagnostic/*}*/ xsdDiagnostic : xsdSchema.getAllDiagnostics())
public static final XSDSchema parse(String location, List locators, List resolvers) throws IOException { //check for case of file url, make sure it is an absolute reference if (new File(location).exists()) { location = new File(location).getCanonicalFile().toURI().toString(); //location = new File(location).getCanonicalPath(); } URI uri = URI.createURI(location); final ResourceSet resourceSet = new ResourceSetImpl(); //add the specialized schema location resolvers if ((resolvers != null) && !resolvers.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocationResolverAdapterFactory(resolvers); resourceSet.getAdapterFactories().add(adapterFactory); } //add the specialized schema locators as adapters if ((locators != null) && !locators.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocatorAdapterFactory(locators); resourceSet.getAdapterFactories().add(adapterFactory); } XSDResourceImpl xsdMainResource = (XSDResourceImpl) resourceSet.createResource(URI.createURI( ".xsd")); xsdMainResource.setURI(uri); xsdMainResource.load(resourceSet.getLoadOptions()); return xsdMainResource.getSchema(); }
Resource resolvedResource = resourceSet.getResource(uri, false); if (resolvedResource == null) InputStream inputStream = resourceSet.getURIConverter().createInputStream(uri); resolvedResource = getResource(uri, resourceSet); resolvedResource.load(inputStream, resourceSet.getLoadOptions()); eSchema = ((XSDResourceImpl)resolvedResource).getSchema();
public static synchronized XSDSchema getSchemaInstance(String namespace) { if (XSDConstants.SCHEMA_INSTANCE_URI_2001.equals(namespace)) { if (xsdSchemaInstance2001 == null) { try { String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); getGlobalResourceSet().getLoadOptions().put("XSD_SCHEMA_INSTANCE", XSDConstants.SCHEMA_INSTANCE_URI_2001); Resource schemaInstance2001Resource = getGlobalResourceSet().getResource (URI.createURI(baseURL + "cache/www.w3.org/2001/XMLSchema-instance.xsd"), true); xsdSchemaInstance2001 = ((XSDResourceImpl)schemaInstance2001Resource).getSchema(); } catch (Exception exception) { exception.printStackTrace(); } finally { getGlobalResourceSet().getLoadOptions().remove("XSD_SCHEMA_INSTANCE"); } } return xsdSchemaInstance2001; } return null; }
if (componentNamespace != null && componentNamespace.equals(schema.getTargetNamespace())) if (schema.getSchemaForSchemaQNamePrefix() == null) String targetNS = schema.getTargetNamespace(); if (targetNS == null) targetNS = ""; Resource resource = concreteComponent.eResource().getResourceSet().createResource(URI.createURI(platformLocation)); if (resource instanceof XSDResourceImpl) resolvedSchema = resourceImpl.getSchema(); if (resolvedSchema != null)
XSDResourceImpl resource = (XSDResourceImpl) resourceSet.getResource( URI.createURI( EmfXsdLoadTest.class.getResource(filename).toString()), true); XSDSchema schema = resource.getSchema(); Assert.assertNotNull(schema); SchemaIndex index = null;
Resource currentResource = schema.eResource(); for (Resource resource : resourceSet.getResources()) XSDSchema otherSchema = xsdResource.getSchema(); for (XSDSchemaContent content : otherSchema.getContents())
ResourceSet resourceSet = xsdSchema.eResource().getResourceSet(); Resource resolvedResource = resourceSet.getResource( URI.createURI( resolvedSchemaLocationURI == null return ((XSDResourceImpl) resolvedResource).getSchema(); } else {
/** * Remove all references to this schema, and all schemas built in the same resource set It is * important to call this method for every dynamic schema created that is not needed anymore, * because references in the static schema's will otherwise keep it alive forever */ public void dispose() { if (schema != null) { ResourceSet rs = schema.eResource().getResourceSet(); for (Resource r : rs.getResources()) { if (r instanceof XSDResourceImpl) { Schemas.dispose(((XSDResourceImpl) r).getSchema()); } } schema = null; } } }
/*{@link */Resource/*}*/ resource = new /*{@link */XSDResourceImpl/*}*/(URI.createURI(schemaURI)); resource./*{@link Resource#getContents */getContents/*}*/().add(purchaseOrderSchema); resourceSet./*{@link ResourceSet#getResources() */getResources()/*}*/.add(resource); resource./*{@link Resource#save(java.util.Map) */save/*}*/(Collections.EMPTY_MAP);
resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory()); Resource resource = new XSDResourceImpl(); resource.setURI(uri); schema = XSDFactory.eINSTANCE.createXSDSchema(); resource.getContents().add(schema); resourceSet.getResources().add(resource); schema.setDocument(document); final Element element = document.getDocumentElement(); if (element != null)
protected void doSave(Writer writer, Map<?, ?> options) throws IOException { XSDSchema xsdSchema = getSchema(); if (xsdSchema != null) { Document document = xsdSchema.getDocument(); if (document == null) { xsdSchema.updateDocument(); document = xsdSchema.getDocument(); } if (xsdSchema.getElement() == null) { xsdSchema.updateElement(); } doSerialize(writer, document, options); } }
progressMonitor.subTask(getURI().toString()); getDefaultSaveOptions().put(XSD_ENCODING, xsdParser.getEncoding()); document = getDocument(inputSource, errorHandler, options); handleSchemaElement(document.getDocumentElement(), true); else if (!findSchemas(document.getDocumentElement())) handleSchemaElement(document.getDocumentElement(), false); handleSchemaElement(null, false); handleSchemaElement(null, false); ioException = exception; for (Iterator<?> i = getContents().iterator(); i.hasNext();) assignDiagnostics(xsdSchema, errors); getErrors().add(xsdDiagnostic); break; getWarnings().add(xsdDiagnostic); break; if (getContents().size() > 1)
final XSDResourceImpl rsrc = new XSDResourceImpl(URI.createFileURI(xsdFileWithPath)); rsrc.load(new HashMap()); final XSDSchema schema = rsrc.getSchema(); for (Object content : schema.getContents()) { if (content instanceof XSDImport) { XSDImport xsdImport = (XSDImport) content; xsdImport.resolveTypeDefinition(xsdImport.getNamespace(), ""); } }