I have the following in my xsd:
<xs:complexType name="Alpha>
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="alphaString" type="xs:string"/>
<xs:element ref="gml:Polygon"/>
<xs:element name="aString" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="alpha" type="tns:Alpha" substitutionGroup="gml:_Feature"/>
gml:AbstractFeatureType extends gml:AbstractGMLType, which has a "gml:name"
element that is unbounded.
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 mypackage.Alpha
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:
<alpha
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://myserver/myns
../../xsd/polygon.xsd<http://myserver/xsd/polygon.xsd>"
xmlns="http://myserver/myns"
xmlns:gml="http://www.opengis.net/gml"
gml:id="alpha.A1">
<gml:description>This is my description</gml:description>
<gml:name>http://myserver/myns/alpha</gml:name<http://myserver/myns/alpha%3c/gml:name>>
<alphaString>AA123</alphaString>
<gml:Polygon srsName="">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">0,0 84,0 84,48 0,48
0,0</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
<aString>aa123</aString>
</alpha>
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