You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Nick Burch <ni...@torchbox.com> on 2008/04/11 14:25:22 UTC

No way to get at children of a bean in order, ignoring type

Hi All

I have another issue for apache poi, from our nicely generated beans from
the ooxml xsd. We have one particular bean which can have a number of
children, including text, hyperlinks and comments. The bean offers to give
us an ordered list of all the text, an ordered list of hyperlinks etc. The
snag is we can't figure out how to get all the entries in the order they
occur, irrespective of their type.

So, for this snippet of xml (scheme is at
http://people.apache.org/~nick/wml.xsd):
    <w:p w:rsidR="00812E80" w:rsidRDefault="00812E80">
      <w:r>
        <w:t xml:space="preserve">We have a </w:t>
      </w:r>
      <w:hyperlink r:id="rId4" w:history="1">
        <w:r w:rsidRPr="00812E80">
          <w:rPr>
            <w:rStyle w:val="Hyperlink"/>
          </w:rPr>
          <w:t>hyperlink</w:t>
        </w:r>
      </w:hyperlink>
      <w:r>
        <w:t xml:space="preserve"> here, and </w:t>
      </w:r>
    </w:p>

We want to be able to get back the children in this order, irrespective of
their types. This will allow us to get the textual data out in the order
it occurs. For now, all we can do is get all the r's, then all the
hyperlinks, and our text is then "We have a  here, and hyperlink", when we
really wanted "We have a hyperlink here, and "

Is there a trick to getting back all the children of the w:p, in the order
they occur, irrespective of the child's type?

Thanks
Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: No way to get at children of a bean in order, ignoring type

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
XmlCursor is your friend here. It's really not that difficult and does
exactly what you want. I suggest you start with the sample at:
http://xmlbeans.apache.org/samples/OrderMatters.html (also included in
the XMLBeans distribution).

Radu

> -----Original Message-----
> From: Nick Burch [mailto:nick@torchbox.com] 
> Sent: Friday, April 11, 2008 5:25 AM
> To: user@xmlbeans.apache.org
> Subject: No way to get at children of a bean in order, ignoring type
> 
> Hi All
> 
> I have another issue for apache poi, from our nicely 
> generated beans from the ooxml xsd. We have one particular 
> bean which can have a number of children, including text, 
> hyperlinks and comments. The bean offers to give us an 
> ordered list of all the text, an ordered list of hyperlinks 
> etc. The snag is we can't figure out how to get all the 
> entries in the order they occur, irrespective of their type.
> 
> So, for this snippet of xml (scheme is at
> http://people.apache.org/~nick/wml.xsd):
>     <w:p w:rsidR="00812E80" w:rsidRDefault="00812E80">
>       <w:r>
>         <w:t xml:space="preserve">We have a </w:t>
>       </w:r>
>       <w:hyperlink r:id="rId4" w:history="1">
>         <w:r w:rsidRPr="00812E80">
>           <w:rPr>
>             <w:rStyle w:val="Hyperlink"/>
>           </w:rPr>
>           <w:t>hyperlink</w:t>
>         </w:r>
>       </w:hyperlink>
>       <w:r>
>         <w:t xml:space="preserve"> here, and </w:t>
>       </w:r>
>     </w:p>
> 
> We want to be able to get back the children in this order, 
> irrespective of their types. This will allow us to get the 
> textual data out in the order it occurs. For now, all we can 
> do is get all the r's, then all the hyperlinks, and our text 
> is then "We have a  here, and hyperlink", when we really 
> wanted "We have a hyperlink here, and "
> 
> Is there a trick to getting back all the children of the w:p, 
> in the order they occur, irrespective of the child's type?
> 
> Thanks
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 

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: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org