You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Guofeng Zhang <gu...@radvision.com> on 2005/06/09 12:48:36 UTC

How to limit the range of the integer type

I have limited the range of the value of an attribute in my schema as
following:

  <xs:complexType name="pageSplitType" >

       <xs:attribute name="size-per-page" >

         <xs:simpleType>

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

             <xs:pattern value="\d{1,2}"/>

           </xs:restriction>

         </xs:simpleType>

       </xs:attribute>

</xs:complexType>

 

I hope that the type of the generated attribute should be int, but it is
BigInteger. The following is the signature of the generated getter:

    /**

     * Gets the "size-per-page" attribute

     */

    java.math.BigInteger getSizePerPage();

 

How to define the schema so that the type of the attribute is int?

 

Thanks for your help very much.

 

The version is XmlBean 2.0.0.beta1


Created accessor/mutator methods for attributes

Posted by Gene Holmerud <ge...@cox.net>.
> Vaguely related to: How to limit the range of the integer type
>
> I noticed his compile created a "get" method for his attribute value.  
> My compiles, instead, yield only methods such as get/setYTDRENTArray.  
> This, in turn, gives me strings of XML snippits that look like 
> "<xml-fragment year="1990">4200</xml-fragment>" rathar than the values 
> "1990" and/or "4200".
>
> I used getMethod(Reflection) to see what methods are generated as well a 
> scaning the generated source.  Is there a way to get/set the values 
> directly?
>
> My .xml file is structured as (excerpted for readability):
> ...
> <HOUSES xmlns="http://HOUSES">
>     <HOUSE>
>        --some other (non-repeating) elements--
>        <YTD_RENT year="1990">4200</YTD_RENT>
>        --about 15 more of the above thru year="2005"--
>     </HOUSE>
>     --repeats of other houses--
> </HOUSES>	
>
> My schema (full copy attached) is structured:
>
> <xs:schema ...
>     <xs:element name="HOUSES">
> 		<xs:complexType>
> 		      <xs:sequence>
>          			<xs:element name="HOUSE" type="hse:houseElement" 
>                                          minOccurs="8" maxOccurs="8"/>
> 			</xs:sequence>
> ...
>     <xs:complexType name="houseElement">
>        <xs:sequence>
>           --the non-rpeating elements as type="xs:string"---
>           <xs:element name="YTD_RENT"      type="yr:ytdRentElement" 
> minOccurs="0"                                                              
> maxOccurs="unbounded"/>
> 	</xs:sequence>
>     </xs:complexType>
>     <xs:complexType name="ytdRentElement">
>        <xs:simpleContent>
>           <xs:extension base="xs:string">
>              <xs:attribute name="year" type="xs:ID"/>
>           </xs:extension>
>        </xs:simpleContent>
>     </xs:complexType>
> </xs:schema>
>
> Gene
>



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Created accessor/mutator methods for attributes

Posted by Gene Holmerud <ge...@cox.net>.
Vaguely related to: How to limit the range of the integer type

I noticed his compile created a "get" method for his attribute value.  My 
compiles, instead, yield only methods such as get/setYTDRENTArray.  This, 
in turn, gives me strings of XML snippits that look like "<xml-fragment 
year="1990">4200</xml-fragment>" rathar than the values "1990" and/or 
"4200".

I used getMethod(Reflection) to see what methods are generated as well a 
scaning the generated source.  Is there a way to get/set the values 
directly?

My .xml file is structured as (excerpted for readability):
...
<HOUSES xmlns="http://HOUSES">
    <HOUSE>
       --some other (non-repeating) elements--
       <YTD_RENT year="1990">4200</YTD_RENT>
       --about 15 more of the above thru year="2005"--
    </HOUSE>
    --repeats of other houses--
</HOUSES>	

My schema (full copy attached) is structured:

<xs:schema ...
    <xs:element name="HOUSES">
		<xs:complexType>
		      <xs:sequence>
         			<xs:element name="HOUSE" type="hse:houseElement" 
minOccurs="8"                                                             
maxOccurs="8"/>
			</xs:sequence>
...
    <xs:complexType name="houseElement">
       <xs:sequence>
          --the non-rpeating elements as type="xs:string"---
          <xs:element name="YTD_RENT"      type="yr:ytdRentElement" 
minOccurs="0"                                                              
maxOccurs="unbounded"/>
	</xs:sequence>
    </xs:complexType>
    <xs:complexType name="ytdRentElement">
       <xs:simpleContent>
          <xs:extension base="xs:string">
             <xs:attribute name="year" type="xs:ID"/>
          </xs:extension>
       </xs:simpleContent>
    </xs:complexType>
</xs:schema>

Gene

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Re: How to limit the range of the integer type

Posted by Jean-Christophe Pazzaglia <Je...@eurecom.fr>.
Guofeng Zhang wrote:

> I have limited the range of the value of an attribute in my schema as
> following:
>
>   <xs:complexType name="pageSplitType" >
>
>        <xs:attribute name="size-per-page" >
>
>          <xs:simpleType>
>
>            <xs:restriction base="xs:positiveInteger">
>
>              <xs:pattern value="\d{1,2}"/>
>
>            </xs:restriction>
>
>          </xs:simpleType>
>
>        </xs:attribute>
>
> </xs:complexType>
>
>  
>
> I hope that the type of the generated attribute should be int, but it
> is BigInteger. The following is the signature of the generated getter:
>
>     /**
>
>      * Gets the "size-per-page" attribute
>
>      */
>
>     java.math.BigInteger getSizePerPage();
>
>  
>
> How to define the schema so that the type of the attribute is int?
>
>  
>
> Thanks for your help very much.
>
>  
>
> The version is XmlBean 2.0.0.beta1
>
*Read* the xsd recommendation ...
and use the min/maxeclusive facet
from http://www.w3.org/TR/xmlschema-0/

            <xsd:element name="productName" type="xsd:string"/>
            <xsd:element name="quantity">
              <xsd:simpleType>
                <xsd:restriction base="xsd:positiveInteger">
                  <xsd:maxExclusive value="100"/>
                </xsd:restriction>
              </xsd:simpleType>



-- 
Jean-Christophe Pazzaglia, PhD <Je...@eurecom.fr>
Corporate communications
Tel: (+33) 4-93-00-26-78 
PGP Key available : http://www.eurecom.fr/~pazzagli/publickey.pgp
--
Institut Eurécom - Office 029
http://www.eurecom.fr/
2229 Route des CrĂȘtes 
BP 193 
06904 Sophia Antipolis, France
Fax: (+33) 4-93-00-26-27

















---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org