Sachith,

please see inline ...

Werner

Sachith Dhanushka wrote:
> Hi Werner and all,
> 
> I have couple of quick questions on using Castor schema model.
> 
> 1. I declared default schema namespace in the Schema object with the
> prefix "xs". Then I set the type reference of an element as "xs:string".
> But when I used SchemaWriter to serialize the Schema object, the type of
> the element is serialized as "string" and not as "xs:string". What
> should I do to fix this?
I think you are already looking into this as part of a different thread.
It might have to be - as you noticed yourself - that you'll have to
extend the Schema class so that custom namespace prefices can be set.

> FYI : XMLInstance2SchemaHandler class had used setReference method
> instead of setType method to set a simple type as a type of an element.
> I think it is not the best way to do that, but I followed the same thing
> assuming XMLInstance2SchemaHandler is doing it with a proper reason.
Which I think is fine for the time being. It might be that this has to
change later on, but it might not be the case. I think it all depends on
what kind of simple type we are looking at ? E.g. xs:integer or a user
defined simple type (defined globally). For the latter I'd expect the
setReference() method to be used, for the former not.

> 2. There is a simple type defined to define a restriction. How can I set
> this restriction to Castor schema model. For example, take the following
> schema fragment.
> 
> <xs:simpleType name="bookCategoryType" >
>    <xs:restriction base="xs:string">
>       <xs:enumeration value="magazine" />
>       <xs:enumeration value="novel" />
>       <xs:enumeration value="fiction" />
>       <xs:enumeration value="other" />
>    </xs:restriction>
> </xs:simpleType>
> 
> This is what I did.
> 
> SimpleType simpleType = new UrType();
> schema.addSimpleType(simpleType);
> 
> After this how can I add the restriction to simpleType?
As far as I remember, this is done through facets, and in your case the
enumeration facet in particular. Have a look at the EnumerationFactory
class to see how the reverse is done, i.e. how for a simple type
definition that has enumerations, these are accessed through the Facet
interface and looped over.



---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to