public String resolveSchemaLocation( XSDSchema schema, String namespaceURI, String rawSchemaLocationURI) { for (int i = 0; i < resolvers.size(); i++) { XSDSchemaLocationResolver resolver = (XSDSchemaLocationResolver) resolvers.get(i); String resolved = resolver.resolveSchemaLocation(schema, namespaceURI, rawSchemaLocationURI); if (resolved != null) { return resolved; } } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine( "Could not resolve schema location: " + rawSchemaLocationURI + " to physical location."); } return null; } }
public XSDSchema locateSchema( XSDSchema xsdSchema, String namespaceURI, String rawSchemaLocationURI, String resolvedSchemaLocationURI) { for (int i = 0; i < locators.size(); i++) { XSDSchemaLocator locator = (XSDSchemaLocator) locators.get(i); XSDSchema schema = locator.locateSchema( xsdSchema, namespaceURI, rawSchemaLocationURI, resolvedSchemaLocationURI); if (schema != null) { return schema; } } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Could not locate schema for: " + rawSchemaLocationURI + "."); } return 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()); }
xsdMainResource.setURI(uri); 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) {
/** * 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; } } }
public static void main(String[] args) throws Exception { XSDSchema schema = XSDUtil.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); SchemaGenerator generator = new SchemaGenerator(schema); generator.setComplexTypes(false); generator.setFollowComplexTypes(false); generator.setSimpleTypes(true); generator.generate(); }
public ElementInstance element(String text, QName original, String name) { try { File temp = File.createTempFile("name", "xsd"); FileWriter file = new FileWriter(temp); BufferedWriter buff = new BufferedWriter(file); PrintWriter print = new PrintWriter(buff); print.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + " <xsd:schema xmlns:my=\"http://mails/refractions/net\"" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" + " targetNamespace=\"http://localhost//test\">" + " <xsd:element name=\"" + name + "\" type=\"xsd:" + original.getLocalPart() + "\"/>" + "</xsd:schema>"); URL url = temp.toURL(); XSDParser parser = new XSDParser(); parser.parse(url.toString()); XSDSchema schema = parser.getSchema(); Map map = schema.getSimpleTypeIdMap(); return (ElementInstance) map.get(name); } catch (Throwable t) { java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", t); return null; } }
@BeforeClass public static void oneTimeSetUp() { reader = EmfComplexFeatureReader.newInstance(); // need to register custom factory to load schema resources Resource.Factory.Registry.INSTANCE .getExtensionToFactoryMap() .put("xsd", new XSDResourceFactoryImpl()); }
int pType = XSDUtil.nodeType(particle.getElement());
/** * Returns the line at which the given node starts. * @param node the node to query. * @return the line at which the given node starts. */ public static int getStartLine(Node node) { int result = getLocationMap(node).getStartLine(); return result == LocationMap.UNSET ? 1 : result; }
/** * Sets the line at which the given node starts. * @param node the node to set. * @param value the line at which the given node starts. */ public static void setStartLine(Node node, int value) { getLocationMap(node).setStartLine(value); }
/** * Returns the line at which the given node ends. * @param node the node to query. * @return the line at which the given node ends. */ public static int getEndLine(Node node) { int result = getLocationMap(node).getEndLine(); return result == LocationMap.UNSET ? 1 : result; }
/** * Sets the line at which the given node ends. * @param node the node to set. * @param value the line at which the given node ends. */ public static void setEndLine(Node node, int value) { getLocationMap(node).setEndLine(value); }
return ((XSDResourceImpl) resolvedResource).getSchema(); } else {
resolver.resolveSchemaLocation(null, namespace, location); if (resolvedSchemaLocation != null) { return resolvedSchemaLocation;
protected final AttributeType xsAnyType() { XSDSchema schema = XSDUtil.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); for ( Iterator i = schema.getTypeDefinitions().iterator(); i.hasNext(); ) { XSDTypeDefinition t = (XSDTypeDefinition) i.next(); if ( XS.ANYTYPE.getLocalPart().equals( t.getName() ) ) { return findType(t); } } throw new IllegalStateException("XS schema not present"); }
XSDSchema schema = locator.locateSchema(null, namespaceURI, schemaLocation, null);
int pType = XSDUtil.nodeType(particle.getElement());
EmfXsdLoadTest.class.getResource(filename).toString()), true); XSDSchema schema = resource.getSchema(); Assert.assertNotNull(schema); SchemaIndex index = null;
XSDUtil.getSchemaForSchema(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001) .getSimpleTypeIdMap() .get("string");