On 17/11/09 18:58, Pitaev, Anna wrote:
> 2. Please, have a look at our schema Definition for the Geometry:
> <xs:element minOccurs="0" name="Geometry" 
> type="ournamespace:LineString_Curve_MultiCurve_CompositeCurvePropertyType"/>
[...]
> Could not find elmeent declaration for:{ourNamespace}Geometry

You cannot use minOccurs in a global element declaration. This invalid 
element declaration is probably ignored, hence the error.
http://www.w3.org/TR/xmlschema-0/#Globals

If you want an optional element, define a top-level feature type, and 
declare inside it an optional element in the xs:sequence using 
minOccurs="0".

> <xs:complexType name="LineString_Curve_MultiCurve_CompositeCurvePropertyType">
>                  <xs:sequence>
>                          <xs:choice>
>                                  <xs:element ref="gml:LineString"/>
>                                  <xs:element ref="gml:Curve"/>
>                                  <xs:element ref="gml:MultiCurve"/>
>                                  <xs:element ref="gml:CompositeCurve"/>
>                          </xs:choice>
>                  </xs:sequence>
> </xs:complexType>

Even if I remove the minOccurs, this does not work for me. Be aware that 
GeoTools Encoder support for user-defined complex types is limited, 
unless you are using app-schema (which has its own problems).

I am also not sure of the level of support for curves in JTS or 
GeoTools. Hopefully one of the other developers can help. Justin? Jody?

What are you trying to do? Is there a reason you do not use 
gml:GeometryPropertyType, which is well-supported? This will allow you 
to encode any GML geometry type. For example:

<xs:element name="Geometry" type="gml:GeometryPropertyType" />

[Note that, by convention, elements should be lower case, and the GML 
encoding rules specify Type/property/Type/property encoding. I recommend 
defining a top-level element that contains a property called "geometry".]

If I have:

SchemaTest.xml:

<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.example.org/example";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:gml="http://www.opengis.net/gml";
xmlns:ex="http://www.example.org/example"; elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:import namespace="http://www.opengis.net/gml";
schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"; />
<xs:element name="Geometry" type="gml:GeometryPropertyType" />
</xs:schema>

Then I can encode a LINESTRING:

String NAMESPACE = "http://www.example.org/example";;
String schemaFileName = "SchemaTest.xml"; // same directory as the code
String wkt = "LINESTRING (60 380, 60 20, 200 400, 280 20, 360 400, 420 
20, 500 400, 580 20, 620 400)";
Geometry geometry = (new WKTReader2()).read(wkt);
Configuration configuration = new ApplicationSchemaConfiguration(NAMESPACE,
         SchemaTest.class.getResource(schemaFileName).toExternalForm());
org.geotools.xml.Encoder encoder = new 
org.geotools.xml.Encoder(configuration);
encoder.encode(geometry, new QName(NAMESPACE, "Geometry"), System.out);

This works in GeoTools (trunk = 2.7-SNAPSHOT). I get:

<?xml version="1.0" encoding="UTF-8"?>
<ex:Geometry xmlns:ex="http://www.example.org/example";
xmlns:gml="http://www.opengis.net/gml";>
<gml:LineString>
<gml:posList>60.0 380.0 60.0 20.0 200.0 400.0 280.0 20.0 360.0 400.0
420.0 20.0 500.0 400.0 580.0 20.0 620.0 400.0</gml:posList>
</gml:LineString>
</ex:Geometry>

Kind regards,

-- 
Ben Caradoc-Davies <ben.caradoc-dav...@csiro.au>
Software Engineer, CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre
26 Dick Perry Ave, Kensington WA 6151, Australia

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to