[OSGeo-Discuss] XML to GML XSLT

Kralidis,Tom [Ontario] Tom.Kralidis at ec.gc.ca
Wed Jun 10 13:23:19 PDT 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 15:29
> To: OSGeo Discussions
> Subject: Re: [OSGeo-Discuss] XML to GML XSLT
> 
> Kralidis,Tom [Ontario] wrote:
> >  
> >
> >   
> >> -----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>
> >
> >
> >   
> This worked perfectly. Thanks.
> 
> >> 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?
> >
> >   
> I'm designing with GML 3.x in mind, but it doesn't make much 
> difference since all I'm really using is gml:Point and 
> gml:pos, which have been available for a long time.
> 
> > 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>
> >
> >   
> I've tried the above but it causes two problems: 
> substitutionGroup on xs:element is apparently not valid (or 
> at least that's the exception that SAX throws at me) and 
> gml:AbstractFeatureType doesn't resolve anyway. Is there 
> something wrong with how I did my xmlns:gml or my import? I 
> have never worked with XSDs before so I really don't know 
> very much about this issue.
> 

What does your .xsd look like?  You can send it to me offline.

> > You might want to consult the OGC Public Forum 
> (http://feature.opengeospatial.org/forumbb/) as well.
> >
> > ..Tom
> >
> > _______________________________________________
> > Discuss mailing list
> > Discuss at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/discuss
> >   
> Thanks a lot for your help! I'll keep working at it and post 
> any results I get on here.
> 
> René
> _______________________________________________
> Discuss mailing list
> Discuss at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/discuss
> 



More information about the Discuss mailing list