I'm new to Castor and to XML schemas, and I am trying to use the code
generator to handle xml portions like this:
<textbox hpos="left 0" vpos="top 0" height="30" width="80">
<text align="center">A text</text>
</textbox>
<imagebox hpos="right 0" vpos="top 0" height="30" width="30">
<image fill="stretch">an_image.gif</image>
</imagebox>
So I naturally thought of an abstract type "box", which "textbox" and
"imagebox" would extend.
here is some extract of my latest attempt of a schema file:
<!-- "hpos" argument type: center, left <value>, right <value> -->
<simpleType name="hpos">
<restriction base="string">
<pattern value="(center|left [0-9]+|right [0-9]+)"/>
</restriction>
</simpleType>
<!-- "vpos" argument type: center, top <value>, bottom <value> -->
<simpleType name="vpos">
<restriction base="string">
<pattern value="(center|top [0-9]+|bottom [0-9]+)"/>
</restriction>
</simpleType>
<!-- "box" type: common abstract class to all boxes -->
<complexType name="box">
<attributeGroup ref="boxAttrGrp"/>
</complexType>
<attributeGroup name="boxAttrGrp">
<attribute name="hpos" type="hpos" use="required"/>
<attribute name="vpos" type="vpos" use="required"/>
<attribute name="height" type="integer" use="required"/>
<attribute name="width" type="integer" use="required"/>
</attributeGroup>
<!-- a textbox is a box with a text. -->
<element name="textbox">
<complexType>
<complexContent>
<extension base="box">
<sequence>
<!-- "text" element has an optional "align" attribute -->
<element name="text" use="required">
<complexType>
<simpleContent>
<extension base="string">
<attribute name="align" type="string" use="optional"/>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
</extension>
</complexContent>
</complexType>
</element>
<!-- a imagebox is a box with an image. -->
<element name="imagebox">
<complexType>
<complexContent>
<extension base="box">
<sequence>
<!-- "image" element has an optional "fill" attribute -->
<element name="image" use="required">
<complexType>
<simpleContent>
<extension base="string">
<attribute name="fill" type="string" use="optional"/>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
</extension>
</complexContent>
</complexType>
</element>
I'm using the default ("element") method of codegen to handle top-level
complex types.
the codegen magically creates a Box abstract class, and Textbox and Imagebox
classes which extend it. I'm not sure it represents the XML I intend to
manipulate, but at least it compiles.
My problem is the use of the "box" type:
<element name="boxlist">
<complexType>
<sequence>
<element name="box" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
this generates a Boxlist class whose descriptor does not compile, because it
attempts to instantiate the abstract class "Box".
I've tried to replace
<element name="box" maxOccurs="unbounded"/>
by
<element name="box" type="box" maxOccurs="unbounded"/>
or
<element name="box" maxOccurs="unbounded">
<complexType ref="box"/>
</element>
but each of those caused a different problem.
What (dozens of) errors am I doing?
youri
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev