Thanks Vinh ! It looks really cool, also I'm not enough familiar with DOM to
evaluate this method.
Regards,
Pascal
On Wed, May 21, 2008 at 11:24 PM, Vinh Nguyen (vinguye2) <[EMAIL PROTECTED]>
wrote:
> Here's a util method I created for my use that might help you:
>
> /**
> * Copies children to the end of an XmlObject's current list of
> children.
> * @param parent The parent object.
> * @param children The children to add.
> */
> public static void appendChild(XmlObject parent, XmlObject[] children)
> {
> Node parentNode = parent.getDomNode();
> for (int x = 0; x < children.length; x++)
> {
>
> parentNode.appendChild(parentNode.getOwnerDocument().importNode(children[x].newDomNode(),
> true));
> }
> }
>
> ------------------------------
> *From:* Radu Preotiuc-Pietro [mailto:[EMAIL PROTECTED]
> *Sent:* Monday, May 19, 2008 2:12 PM
> *To:* [email protected]
> *Subject:* RE: Schema compilation into XMLBeans classes - issue with
> several xs:anyType children
>
> No, this is exactly what I had in mind :-)
>
> Radu
>
> ------------------------------
> *From:* Pascal Maugeri [mailto:[EMAIL PROTECTED]
> *Sent:* Monday, May 19, 2008 3:28 AM
> *To:* [email protected]
> *Subject:* Re: Schema compilation into XMLBeans classes - issue with
> several xs:anyType children
>
> Thank you Radu for the hint !
>
> What I did to copy a new action element (a RaduAction :->) within
> <actions/> is the following using XmlCursor:
>
> // The action to be inserted within <actions/>
> RaduActionDocument raduActionDoc =
> RaduActionDocument.Factory.newInstance();
> raduActionDoc.setStatus(true);
>
> XmlCursor srcCursor = raduActionDoc.newCursor();
> srcCursor.toFirstChild();
>
> XmlCursor dstCursor = actions.newCursor();
> dstCursor.toEndToken();
>
> srcCursor.copyXml(dstCursor);
>
>
> The srcCursor.toFirstChild() is required otherwise I get a
> "java.lang.IllegalArgumentException: Can't move/copy/insert a whole
> document. ..." exception.
>
> Would you do it in a different or safer way ?
>
> Regards,
> Pascal
>
>
> On Fri, May 16, 2008 at 9:38 PM, Radu Preotiuc-Pietro <[EMAIL PROTECTED]>
> wrote:
>
>> The XmlObject.set() method is common to all generated classes,
>> regardless of Schema. It just replaces the current value of the XmlObject
>> with a different value, without changing the reference.
>>
>> In order to add content in an element allowing <any> wildcards, you need
>> to use the XmlCursor API (see the copyXml() and insertElement() methods if
>> you already have the content or you need to build the content from scratch,
>> respectively).
>>
>> Radu
>>
>> ------------------------------
>> *From:* Pascal Maugeri [mailto:[EMAIL PROTECTED]
>> *Sent:* Thursday, May 15, 2008 5:15 AM
>> *To:* [email protected]
>> *Subject:* Schema compilation into XMLBeans classes - issue with several
>> xs:anyType children
>>
>> Hi
>>
>> This email is related to the compilation of XMLBeans classes corresponding
>> to the XML schema "urn:ietf:params:xml:ns:common -policy" as defined in
>> RFC 4745, section 13. I give the reference to this specific schema to
>> illustrate but of course the issue should apply in other situation as well.
>>
>> In the XML schema, there is the definition of the following complex type.
>>
>> <!-- //rule/actions or //rule/transformations -->
>> <xs:complexType name="extensibleType">
>> <xs:complexContent>
>> <xs:restriction base="xs:anyType">
>> <xs:sequence>
>> <xs:any namespace="##other" processContents="lax"
>> minOccurs="0" maxOccurs="unbounded"/>
>> </xs:sequence>
>> </xs:restriction>
>> </xs:complexContent>
>> </xs:complexType>
>>
>> Scomp produces the class ExtensibleType that only provides me with the
>> setter
>> ExtensibleType.set(XmlObject arg0)
>> but according to the schema definition I should have the possibility to
>> add more than one child (maxOccurs="unbounded").
>>
>> Do you have any idea on how I can add several children of type xs:anyType
>> to my ExtensibleType ?
>>
>> I would like to produce a such structure:
>>
>> <urn:rule>
>> <urn:conditions/>
>> <urn:actions>
>> <call>true</call>
>> <email>true</email>
>> </urn:actions>
>> <urn:transformations/>
>> </urn:rule>
>>
>> but with the current XMLBean class ExtensibleType I can only have a single
>> action under <actions/>.
>>
>> Regards,
>> Pascal
>>
>>
>> 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.
>
>
>
> 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.
>