bellakhalAmir / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

Velocity variable is removing the space before and after. #373

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Have a document with text "Dear   «$contact_name»"
2. Passing an argument "John Doe" as contact_name in the context.
3. After generating the reporting using velocity template, it produces output 
as "DearJohn Doe".

What is the expected output? What do you see instead?
"Dear John Doe"

What version of the product are you using? On what operating system?
1.0.3

Please provide any additional information below.
I tried passing additional space, and also created another variable 
$whitespace, but nothing seems to work.

Original issue reported on code.google.com by booshan....@gmail.com on 27 Feb 2014 at 2:57

GoogleCodeExporter commented 8 years ago
«$contact_name» is a mergefield? Please attach a simple Java+docx with your 
problem.

Original comment by angelo.z...@gmail.com on 27 Feb 2014 at 8:54

GoogleCodeExporter commented 8 years ago
Hi Angelo, attaching the docs file and the Java sample class. Please let me 
know if you need any details. Thanks in advance for your help.

Regards
Booshan

Original comment by booshan....@gmail.com on 27 Feb 2014 at 4:43

Attachments:

GoogleCodeExporter commented 8 years ago
Thank's for your attached docx+java. But I don't understand your problem, when 
I generate the docx, I have "Dear John Doe"?

What is your problem?

Original comment by angelo.z...@gmail.com on 27 Feb 2014 at 9:26

GoogleCodeExporter commented 8 years ago
Hi Angelo, I am attaching the output file I am getting. I not sure how you are 
getting "Dear John Doe". I am still getting "DearJohn Doe". You can also see 
other variables without whitespace.

Original comment by booshan....@gmail.com on 27 Feb 2014 at 9:39

Attachments:

GoogleCodeExporter commented 8 years ago
I have compared your doc with my mine. In my document I have : 

-----------------------------------------------------------------------
<w:p w:rsidR="008243F7" w:rsidRDefault="008243F7" w:rsidP="008243F7">
 <w:pPr>
  <w:pStyle w:val="NoSpacing" /> 
 </w:pPr>
 <w:r>
  <w:t>Dear</w:t> 
 </w:r>
 <w:r w:rsidR="00B172A0">
  <w:t xml:space="preserve" /> 
 </w:r>
 <w:r>
  <w:t xml:space="preserve" /> 
 </w:r>
 <w:r>
  <w:rPr>
  <w:noProof /> 
  </w:rPr>
  <w:t>John Doe</w:t> 
 </w:r>
 <w:r>
  <w:t>,</w:t> 
 </w:r>
</w:p>
---------------------------------------------------------------

In your document you have : 
-----------------------------------------------------------------------
<w:p w:rsidR="008243F7" w:rsidRDefault="008243F7" w:rsidP="008243F7">
 <w:pPr>
  <w:pStyle w:val="NoSpacing" /> 
 </w:pPr>
 <w:r>
  <w:t>Dear</w:t> 
 </w:r>
 <w:r w:rsidR="00B172A0">
  <w:t space="preserve" /> 
 </w:r>
 <w:r>
  <w:t space="preserve" /> 
 </w:r>
 <w:r>
  <w:rPr>
  <w:noProof /> 
  </w:rPr>
  <w:t>John Doe</w:t> 
 </w:r>
 <w:r>
  <w:t>,</w:t> 
 </w:r>
</w:p>
---------------------------------------------------------------

Difference is about xml:space in my case and your case, you have just space 
(that's why it deosn't preserve spaces).

It seems that it's a problem when your docx is loaded with SAX. Which OS do you 
have? 
Could you check which SAX Parser do you use?

Original comment by angelo.z...@gmail.com on 27 Feb 2014 at 10:33

GoogleCodeExporter commented 8 years ago
Hi Angelo, appreciate looking into this issue and thank you very much.

I am using Windows 7 Professional Pack -1, and running this using Java 1.7.

I am also seeing shani-xml-apis-1.4.17 downloaded by Maven. Please let me know 
if you need any other details.

Regards
Booshan

Original comment by booshan....@gmail.com on 27 Feb 2014 at 10:48

GoogleCodeExporter commented 8 years ago
Hi Booshan,

I have attached 2 files. You must set it in your 
com.swapstech.fxstar.document.service package. Launch the main of TestSAXSpace. 
This main parse the document.xml (which contains xml:space) and display value 
of this attribute. In my case my console displays : 

---------------------------------------------------
URI : http://www.w3.org/XML/1998/namespace
QName : xml:space
LocalName : space
Value : preserve
---------------------------------------------------

I suppose that in your case QName will be "space" and not "xml:space". If it 
that, could you investigate about this problem?

Many thank's.

Original comment by angelo.z...@gmail.com on 28 Feb 2014 at 8:44

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Angelo, I see only document.xml attached. Can you please attach TestSAXSpace 
as well?

Regards
Booshan

Original comment by booshan....@gmail.com on 2 Mar 2014 at 1:24

GoogleCodeExporter commented 8 years ago
ooops soory. here the TestSAXSpace .java

Original comment by angelo.z...@gmail.com on 2 Mar 2014 at 10:35

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Angelo - you are correct. It was printing space instead of xml:space. It was 
due to yahp converter that I was using to convert HTML to PDF. Thank you very 
much for your help, and this works great now after removing these jars.

Best
Booshan

Original comment by booshan....@gmail.com on 4 Mar 2014 at 1:15

GoogleCodeExporter commented 8 years ago
Ok great. I close this issue.

Original comment by angelo.z...@gmail.com on 4 Mar 2014 at 1:37