[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlbeans-user
Subject: RE: Schema compilation into XMLBeans classes - issue with several xs:anyType children
From: "Radu Preotiuc-Pietro" <radup () bea ! com>
Date: 2008-05-19 21:11:53
Message-ID: BF6B6CA032BA0A429BD924F96765147DBF3B1A () repbex02 ! amer ! bea ! com
[Download RAW message or body]
No, this is exactly what I had in mind :-)
Radu
________________________________
From: Pascal Maugeri [mailto:pascal.maugeri@gmail.com]
Sent: Monday, May 19, 2008 3:28 AM
To: user@xmlbeans.apache.org
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
<radup@bea.com> 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:pascal.maugeri@gmail.com]
Sent: Thursday, May 15, 2008 5:15 AM
To: user@xmlbeans.apache.org
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.
[Attachment #3 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=437510921-19052008>No, this is exactly what I had in mind
> -)</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=437510921-19052008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=437510921-19052008>Radu</SPAN></FONT></DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; \
MARGIN-RIGHT: 0px"> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Pascal Maugeri
[mailto:pascal.maugeri@gmail.com] <BR><B>Sent:</B> Monday, May 19, 2008 3:28
AM<BR><B>To:</B> user@xmlbeans.apache.org<BR><B>Subject:</B> Re: Schema
compilation into XMLBeans classes - issue with several xs:anyType
children<BR></FONT><BR></DIV>
<DIV></DIV>Thank you Radu for the hint !<BR><BR>What I did to copy a new
action element (a RaduAction :->) within <actions/> is the following
using XmlCursor:<BR><BR> // The action to
be inserted within <actions/><BR>
RaduActionDocument raduActionDoc =
RaduActionDocument.Factory.newInstance();<BR>
raduActionDoc.setStatus(true);<BR><BR>
XmlCursor srcCursor =
raduActionDoc.newCursor();<BR>
srcCursor.toFirstChild();<BR><BR>
XmlCursor dstCursor = actions.newCursor();<BR>
dstCursor.toEndToken();<BR>
<BR>
srcCursor.copyXml(dstCursor);<BR><BR><BR>The srcCursor.toFirstChild() is
required otherwise I get a "java.lang.IllegalArgumentException: Can't
move/copy/insert a whole document. ..." exception.<BR><BR>Would you do it in a
different or safer way ? <BR><BR>Regards,<BR>Pascal<BR><BR><BR>
<DIV class=gmail_quote>On Fri, May 16, 2008 at 9:38 PM, Radu Preotiuc-Pietro
<<A href="mailto:radup@bea.com">radup@bea.com</A>> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) \
1px solid"> <DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>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.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>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).</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN>Radu</SPAN></FONT></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,255) 2px solid; \
MARGIN-RIGHT: 0px"> <DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> Pascal Maugeri [mailto:<A
href="mailto:pascal.maugeri@gmail.com"
target=_blank>pascal.maugeri@gmail.com</A>] <BR><B>Sent:</B> Thursday, May
15, 2008 5:15 AM<BR><B>To:</B> <A href="mailto:user@xmlbeans.apache.org"
target=_blank>user@xmlbeans.apache.org</A><BR><B>Subject:</B> Schema
compilation into XMLBeans classes - issue with several xs:anyType
children<BR></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c>
<DIV></DIV>Hi <BR><BR>This email is related to the compilation of XMLBeans
classes corresponding to the XML schema "urn:ietf:params:xml:ns:common
<DIV>-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.<BR><BR>In the XML schema, there is the definition
of the following complex type.<BR><BR> <!--
//rule/actions or //rule/transformations --><BR>
<xs:complexType
name="extensibleType"><BR>
<xs:complexContent><BR> \
<xs:restriction
base="xs:anyType"><BR> \
<xs:sequence><BR> \
<xs:any namespace="##other"
processContents="lax"<BR> \
minOccurs="0"
maxOccurs="unbounded"/><BR> \
</xs:sequence><BR> \
</xs:restriction><BR>
</xs:complexContent><BR>
</xs:complexType><BR><BR>Scomp produces the class ExtensibleType
that only provides me with the setter <BR>
ExtensibleType.set(XmlObject arg0)<BR>but according to the schema
definition I should have the possibility to add more than one child
(maxOccurs="unbounded").<BR><BR>Do you have any idea on how I can add
several children of type xs:anyType to my ExtensibleType ?<BR><BR>I would
like to produce a such structure:<BR><BR>
<urn:rule><BR>
<urn:conditions/><BR>
<urn:actions><BR>
<call>true</call><BR> \
<email>true</email><BR>
</urn:actions><BR>
<urn:transformations/><BR>
</urn:rule><BR><BR>but with the current XMLBean class ExtensibleType
I can only have a single action under
<actions/>.<BR><BR>Regards,<BR>Pascal<BR></DIV></DIV></DIV></BLOCKQUOTE></DIV><BR>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.</BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>
<br>
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.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic