Hi,

Sorry, this is very long. Hope there is a strong soul out there to get 
through this {-:

I have several problems concerning the generation of sources from xml schema

containing "substitutionGroup" attributes and "extension" elements for 
deriving from abstract types.

I looked into the mail archive and found a mail written in Oct-2002 that 
John Weir asked to start implementing support of "substitutionGroup". Since
it 
generally works to handle these schema elements there seems to be some code 
inside source generator wich handles these features. Is there any progress 
in that feature?

My questions first, so they won't get lost down there:
- Did the hacking of the generated java classes lead to the wrong marshalled

  xml or is it a general bug?
- Is it possible to solve the problem of the wrong marshalled xml via 
  binding file?
- How about using java interfaces instead of abstract classes?
- Is there a way at all to handle the problem or are "substitutionGroup" and

  "extension" not supported at all?
- Any suggestions?


Please excuse the many snippets of XSD and Java code to explain my special 
problem and the few changes I made inside of the created javaclasses.

If you like I can email the xsd/java/xml files.

The important parts of the xml schema (part of the OpenGIS filterencoding):

    <xsd:element name="comparisonOps" type="ogc:ComparisonOpsType" 
                                                           abstract="true"/>
    <xsd:complexType name="ComparisonOpsType" abstract="true"/>

    <xsd:element name="PropertyIsBetween" type="ogc:PropertyIsBetweenType"
                                     substitutionGroup="ogc:comparisonOps"/>
    <xsd:complexType name="PropertyIsBetweenType">
        <xsd:complexContent>
            <xsd:extension base="ogc:ComparisonOpsType">
                <xsd:sequence>
                    <xsd:element ref="ogc:expression"/>
                    <xsd:element name="LowerBoundary" 
                                              type="ogc:LowerBoundaryType"/>
                    <xsd:element name="UpperBoundary" 
                                              type="ogc:UpperBoundaryType"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="LowerBoundaryType">
        <xsd:choice>
            <xsd:element ref="ogc:expression"/>
        </xsd:choice>
    </xsd:complexType>
    <xsd:complexType name="UpperBoundaryType">
        <xsd:sequence>
            <xsd:element ref="ogc:expression"/>
        </xsd:sequence>
    </xsd:complexType>

  <xsd:element name="expression" type="ogc:ExpressionType" abstract="true"/>
  <xsd:complexType name="ExpressionType" abstract="true"/>

  <xsd:element name="PropertyName" type="ogc:PropertyNameType" 
                                        substitutionGroup="ogc:expression"/>
  <xsd:complexType name="PropertyNameType">
    <xsd:complexContent mixed="true">
      <xsd:extension base="ogc:ExpressionType"/>
    </xsd:complexContent>
  </xsd:complexType>

... several other complex_types with <xsd:extension
base="ogc:ExpressionType"/>

The source generator creates the following classes:

public abstract class ComparisonOpsType
public class ComparisonOps extends ComparisonOpsType
!! public abstract class PropertyIsBetweenType 
                                    extends ibr.nas.ogc.ComparisonOpsType !!
public class PropertyIsBetween extends PropertyIsBetweenType

and

public abstract class ExpressionType
public class Expression extends ExpressionType
!! public abstract class PropertyNameType 
                                       extends ibr.nas.ogc.ExpressionType !!
public class PropertyName extends PropertyNameType 

I would have expected
- ComparisonOps to be an abstract class
- PropertyIsBetweenType to extend ComparisonOps instead of ComparisonOpsType
and
- Expression to be abstract.
- PropertyNameType to extend Expression instead of ExpressionType

I hacked the generated classes the way I expected them to be.

>From that moment on I was able to compile the folling code:

    PropertyIsBetween betweenOp = new PropertyIsBetween();
    // Property
    PropertyName pn = new PropertyName();
    pn.setContent("fooBar");
    // following does NOT work as long as PropertyName 
    // does not extend Expression.
    betweenOp.setExpression(pn); 
        // LowerBoundary
        LowerBoundary lb = new LowerBoundary();
        pn = new PropertyName();
        pn.setContent("lowestValue");
        lb.setExpression(pn);
        betweenOp.setLowerBoundary(lb);
        // UpperBoundary
        ...
        
Now marshalling produces following XML:

<?xml version="1.0" encoding="UTF-8"?>
...
    <ogc:comparisonOps xsi:type="ogc:PropertyIsBetween">
        <ogc:expression xsi:type="ogc:PropertyName">fooBar</ogc:expression>
        <ogc:LowerBoundary>
            <ogc:expression
xsi:type="ogc:PropertyName">lowestValue</ogc:expression>
        </ogc:LowerBoundary>
        <ogc:UpperBoundary>
            <ogc:expression
xsi:type="ogc:PropertyName">highestValue</ogc:expression>
        </ogc:UpperBoundary>
    </ogc:comparisonOps>

... which is not valid against xsd.

It has to look like

<?xml version="1.0" encoding="UTF-8"?>
...
        <ogc:PropertyIsBetween>
                <ogc:PropertyName>fooBar</ogc:PropertyName>
                <ogc:LowerBoundary>lowestValue</ogc:LowerBoundary>
                <ogc:UpperBoundary>lowestValue</ogc:UpperBoundary>
        </ogc:PropertyIsBetween>

... which would be valid and expected.

Thanks for reading all this.

Bye, Ulf

-- 
NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse f�r Mail, Message, More! +++

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to