xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sanh, Ai-Hoa" <as...@ll.mit.edu>
Subject Parsing and Substitution Groups
Date Tue, 07 Jul 2009 21:53:33 GMT
I have the following in my xsd:

   <xs:complexType name="Alpha>
         <xs:extension base="gml:AbstractFeatureType">
               <xs:element name="alphaString" type="xs:string"/>
               <xs:element ref="gml:Polygon"/>
               <xs:element name="aString" type="xs:string"/>

   <xs:element name="alpha" type="tns:Alpha" substitutionGroup="gml:_Feature"/>

gml:AbstractFeatureType extends gml:AbstractGMLType, which has a "gml:name" element that is

After compiling the schemas, I get the following classes:

   public abstract interface net.opengis.gml.AbstractGMLType extends org.apache.xmlbeans.XmlObject
   public class net.opengis.gml.impl.AbstractGMLTypeImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl
implements net.opengis.gml.AbstractGMLType

   public abstract interface net.opengis.gml.AbstractFeatureType extends net.opengis.gml.AbstractGMLType
   public class net.opengis.gml.impl.AbstractFeatureTypeImpl extends net.opengis.gml.impl.AbstractGMLTypeImpl
implements net.opengis.gml.AbstractFeatureType

   public abstract interface mypackage.Alpha extends net.opengis.gml.AbstractFeatureType
   public class mypackage.AlphaImpl extends net.opengis.gml.impl.AbstractFeatureTypeImpl implements

   public abstract interface mypackage.AlphaDocument extends net.opengis.gml.FeatureDocument
   public class mypackage.AlphaDocumentImpl extends net.opengis.gml.impl.FeatureDocumentImpl
implements mypackage.AlphaDocument

This is my xml snippet:

    xsi:schemaLocation="http://myserver/myns ../../xsd/polygon.xsd<http://myserver/xsd/polygon.xsd>"
    <gml:description>This is my description</gml:description>
    <gml:Polygon srsName="">
                <gml:coordinates decimal="." cs="," ts=" ">0,0 84,0 84,48 0,48 0,0</gml:coordinates>

I am testing this snippet of Java code:

    AbstractFeatureType feature = AbstractFeatureType.Factory.parse( xml );
    System.out.println( feature.getNameArray().length );
    System.out.println( feature.getId() );

The code compiles, but I am getting "0" for the length and "null" for the id.

However, if I were to use:

    AlphaDocument doc = AlphaDocument.Factory.parse( xml );
    Alpha a = doc.getAlpha();
    System.out.println( a.getId() );
    System.out.println( a.getNameArray().length );

Then I get "1" and "alpha.A1", as I expect.

Is this working as designed? Or am I doing something incorrectly.

I would like very much to be able to get at these parts of the xml without having to know
that I am dealing with an Alpha or a Beta, as long as they both extend the AbstractFeatureType.
Is there another means of doing so if parsing is not the answer?

Thank you for your help.
Ai-Hoa Sanh

View raw message