Hi Ross,
It appears as though you are trying to add elements to
Status message. Is this correct?
Since you have already compiled the schema and are creating
XML for the type docAckHdr, I believe what you are trying to do in this code
fragment will cause your xml instance to fail validation.
If you wish to have elements in your Status Message type,
they should be defined in the schema. I think your schema probably looks
something like:
<xs:element name="StatusMessage"
type="xs:string"/>
you may want to consider changing it to
<xs:element name="StatusMessage"
type="tns:errorType">
or something to this affect where you are going to define
the shape of the XML you are expecting.
But in answer to your query, you are seeing this because
you are setting the value for an xs:string type. Strings should follow
entitization rules and that is why you are seeing what you are seeing
below.
My suggestion is to modify your schema, but if you wish to
add true elements in StatusMessage (and fail xsd validation) you can
do so easily via the XmlCursor and/or DOM APIs. For example,
DocAckHdr.newDomNode();
Good luck,
-Jacobd
From: Larner, Ross S [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 08, 2006 9:51 AM
To: [email protected]
Subject: passing xml as a string to XML Beans
I am a new user of
XMLBeans, previously having used XMLSpy to build Java to XML helper classes. I
am having trouble passing XML strings to XMLBeans. When I try to set a string
field (statusMessage) to:
docAckHdr.addStatusMessage("<error><type>BadSku</type></error>");
the output is:
<statusMessage><error><type>BadSku</type></error></statusMessage>
the first weird thing is that the > is not converted
to > , but it gets weirder. When I try to add a third xml
element:
docAckHdr.addStatusMessage("<error><type>BadSku</type><mess>Abadskunumber</mess></error>");
the output is:
<statusMessage><![CDATA[<error><type>BadSku</type><mess>Abadskunumber</mess></error>]]></statusMessage>
I don't want the
CDATA tag. Is there a way to turn it off? And how do I get the greater than
symbol to convert? This same statement worked well in
XMLSpy.
Thanks,
Ross
_______________________________________________________________________ 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.

