Thanks Lawrence.
That got me thinking and digging deeper. I found the getYear and setYear
methods in the generated source and they do what I expected. "year" is
the atrtribute I'm using in my YTD_RENT element, e.g.:
<YTD_RENT year="2005">4200</YTD_RENT>
I was looking for a getYTDRENT() method, with, perhaps, an array
qualifier. I haven't found a method to get/set the "4200" element other
than the Array methods which give me the String:
<xml-fragment year="2005">4200</xml-fragment>
Is X-B designed this way? My debug code to look at the above is as
follows:
private static houses.YtdRentElement[] ytdRentElmtAry;
...
hses = hseDoc.getHOUSES();
house = hses.getHOUSEArray();
for (int ix = 0; ix < house.length; ix++)
{
System.out.print("HOUSE_NAME = "
+ house[ix].getHOUSENAME());
System.out.print(", \tSHORT_NAME = "
+house[ix].getSHORTNAME());
...
ytdRentElmtAry = house[ix].getYTDRENTArray();
System.out.println("YTD_RENT Array="
+ ytdRentElmtAry.toString()
+ ", Len="
+ ytdRentElmtAry.length);
for (int ix2 = 0; ix2 < ytdRentElmtAry.length; ix2++)
System.out.print("ix2=" + ix2 +
", year="
+ ytdRentElmtAry[ix2].getYear() +
", AE=" + ytdRentElmtAry[ix2] + ", ");
System.out.println();
}
Parsing the fragments is doable, I'd like to know if I'm missing a method
that' already there.
Gene
On Thu, 9 Jun 2005 15:55:28 -0700, Lawrence Jones <[EMAIL PROTECTED]> wrote:
Hi Gene
I think you'll find the following document useful:
http://xmlbeans.apache.org/docs/2.0.0/guide/conMethodsForGeneratedJavaTy
pes.html
Cheers,
Lawrence
-----Original Message-----
From: Gene Holmerud [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 09, 2005 10:31 AM
To: [email protected]
Subject: Created accessor/mutator methods for attributes
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/
--------------------------------------------------------------------------------
Join CEO Alfred Chuang and CTO Mark Carges on June 15 for a unique online
event, giving you the first look at a new category of enterprise software
built specifically for Service-Oriented Architecture (SOA).
Register Now. It's Free!
http://www.bea.com/events/june15
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]