Page 1 of 1

problems of document.xml in docx

PostPosted: Mon Jan 13, 2014 1:13 pm
by songlei
hi guys , i think i have a encoding problem when i try to read a template from document.xml of a docx file and finally merge in velocity and export to another .docx .
it gives me a ParseErrorException when i try to read the document.xml from the xml String i find i copy $math.mul($bNumber, "3.2") in Ms word
The xml read behind is $math.mul($b</w:t></w:r><w:r w:rsidRPr="008665C2"><w:rPr><w:rFonts w:cs="Courier New"/><w:lang w:val="en-US"/></w:rPr><w:t>Number, "3.2"), i get really frustrated, i still don't understand why it is so Strange about the xml the Ms word read.... anyone get the same problems like this ? please help thanks

noted : if i just type $math.mul($bNumber, "3.2") ,it shows what it is in the xml i gotin the backend , but if i copy this and paste below ,it shows quite differently like :$math.mul($b</w:t></w:r><w:r w:rsidRPr="008665C2"><w:rPr><w:rFonts w:cs="Courier New"/><w:lang w:val="en-US"/></w:rPr><w:t>Number, "3.2")

Re: problems of document.xml in docx

PostPosted: Wed Jan 15, 2014 5:38 pm
by jason
Sorry, I can't make much sense of your post.

songlei wrote:it gives me a ParseErrorException when i try to read the document.xml from the xml String


What does your xml String contain? Sounds like it is not valid XML, in which case you'll need to work out what you are doing to create invalid XML.

songlei wrote:noted : if i just type $math.mul($bNumber, "3.2") ,it shows what it is in the xml i gotin the backend , but if i copy this and paste below ,it shows quite differently like :$math.mul($b</w:t></w:r><w:r w:rsidRPr="008665C2"><w:rPr><w:rFonts w:cs="Courier New"/><w:lang w:val="en-US"/></w:rPr><w:t>Number, "3.2")


You mean you typed type $math.mul($bNumber, "3.2") in Word?

You can't expect Word to necessarily put all your characters into a single w:r/w:t. This problem often comes up when people try to do variable replacement. https://github.com/plutext/docx4j/blob/ ... epare.java can clean up some of this...