[OSGeo-Discuss] XML to GML XSLT

Kralidis,Tom [Ontario] Tom.Kralidis at ec.gc.ca
Wed Jun 10 14:30:12 EDT 2009


 

> -----Original Message-----
> From: discuss-bounces at lists.osgeo.org 
> [mailto:discuss-bounces at lists.osgeo.org] On Behalf Of "René 
> A. Enguehard"
> Sent: Wednesday, 10 June 2009 13:59
> To: discuss at lists.osgeo.org
> Subject: [OSGeo-Discuss] XML to GML XSLT
> 
> Hi all,
> 
> I've been working on getting an XML document to transform 
> into a GML document. Currently I'm running into two issues:
> 
> 1. How do we define the XSD rules for a string node with an 
> attribute? 
> ie: <point dimension="2">12.12, 34.34</point>
>     Currently all I have found relates to simple text nodes 
> or simple attribute nodes, but not mixed ones.
> 

You could declare something like:

<xs:element name="foo" type="fooType">

<xs:complexType name="fooType">
 <xs:simpleContent>
  <xs:extension base="xs:string">
   <xs:attribute name="age"/>
  </xs:extension>
 </xs:simpleContent>
</xs:complexType>

..which would look like this when instantiated:

<foo age="123">bar</foo>


> 2. How do we get XSD to "play nice" with the gml: prefix? I 
> want to use gml:Point and gml:pos but the XSD file doesn't validate.
> 
> Some sample XML:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <user xmlns:gml="http://www.opengis.net/gml">
>    <name>test</name>
>     <gml:Point>
>         <gml:pos dimension="2">-97.7452090, 30.2687350</gml:pos>
>     </gml:Point>
> </user>
> 
> The XSD file for the code (so far):
> 
> <?xml version="1.0" encoding="utf-8"?>
> <xsd:schema
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>     xmlns:gml="http://www.opengis.net/gml">
>     <xsd:import namespace="http://www.opengis.net/gml"/>
>     <xsd:element name="user" type="userType" />
> 
>     <xsd:complexType name="userType">
>         <xsd:sequence>
>             <xsd:element name="name" type="xsd:string" />
>             <xsd:element name="gml:Point" type="gml:Point" /> 
>    <---- ???
>         </xsd:sequence>
>     </xsd:complexType>
> 

What version of GML are you designing against?

Have you considered doing your .xsd as a GML application schema, where you would extend as follows: 

<xs:element name="Meeting" substitutionGroup="gml:_Feature">
 <xs:complexType>
  <xs:complexContent>
   <xs:extension base="gml:AbstractFeatureType">
    <xs:sequence>
     <xs:element name="year" type="xs:integer"/>
     <xs:element name="venue" type="xs:string"/>
     <xs:element name="website" type="xs:anyURI"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
</xs:element>

By extending gml:AbstractFeatureType, you inherit gml:location (among other things), from which you can express various geometry types.  So the above would then instantiate as:

<Meeting>
 <gml:description>This was where the first meeting was held</gml:description>
 <gml:name>St. Paul</gml:name>
 <gml:location>
  <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
   <gml:coord>
    <gml:pos-93.093055556 44.944444444</gml:pos>
   </gml:coord>
  </gml:Point>
 </gml:location>
 <year>2003</year>
 <venue>University of Minnesota, St. Paul Campus</venue>
 <website>http://www.mapserver.org</website>
</Meeting>

You might want to consult the OGC Public Forum (http://feature.opengeospatial.org/forumbb/) as well.

..Tom



More information about the Discuss mailing list