Writer content doesn't seems to be a standard XML

Joshua Immanuel josh at hipro.co.in
Thu Nov 25 07:50:47 UTC 2021


Hello Everyone,

I am trying to implement a ODT based report generator in Go language by
substituting placeholder fields and images.

In order to replace an image in the document, I decode the XML find the
<draw:image> node under <draw:frame> with the property which matches
the substituting field. Then I replace "xlink:href" and "loext:mime-
type" attributes matching the substituted image. Finally, add the image
in manifest.xml

This way I am able to substitute the images in the ODT doucment.
However, while encoding the xml back to string I found that the
ordering of certain texts in the document were jumbled.

Checking the content I found that the content doesn't seems to be
standard XML. Eg:

   <text:p text:style-name="P1">
     Sample
     <text:span text:style-name="T3">a</text:span>
     <text:span text:style-name="T14">dmission</text:span>
     format
   </text:p>

When I re-encode this XML, I get the following:

   <text:p text:style-name="P1">
     Sample format
     <text:span text:style-name="T3">a</text:span>
     <text:span text:style-name="T14">dmission</text:span>
   </text:p>

Thereby, completely jumbling the ordering of text.

Shouldn't the original XML be in one of the below format?

   <text:p text:style-name="P1">
     <text:span text:style-name="blah">Sample</text:span>
     <text:span text:style-name="T3">a</text:span>
     <text:span text:style-name="T14">dmission</text:span>
     <text:span text:style-name="blah2">format</text:span>
   </text:p>

   OR

   <text:p text:style-name="P1">
     Sample application format
   </text:p>

   OR

   <text:p text:style-name="P1">
     <text:span text:style-name="blah">Sample admission
   format</text:span>
   </text:p>


Is there any reasoning behind this? Am I missing something here?
Someone please enlighten me.

Thank You.

-- 
Joshua Immanuel
HiPro IT Solutions Private Limited
http://hipro.co.in
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20211125/3df73e4f/attachment.sig>


More information about the LibreOffice mailing list