Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [xsd-dev] I can't get the Numeric Data Type for the current XSDSimpleTypeDefinition

John,

Please use the newsgroup for questions:
news://new.eclipse.org/eclipse.technology.xsd

John Dous wrote:

Hello everyone! I try to get the Numeric DataType for the current XSDSimpleTypeDefinition element but I can’t. With method XSDSimpleTypeDefinition.getPrimitiveTypeDefinition() I get the build-in Type definition for the current element, but when the element is other built-in type like integer, long, nonNegativeInteger, nonPositiveInteger, int, short, byte the this method is unuseful.The method XSDSimpleTypeDefinition.getBaseType() return the DataType of the parent element and not for current. The method XSDSimpleTypeDefinition.getName() brings the value but if the declaration of type is another simpleType the value is wrong. Example:

 

<xs:element name="direct-long" type="xs:long"/>

<xs:element name="direct-short" type="xs:short"/>

 

<xs:element name="link-long" type="link-long"/>

<xs:element name="link-short" type="link-short"/>

 

<xs:simpleType name="link-long">

   <xs:restriction base="xs:long">

            <xs:minInclusive  value="14000"/>

   </xs:restriction>

</xs:simpleType>

 

<xs:simpleType name="link-short">

   <xs:restriction base="xs:short">

            <xs:minInclusive  value="14"/>

   </xs:restriction>

</xs:simpleType>

 

One other idea is to get the BigDecimal Object of the XSDMaxInclusiveFacet and to find from this the current DataType. Example:

 

if (xsdFacet instanceof XSDMaxInclusiveFacet) {

      BigDecimal big (BigDecimal)((XSDMaxInclusiveFacet)xsdFacet).getValue();

}

       

Could anyone know how I can find the DataType for the current Element with easy way?

It seems to me you already have the data type for the current element once you have the XSDSimpleTypeDefinition.  You can walk up the baseType for it until you reach the root of the type hierarchy.  You could keep track of the targetNamespace of each such base type until you reach a type with the schema for schema namespace...

 

Thank you in advance.



Get news, entertainment and everything you care about at Live.com. Check it out!

_______________________________________________ xsd-dev mailing list xsd-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/xsd-dev

Back to the top