It's too bad you consider it a hack. For mixed content at least, it is a
good approach (alternatively, you can use DOM for this purpose). See
sample/MixedContent, which is the recommended way of doing it. How else
would you deal with being able to control where does your text get added
in relation to the elements in the content?
For simple content, you can also use the inherited
setStringValue(String) method.
Radu
On Tue, 2008-03-11 at 21:18 -0400, Alessandro Ferrucci wrote:
> Hey,
> thanks for the response. I had thought about using cursor but was
> reaaallly trying to steer away from doing it that way, as I consider
> it a hack. I fixed this issue by chaning my schema slightly. Instead
> of making a mixed complexType I changed my FilterRequestType to have
> a simpleContent with a base of xs:string and having the inclusive
> attributes, as follows:
>
> <xs:element name="ProfanityFilterRequest" type="FilterRequestType" />
>
> <xs:complexType name="FilterRequestType" mixed="true">
> <xs:simpleContent>
> <xs:extension base="xs:string">
> <xs:attribute name="response_type"
> type="responseTypes"
> use="optional" />
> <xs:attribute name="validate_phone"
> type="xs:boolean"
> use="optional" />
> <xs:attribute name="validate_zip"
> type="xs:boolean"
> use="optional" />
> <xs:attribute name="bid" type="xs:integer"
> use="optional" />
> <xs:attribute name="country" type="xs:string"
> use="optional" />
> <xs:attribute name="product" type="xs:string"
> use="required" />
> <xs:attribute name="category" type="xs:string"
> use="optional" />
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
> I'm still not sure why XmlBeans did not allow me to have text values
> inside of the FilterRequestType since the attribute mixed=true as I
> understand it's described in XML Schema Spec allows you to include
> character data as the value of the complexType element. If anyone has
> any insight as to why that did not happen, please shed some light. I
> see that Bug # XMLBEANS-334 on Jira is related to this issue...has
> this bug been resolved
> or closed?
>
> Thanks
>
> Alessandro Ferrucci :)
>
> On 3/11/08, Radu Preotiuc-Pietro <[EMAIL PROTECTED]> wrote:
> > In XMLBeans you would do
> >
> > newCursor().setTextValue(...) to set the content of the element.
> >
> > Radu
> >
> >
> > On Mon, 2008-03-10 at 20:39 -0400, Alessandro Ferrucci wrote:
> > > For example JAXB generates the following class:
> > >
> > > public class FilterRequestType {
> > >
> > > @XmlValue
> > > protected String content;
> > > @XmlAttribute
> > > protected BigInteger bid;
> > > @XmlAttribute
> > > protected String category;
> > > @XmlAttribute
> > > protected String country;
> > > @XmlAttribute(required = true)
> > > protected String product;
> > > @XmlAttribute(name = "response_type")
> > > protected ResponseTypes responseType;
> > > @XmlAttribute(name = "validate_phone")
> > > protected Boolean validatePhone;
> > > @XmlAttribute(name = "validate_zip")
> > > protected Boolean validateZip;
> > >
> > > And so in this case I would do setContent(...) to set the value... I
> > > need to do the equivalent in XmlBeans.
> > >
> > > thanks
> > >
> > > Alessandro Ferrucci :)
> > >
> > > On Mon, Mar 10, 2008 at 8:34 PM, Alessandro Ferrucci
> > > <[EMAIL PROTECTED]> wrote:
> > > Hello,
> > >
> > > I have the following XSD snippet:
> > >
> > > <xs:element name="ProfanityFilterRequest"
> > > type="FilterRequestType" />
> > > <xs:complexType name="FilterRequestType" mixed="true">
> > > <xs:attribute name="response_type"
> > > type="responseTypes"
> > > use="optional" />
> > > <xs:attribute name="validate_phone" type="xs:boolean"
> > > use="optional" />
> > > <xs:attribute name="validate_zip" type="xs:boolean"
> > > use="optional" />
> > > <xs:attribute name="bid" type="xs:integer"
> > > use="optional" />
> > > <xs:attribute name="country" type="xs:string"
> > > use="optional" />
> > > <xs:attribute name="product" type="xs:string"
> > > use="required" />
> > > <xs:attribute name="category" type="xs:string"
> > > use="optional" />
> > > </xs:complexType>
> > >
> > > Now I want to create an object of FilterRequestType and set
> > > its attributes and VALUE so that I get somethign like
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <ProfanityFilterRequest response_type="text" bid="1"
> > country="US">
> > > foo foo bar</ProfanityFilterRequest>
> > >
> > >
> > >
> > > The class that XmlBeans generates has all the necessary getters
> > and setters for the attributes, but none for the *VALUE*, how do I go about
> > setting "foo foo bar" for this Xml object?
> > >
> > > Thanks
> > >
> > > alessandro ferrucci :)
> > >
> > >
> > >
> > >
> >
> >
> > 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]