Hi there,
here I am again :)
This time I used an example taken straight from the user documentation
but still no success.
Here it is :


main
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.geotools.gml3.GMLConfiguration;
import org.geotools.xml.Parser;

public class MainXML {
        public static void main(String[] args) {
                try {
                        InputStream in = new FileInputStream(new
File("C:\\Broker\\Workspace\\GeoToolsTest\\src\\xsdtest\\test.xml"));
                        Parser parser = new Parser(new GMLConfiguration());
                        Object parsedObject = parser.parse(in);
                        System.out.println(parsedObject.getClass().getName());
                        System.out.println(parsedObject);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------


test.xsd
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.geotools.org/test";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:test="http://www.geotools.org/test";
xmlns:gml="http://www.opengis.net/gml"; elementFormDefault="qualified">

        <xsd:import namespace="http://www.opengis.net/gml";
schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"; />

        <xsd:complexType name="TestFeatureType">
                <xsd:complexContent>
                        <xsd:extension base="gml:AbstractFeatureType">
                                <xsd:sequence>
                                        <xsd:element name="geom" 
type="gml:PointPropertyType" />
                                        <xsd:element name="count" 
type="xsd:int" />
                                        <xsd:element name="date" 
type="xsd:date" />
                                </xsd:sequence>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <xsd:element name="TestFeature" type="test:TestFeatureType"
substitutionGroup="gml:_Feature" />

        <xsd:complexType name="TestFeatureCollectionType">
                <xsd:complexContent>
                        <xsd:extension base="gml:AbstractFeatureCollectionType" 
/>
                </xsd:complexContent>
        </xsd:complexType>
        <xsd:element name="TestFeatureCollection"
type="test:TestFeatureCollectionType" />

</xsd:schema>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

test.xml
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
<test:TestFeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:gml="http://www.opengis.net/gml";
xmlns:test="http://www.geotools.org/test";
xsi:schemaLocation="http://www.geotools.org/test test.xsd">

 <gml:featureMember>
  <test:TestFeature gml:id="fid.0">
   <test:geom>
    <gml:Point>
     <gml:coord>
      <gml:X>0</gml:X>
      <gml:Y>0</gml:Y>
     </gml:coord>
    </gml:Point>
   </test:geom>
   <test:count>0</test:count>
   <test:date>2001-01-01</test:date>
  </test:TestFeature>
 </gml:featureMember>

 <gml:featureMember>
  <test:TestFeature gml:id="fid.1">
   <test:geom>
    <gml:Point>
     <gml:coord>
      <gml:X>1</gml:X>
      <gml:Y>1</gml:Y>
     </gml:coord>
    </gml:Point>
   </test:geom>
   <test:count>1</test:count>
   <test:date>2002-02-02</test:date>
  </test:TestFeature>
 </gml:featureMember>

 <gml:featureMember>
  <test:TestFeature gml:id="fid.2">
   <test:geom>
    <gml:Point>
     <gml:coord>
      <gml:X>2</gml:X>
      <gml:Y>2</gml:Y>
     </gml:coord>
    </gml:Point>
   </test:geom>
   <test:count>2</test:count>
   <test:date>2003-03-03</test:date>
  </test:TestFeature>

 </gml:featureMember>

</test:TestFeatureCollection>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------


output
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
java.util.HashMap
{featureMember=[SimpleFeatureImpl:TestFeature=[SimpleFeatureImpl.Attribute:
description<description id=fid.0>=null, SimpleFeatureImpl.Attribute:
name<name id=fid.0>=null, SimpleFeatureImpl.Attribute:
boundedBy<boundedBy id=fid.0>=null, SimpleFeatureImpl.Attribute:
geom<geom id=fid.0>=POINT (0 0), SimpleFeatureImpl.Attribute:
count<count id=fid.0>=0, SimpleFeatureImpl.Attribute: date<date
id=fid.0>=2001-01-01],
SimpleFeatureImpl:TestFeature=[SimpleFeatureImpl.Attribute:
description<description id=fid.1>=null, SimpleFeatureImpl.Attribute:
name<name id=fid.1>=null, SimpleFeatureImpl.Attribute:
boundedBy<boundedBy id=fid.1>=null, SimpleFeatureImpl.Attribute:
geom<geom id=fid.1>=POINT (1 1), SimpleFeatureImpl.Attribute:
count<count id=fid.1>=1, SimpleFeatureImpl.Attribute: date<date
id=fid.1>=2002-02-02],
SimpleFeatureImpl:TestFeature=[SimpleFeatureImpl.Attribute:
description<description id=fid.2>=null, SimpleFeatureImpl.Attribute:
name<name id=fid.2>=null, SimpleFeatureImpl.Attribute:
boundedBy<boundedBy id=fid.2>=null, SimpleFeatureImpl.Attribute:
geom<geom id=fid.2>=POINT (2 2), SimpleFeatureImpl.Attribute:
count<count id=fid.2>=2, SimpleFeatureImpl.Attribute: date<date
id=fid.2>=2003-03-03]]}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to