Package org.geotools.xml

Examples of org.geotools.xml.SchemaIndex


     *
     * @throws Exception
     */
    @Test
    public void testParseSchema() throws Exception {
        SchemaIndex schemaIndex = loadSchema("http://schemas.opengis.net/GeoSciML/Gsml.xsd");

        AppSchemaFeatureTypeRegistry typeRegistry = new AppSchemaFeatureTypeRegistry();
        try {
            typeRegistry.addSchemas(schemaIndex);
   
View Full Code Here


        /*
         * not found types and elements:
         */

        // load geosciml schema
        SchemaIndex schemaIndex;
        try {
            schemaIndex = loadSchema(schemaBase + "commonSchemas/XMML/1/borehole.xsd");
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
View Full Code Here

    public Handler createChildHandler(QName qName) {
        return getChildHandlerInternal(qName);
    }

    private Handler getChildHandlerInternal(QName qName) {
        SchemaIndex index = parser.getSchemaIndex();

        XSDElementDeclaration element = index.getChildElement(content, qName);

        if (element != null) {
            //TODO: determine wether the element is complex or simple, and create
            ElementHandler handler = parser.getHandlerFactory()
                                           .createElementHandler(element, this, parser);

            return handler;
        }

        //could not find the element as a direct child of the parent, check
        // for a global element, and then check its substituation group
        element = index.getElementDeclaration(qName);

        if (element != null) {
            XSDElementDeclaration sub = element.getSubstitutionGroupAffiliation();

            if (sub != null) {
View Full Code Here

        ResourceSet resourceSet = XSDSchemaImpl.createResourceSet();
        XSDResourceImpl resource = (XSDResourceImpl) resourceSet.getResource(
                URI.createURI(EmfXsdLoadTest.class.getResource(filename).toString()), true);
        XSDSchema schema = resource.getSchema();
        Assert.assertNotNull(schema);
        SchemaIndex index = null;
        XSDTypeDefinition type = null;
        try {
            index = new SchemaIndexImpl(new XSDSchema[] { schema });
            type = index.getTypeDefinition(new QName(namespace, name));
        } finally {
            if (index != null) {
                index.destroy();
            }
        }
        Assert.assertNotNull(type);
        System.err.println("Child element declaration types for " + name + " :");
        List<XSDElementDeclaration> children = Schemas.getChildElementDeclarations(type);
View Full Code Here

     *            XML configuration for the schema
     * @param name
     *            complex type to be tested
     */
    private static void checkChildElementTypes(Configuration configuration, QName name) {
        SchemaIndex index = null;
        XSDTypeDefinition type = null;
        try {
            index = Schemas.findSchemas(configuration);
            type = index.getTypeDefinition(name);
        } finally {
            if (index != null) {
                index.destroy();
            }
        }
        Assert.assertNotNull(type);
        System.err.println("Child element declaration types for " + name + " :");
        @SuppressWarnings("unchecked")
View Full Code Here

    public ElementHandler createElementHandler(QName qName, Handler parent, ParserHandler parser) {
        String name = qName.getLocalPart();
        if (schemaRegistry.get(name) != null) {
            // we found a custom schema element
            // let's treat it as if we've found a placemark
            SchemaIndex schemaIndex = parser.getSchemaIndex();
            XSDElementDeclaration element = schemaIndex.getElementDeclaration(KML.Placemark);
            if (element != null) {
                return createElementHandler(element, parent, parser);
            }
        }
        return super.createElementHandler(qName, parent, parser);
View Full Code Here

        {
            String namespaceURI = featureTypeName.getNamespaceURI();
            String uri = schemaLocation.toExternalForm();
            configuration = new ApplicationSchemaConfiguration(namespaceURI, uri);
        }
        SchemaIndex schemaIndex;
        try {
            schemaIndex = Schemas.findSchemas(configuration);
        } catch (RuntimeException e) {
            throw new DataSourceException("Error parsing feature type for " + featureTypeName, e);
        }

        XSDElementDeclaration elementDeclaration;
        elementDeclaration = schemaIndex.getElementDeclaration(featureTypeName);
        schemaIndex.destroy();
        if (elementDeclaration == null) {
            throw new DataSourceException("No XSDElementDeclaration found for " + featureTypeName);
        }
        return elementDeclaration;
    }
View Full Code Here

                featureTypeName = new QName(namespaceURI, featureTypeName.getLocalPart());
            }
            String uri = schemaLocation.toExternalForm();
            configuration = new ApplicationSchemaConfiguration(namespaceURI, uri);
        }
        SchemaIndex schemaIndex;
        try {
            schemaIndex = Schemas.findSchemas(configuration);
        } catch (RuntimeException e) {
            throw new DataSourceException("Error parsing feature type for " + featureTypeName, e);
        }

        XSDElementDeclaration elementDeclaration;
        elementDeclaration = schemaIndex.getElementDeclaration(featureTypeName);
        schemaIndex.destroy();
        if (elementDeclaration == null && !ignoreMissingElementDeclaration) {
            throw new DataSourceException("No XSDElementDeclaration found for " + featureTypeName);
        }
        return elementDeclaration;
    }
View Full Code Here

    }

    private static XSDElementDeclaration parseFeatureType(final QName featureTypeName,
            Configuration configuration) throws DataSourceException {

        SchemaIndex schemaIndex;
        try {
            schemaIndex = Schemas.findSchemas(configuration);
        } catch (RuntimeException e) {
            throw new DataSourceException("Error parsing feature type for " + featureTypeName, e);
        }

        XSDElementDeclaration elementDeclaration;
        elementDeclaration = schemaIndex.getElementDeclaration(featureTypeName);
        schemaIndex.destroy();
        return elementDeclaration;
    }
View Full Code Here

     * @param configuration configuration object used to access the XSDSchema to parse. This configuration object might contain {@link Binding}s
     * @throws IOException
     */
    public SchemaIndex parse(Configuration configuration) throws IOException {
        // find out the schemas involved in the app schema configuration
        final SchemaIndex appSchemaIndex = Schemas.findSchemas(configuration);

        return appSchemaIndex;
    }
View Full Code Here

TOP

Related Classes of org.geotools.xml.SchemaIndex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.