Package org.geotools.xml

Examples of org.geotools.xml.Parser


        super(type, type, mimeType,element);
    }

    @Override
    public Object decode(InputStream input) throws Exception {
        Parser p = new Parser( xml );
        return p.parse( input );
    }
View Full Code Here


            }
        };
    }
   
    List<Exception> validateSLD() {
        Parser parser = new Parser(new SLDConfiguration());
        try {
            parser.validate( new ByteArrayInputStream(editor.getInput().getBytes()) );
        } catch( Exception e ) {
            return Arrays.asList( e );
        }
       
        return parser.getValidationErrors();
    }
View Full Code Here

            strict = Boolean.FALSE;
        } else if(wfs.isCiteCompliant()) {
            strict = Boolean.TRUE;
        }

        Parser parser = new Parser(configuration);
        parser.setValidating(strict);

        // "inject" namespace mappings
        List<NamespaceInfo> namespaces = configuration.getCatalog().getNamespaces();
        for (NamespaceInfo namespace : namespaces ) {
            if (namespace.equals( configuration.getCatalog().getDefaultNamespace() ))
                continue;

            parser.getNamespaces().declarePrefix(namespace.getPrefix(), namespace.getURI());
        }

        // set the input source with the correct encoding
        InputSource source = new InputSource(reader);
        source.setEncoding(wfs.getGeoServer().getGlobal().getCharset());

        Object parsed = parser.parse(source);

        // valid request? this should definitley be a configuration option
        // TODO: HACK, disabling validation for transaction
        if (!"Transaction".equalsIgnoreCase(getElement().getLocalPart())) {
            if (!parser.getValidationErrors().isEmpty()) {
                WFSException exception = new WFSException("Invalid request",
                        "InvalidParameterValue");

                for (Iterator e = parser.getValidationErrors().iterator(); e.hasNext();) {
                    Exception error = (Exception) e.next();
                    exception.getExceptionText().add(error.getLocalizedMessage());
                }

                throw exception;
View Full Code Here

        }
       
        //TODO: make this configurable?
        configuration.getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS);

        Parser parser = new Parser(configuration);
        parser.setValidating(strict.booleanValue());
       
        //"inject" namespace mappings
        List<NamespaceInfo> namespaces = catalog.getNamespaces();
        for ( NamespaceInfo ns : namespaces ) {
            if ( ns.equals( catalog.getDefaultNamespace() ) ) 
                continue;
           
            parser.getNamespaces().declarePrefix(
                ns.getPrefix(), ns.getURI());
        }
      
        //set the input source with the correct encoding
        InputSource source = new InputSource(reader);
        source.setEncoding(wfs.getGeoServer().getGlobal().getCharset());

        Object parsed = parser.parse(source);

        //TODO: HACK, disabling validation for transaction
        if (!"Transaction".equalsIgnoreCase(getElement().getLocalPart())) {
            if (!parser.getValidationErrors().isEmpty()) {
                WFSException exception = new WFSException("Invalid request", "InvalidParameterValue");

                for (Iterator e = parser.getValidationErrors().iterator(); e.hasNext();) {
                    Exception error = (Exception) e.next();
                    exception.getExceptionText().add(error.getLocalizedMessage());
                }

                throw exception;
View Full Code Here

            strict = Boolean.FALSE;
        } else if(wfs.isCiteCompliant()) {
            strict = Boolean.TRUE;
        }

        Parser parser = new Parser(configuration);
        parser.setValidating(strict);

        // "inject" namespace mappings
        List<NamespaceInfo> namespaces = configuration.getCatalog().getNamespaces();
        for (NamespaceInfo ns : namespaces) {
            if (ns.equals( configuration.getCatalog().getDefaultNamespace()))
                continue;

            parser.getNamespaces().declarePrefix(ns.getPrefix(), ns.getURI());
        }

        // set the input source with the correct encoding
        InputSource source = new InputSource(reader);
        source.setEncoding(wfs.getGeoServer().getGlobal().getCharset());

        Object parsed = parser.parse(source);

        // valid request? this should definitley be a configuration option
        // TODO: HACK, disabling validation for transaction
        if (!"Transaction".equalsIgnoreCase(getElement().getLocalPart())) {
            if (!parser.getValidationErrors().isEmpty()) {
                WFSException exception = new WFSException("Invalid request",
                        "InvalidParameterValue");

                for (Iterator e = parser.getValidationErrors().iterator(); e.hasNext();) {
                    Exception error = (Exception) e.next();
                    exception.getExceptionText().add(error.getLocalizedMessage());
                }

                throw exception;
View Full Code Here

    protected abstract Configuration getParserConfiguration();

    public Object parse(String value) throws Exception {
        // create the parser
        final Configuration configuration = getParserConfiguration();
        final Parser parser = new Parser(configuration);

        // seperate the individual filter strings
        List unparsed = KvpUtils.readFlat(value, KvpUtils.OUTER_DELIMETER);
        List filters = new ArrayList();

        Iterator i = unparsed.listIterator();

        while (i.hasNext()) {
            String string = (String) i.next();
            if ("".equals(string.trim())) {
                filters.add(Filter.INCLUDE);
            } else {
                InputStream input = new ByteArrayInputStream(string.getBytes());

                try {
                    Filter filter = (Filter) parser.parse(input);

                    if (filter == null) {
                        throw new NullPointerException();
                    }
View Full Code Here

            new FeatureTypeSchemaBuilder.GML3(getGeoServer());
        return new WFSConfiguration(catalog,sb,new WFS(sb));
    }

    public void testValid() throws Exception {
        Parser parser = new Parser(configuration());
        parser.parse(getClass().getResourceAsStream("GetFeature.xml"));

        assertEquals(0, parser.getValidationErrors().size());
    }
View Full Code Here

        assertEquals(0, parser.getValidationErrors().size());
    }

    public void testInvalid() throws Exception {
        Parser parser = new Parser(configuration());
        parser.setValidating(true);
        parser.parse(getClass().getResourceAsStream("GetFeature-invalid.xml"));

        assertTrue(parser.getValidationErrors().size() > 0);
    }
View Full Code Here

            }
            else {
              _transaction = Transaction.AUTO_COMMIT;
            }
            _maxWritesInTransaction = maxWritesInTransaction;
            _gmlParser = new Parser(new GMLConfiguration());
            boolean rebuildIndex;

            rebuildIndex = createWriter(_datastore);
            if (rebuildIndex) {
                setupIndex(true);
View Full Code Here

         */
        public Filter filter(org.apache.lucene.search.Query query, int numHits, Element filterExpr, String filterVersion)
                throws Exception {
            _lock.lock();
            try {
              Parser filterParser = getFilterParser(filterVersion);
                Pair<FeatureSource<SimpleFeatureType, SimpleFeature>, SpatialIndex> accessor = new SpatialIndexAccessor();
                return OgcGenericFilters.create(query, numHits, filterExpr, accessor, filterParser);
            }
            catch (Exception e) {
              // TODO Handle NPE creating spatial filter (due to constraint language version).
View Full Code Here

TOP

Related Classes of org.geotools.xml.Parser

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.