[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>&nbsp;</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 :-&gt;) within &lt;actions/&gt; is the following 
  using XmlCursor:<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // The action to 
  be inserted within &lt;actions/&gt;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  RaduActionDocument raduActionDoc = 
  RaduActionDocument.Factory.newInstance();<BR>&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp; raduActionDoc.setStatus(true);<BR><BR>&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp; XmlCursor srcCursor = 
  raduActionDoc.newCursor();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  srcCursor.toFirstChild();<BR><BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  XmlCursor dstCursor = actions.newCursor();<BR>&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp; dstCursor.toEndToken();<BR>&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  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 
  &lt;<A href="mailto:radup@bea.com">radup@bea.com</A>&gt; 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&nbsp;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>&nbsp;</DIV>
    <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>In order 
    to add content in an element allowing &lt;any&gt; 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>&nbsp;</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>&nbsp;&nbsp;&nbsp; &lt;!-- 
      //rule/actions or //rule/transformations --&gt;<BR>&nbsp;&nbsp;&nbsp; 
      &lt;xs:complexType 
      name="extensibleType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;xs:complexContent&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  &lt;xs:restriction 
      base="xs:anyType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                
      &lt;xs:sequence&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  &lt;xs:any namespace="##other" 
      processContents="lax"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  minOccurs="0" 
      maxOccurs="unbounded"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                
      &lt;/xs:sequence&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                
      &lt;/xs:restriction&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;/xs:complexContent&gt;<BR>&nbsp;&nbsp;&nbsp; 
      &lt;/xs:complexType&gt;<BR><BR>Scomp produces the class ExtensibleType 
      that only provides me with the setter <BR>&nbsp; 
      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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;urn:rule&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;urn:conditions/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;urn:actions&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;call&gt;true&lt;/call&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                
      &lt;email&gt;true&lt;/email&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;/urn:actions&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;urn:transformations/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;/urn:rule&gt;<BR><BR>but with the current XMLBean class ExtensibleType 
      I can only have a single action under 
      &lt;actions/&gt;.<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