Hi

I'm starting to use the castor Schema in perhaps a slightly roundabout way,
in that I have a web interface where a user can incrementally build up a new
schema from a palette of types which I'm defining. The intention here is not
to offer the full flexibility of schemas in general, just a limited set of
types in a pretty flat structure.

One area I'm having trouble with is the definition of a simpleType with
restrictions

I'm trying to get a result of say,

<xsd:element name="anumber">
<xsd:annotation>
<xsd:documentation>the documentation</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:decimal" >
<xsd:minInclusive value='1'/>
<xsd:maxInclusive value='10'/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

but all I get is 

<xsd:element name="anumber" type="xsd:decimal">
<xsd:annotation>
<xsd:documentation> the documentation </xsd:documentation>
</xsd:annotation>
</xsd:element>

The code to generate this is below

public void addInteger( String name, String desc, String min, String max ) {

// stf is a SimpleTypesFactory
        SimpleType x = stf.getBuiltInType( stf.getBuiltInTypeName(
stf.DECIMAL_TYPE ));
        ElementDecl i = new ElementDecl( schema, name ); 
        
        Facet f;
        x.setDerivationMethod("restriction");

        if( min != null ){
            f = new Facet( Facet.MIN_INCLUSIVE, min );
            x.addFacet( f );
        }

        if( max != null ){
            f = new Facet( Facet.MAX_INCLUSIVE, max );
            x.addFacet( f );
        }

        doc = new Documentation();
        doc.setContent( desc );
        anot = new Annotation();
        anot.addDocumentation( doc );
        i.addAnnotation( anot );

        i.setType( x );   // set the type of the element

        this.group.addElementDecl( i );  // group is inside the top level
complex type
   }

Anybody notice where this is going wrong ?


thanks


Tim

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

Reply via email to