You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Steven Crosley <st...@mac.com> on 2008/04/02 22:55:19 UTC
How do I set a string element of a type object?
Hi,
I'm trying to set an element value that is a complex type, but I had
to add an attribute to the element so I can no longer call it like this:
book.setTitle(rs.getString("title"));
I now get this message:
The method setTitle(TitleType) in the type Book is
not applicable for the arguments (String)
So, how do I convert the String to the TitleType object?
My XSD looks something like this:
<xs:element type="tns:titleType" name="title"/>
<xs:complexType name="titleType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="lost"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Thanks,
Steven
RE: How do I set a string element of a type object?
Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Instead of
book.setTitle(rs.getString("title"));
do
TitleType title = book.addNewTitle();
title.setStringValue(rs.getString("title"));
Then, if you want to set the "lost" attribute, you'll do:
title.setLost(true);
Radu
On Thu, 2008-04-03 at 08:35 +0100, Andrew Mansfield wrote:
> Use the factory method.
>
> Thanks,
> Andy
> -----Original Message-----
> From: Steven Crosley [mailto:stevencrosley@mac.com]
> Sent: 02 April 2008 21:55
> To: user@xmlbeans.apache.org
> Subject: How do I set a string element of a type object?
>
>
> Hi,
>
>
> I'm trying to set an element value that is a complex type, but
> I had to add an attribute to the element so I can no longer
> call it like this:
>
>
> book.setTitle(rs.getString("title"));
>
>
> I now get this message:
>
>
> The method setTitle(TitleType) in the type Book is
> not applicable for the arguments (String)
>
>
> So, how do I convert the String to the TitleType object?
>
>
> My XSD looks something like this:
>
>
> <xs:element type="tns:titleType" name="title"/>
>
>
>
>
> <xs:complexType name="titleType">
> <xs:simpleContent>
> <xs:extension base="xs:string">
> <xs:attribute type="xs:boolean" name="lost"/>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
>
>
>
> Thanks,
> Steven
>
>
Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
RE: How do I set a string element of a type object?
Posted by Andrew Mansfield <AM...@globeop.com>.
Use the factory method.
Thanks,
Andy
-----Original Message-----
From: Steven Crosley [mailto:stevencrosley@mac.com]
Sent: 02 April 2008 21:55
To: user@xmlbeans.apache.org
Subject: How do I set a string element of a type object?
Hi,
I'm trying to set an element value that is a complex type, but I had to add an attribute to the element so I can no longer call it like this:
book.setTitle(rs.getString("title"));
I now get this message:
The method setTitle(TitleType) in the type Book is
not applicable for the arguments (String)
So, how do I convert the String to the TitleType object?
My XSD looks something like this:
<xs:element type="tns:titleType" name="title"/>
<xs:complexType name="titleType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="lost"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Thanks,
Steven