Package org.geotools.xml

Examples of org.geotools.xml.Encoder$DOMAttributes


    public void testEncodeFeatureWithNoBounds() throws Exception {
        SimpleFeature feature = GML3MockData.feature();
        TestConfiguration configuration  = new TestConfiguration();
        configuration.getProperties().add( org.geotools.gml2.GMLConfiguration.NO_FEATURE_BOUNDS );
   
        Encoder encoder = new Encoder( configuration );
        Document dom = encoder.encodeAsDOM(feature, TEST.TestFeature );
       
        assertEquals( 0, dom.getElementsByTagName("gml:boundedBy").getLength());
    }
View Full Code Here


        assertEquals( 0, dom.getElementsByTagName("gml:boundedBy").getLength());
    }

    public void testEncodeWithNoSrsDimension() throws Exception {
        GMLConfiguration gml = new GMLConfiguration();
        Document dom = new Encoder(gml).encodeAsDOM(GML3MockData.point(), GML.Point);
        assertTrue(dom.getDocumentElement().hasAttribute("srsDimension"));

        gml.getProperties().add(GMLConfiguration.NO_SRS_DIMENSION);
        dom = new Encoder(gml).encodeAsDOM(GML3MockData.point(), GML.Point);
        assertFalse(dom.getDocumentElement().hasAttribute("srsDimension"));
    }
View Full Code Here

        assertFalse(dom.getDocumentElement().hasAttribute("srsDimension"));
    }

    public void testEncodeSrsSyntax() throws Exception {
        GMLConfiguration gml = new GMLConfiguration();
        Document dom = new Encoder(gml).encodeAsDOM(GML3MockData.point(), GML.Point);
        assertTrue(dom.getDocumentElement().getAttribute("srsName")
            .startsWith("urn:x-ogc:def:crs:EPSG:"));

        gml.setSrsSyntax(SrsSyntax.OGC_URN);
        dom = new Encoder(gml).encodeAsDOM(GML3MockData.point(), GML.Point);
        assertTrue(dom.getDocumentElement().getAttribute("srsName")
            .startsWith("urn:ogc:def:crs:EPSG::"));

        gml.setSrsSyntax(SrsSyntax.OGC_HTTP_URI);
        dom = new Encoder(gml).encodeAsDOM(GML3MockData.point(), GML.Point);
        assertTrue(dom.getDocumentElement().getAttribute("srsName")
            .startsWith("http://www.opengis.net/def/crs/EPSG/0/"));
    }
View Full Code Here

        builder.add(null);

        SimpleFeature feature = (SimpleFeature) builder.buildFeature("fid.1");
       
        TestConfiguration configuration  = new TestConfiguration();
        Encoder encoder = new Encoder( configuration );
        Document dom = encoder.encodeAsDOM(feature, TEST.TestFeature);
        NodeList countList = dom.getElementsByTagName("test:count");
        Node count = countList.item(0);
        assertEquals("true", count.getAttributes().getNamedItem("xs:nil").getTextContent());
        NodeList dateList = dom.getElementsByTagName("test:date");
        Node date = dateList.item(0);
        assertEquals("true", date.getAttributes().getNamedItem("xs:nil").getTextContent());

        // now force the XSD prefix
        encoder = new Encoder(configuration);
        encoder.getNamespaces().declarePrefix("xsd", "http://www.w3.org/2001/XMLSchema");
        dom = encoder.encodeAsDOM(feature, TEST.TestFeature);
        countList = dom.getElementsByTagName("test:count");
        count = countList.item(0);
        assertEquals("true", count.getAttributes().getNamedItem("xsd:nil").getTextContent());
        dateList = dom.getElementsByTagName("test:date");
        date = dateList.item(0);
View Full Code Here

        File file = File.createTempFile("filter", "xml");
        file.deleteOnExit();

        OutputStream output = new BufferedOutputStream(new FileOutputStream(file));
        Encoder encoder = new Encoder(new OGCConfiguration());

        encoder.encode(filter, OGC.PropertyIsEqualTo, output);
        output.flush();
        output.close();

        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        docFactory.setNamespaceAware(true);
View Full Code Here

        sb.add( "two" );
        sb.add( "the second feature");
        sb.add( gf.createPoint( new Coordinate(2, 2) ) ) ;
        features.add( sb.buildFeature("2"));
       
        Encoder encoder = new Encoder(new KMLConfiguration());
        encoder.setIndenting(true);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        encoder.encode(features, KML.kml, out );
        System.out.println( new String( out.toByteArray() ));
       
        DocumentBuilder db =
            DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document d = db.parse( new ByteArrayInputStream( out.toByteArray() ) );
View Full Code Here

       
        sb = new SimpleFeatureBuilder(DocumentTypeBinding.FeatureType);
        sb.set( "Feature", features );
        SimpleFeature f = sb.buildFeature("kml");
       
        Encoder encoder = new Encoder(new KMLConfiguration());
        encoder.setIndenting(true);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        encoder.encode(f, KML.kml, out );
       
        DocumentBuilder db =
            DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document d = db.parse( new ByteArrayInputStream( out.toByteArray() ) );
        assertEquals( "kml:kml", d.getDocumentElement().getNodeName() );
View Full Code Here

     *            the charset to use to encode the request in
     * @throws IOException
     */
    public static void encode(final EObject request, final Configuration configuration,
            final OutputStream out, final Charset charset) throws IOException {
        Encoder encoder = new Encoder(configuration);
        encoder.setEncoding(charset);       
    }
View Full Code Here

                         .registerComponentInstance("http://geotools.org/typeDefinition", type);
        }

        XSDSchema schema = configuration.getXSD().getSchema();

        Encoder encoder = new Encoder(configuration, schema);
       
        //additional namespaces
        for ( Iterator e = namespaceMappings.entrySet().iterator(); e.hasNext(); ) {
            Map.Entry mapping = (Map.Entry) e.next();
            String prefix = (String) mapping.getKey();
            String uri = (String) mapping.getValue();
           
            encoder.getNamespaces().declarePrefix( prefix, uri );
        }
       
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        encoder.write(object, element, output);

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);

        return dbf.newDocumentBuilder().parse(new ByteArrayInputStream(output.toByteArray()));
View Full Code Here

    public void performPostOutput(OutputStream outputStream) throws IOException
    {
        // Encode the request into GML2 with the schema provided in the
        // describeprocess
        Configuration config = new WPSConfiguration();
        Encoder encoder = new Encoder(config);
        encoder.setIndenting(true);

        // http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd
        ExecuteType request = createExecuteType();
        encoder.encode(request, WPS.Execute, outputStream);
        // System.out.println(outputStream.toString());
    }
View Full Code Here

TOP

Related Classes of org.geotools.xml.Encoder$DOMAttributes

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.