Hi,
I have drilled down the problem to how xmlbeans exposes a <xsd:sequence> of
<xsd:choice> where the available choices do not have a common basetype.
Here is an extract of CTBody schema from wml.xsd:
<xsd:choice>
<xsd:element name="customXml" type="CT_CustomXmlBlock">
<xsd:annotation>
<xsd:documentation>Block-Level Custom XML Element</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="sdt" type="CT_SdtBlock">
<xsd:annotation>
<xsd:documentation>Block-Level Structured Document
Tag</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="p" type="CT_P" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>Paragraph</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="tbl" type="CT_Tbl" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>Table</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:group ref="EG_RunLevelElts" minOccurs="0" maxOccurs="unbounded" />
</xsd:choice>
Each element is exposed through a separate list, thus ordering is lost. I have
found how to preserve ordering when doing read access
(http://article.gmane.org/gmane.text.xml.xmlbeans.user/2639/match=choice+sequence+order),
but I don't have an idea how to write elements in a specific order as there is
no shared list of them. My only current idea is to dump the xml of the
bodyElements (CTP and CTTbl) into a string (with correct ordering) and the
CTBody.Factory.parse them into a CTBody again. Very ugly.
Any better approaches?
Cheers
Brian
-----Ursprüngliche Nachricht-----
Von: Brian Rosenberger [mailto:[email protected]]
Gesendet: Sonntag, 26. Juni 2011 17:58
An: [email protected]
Betreff: AW: Replacing placeholder to a Table.
Hi,
I am facing the same problem. The insertTable() method correctly adds the table
into the body element list (correct position between two paragraphs). But when
the document is written, all tables end up at the end of the document.
However tables inserted by ms word remain at their original location.
Cheers
Brian
-----Ursprüngliche Nachricht-----
Von: Mark Beardsley [mailto:[email protected]]
Gesendet: Samstag, 26. Februar 2011 13:22
An: [email protected]
Betreff: Re: Replacing placeholder to a Table.
Hello again Andre,
I do not know if you are stil working on this problem but I have been a little
today and can report no p[rogress at all. It is a trivial task to build a
document sequentially; inserting a new paragraph followed by a table followed
by another paragraph, etc, but I cannot yet find a way to insert a table
between two existing paragraphs; whatever I try, the table simply appears at
the end of the document.
I think that the key lies in one of two places - allowing us to directly update
either the tables list or the body elements list, both of which are protected
and so inaccessible to client code. To date, I have not looked at the source of
the XWPF class but suspect that this is the way the
insertTable() and setTable() methods try to work. It would be perfect if we
could use the set/insertTable methods to allow us to position a table in the
document in it's correct location and I will look to see if this is possible.
As always, will be in touch if I make any progress.
Yours
Mark B
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/Replacing-placeholder-to-a-Table-tp3392424p3401338.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional
commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]