Page 1 of 1

How to set the od:xpath

PostPosted: Thu Feb 14, 2013 10:48 am
by kvmc09302012
How to set the od:xpath to xHtmlPropertyData&od:ContentType=application/xhtml+xml. I need to insert html content using content control data binding method.
I added a new binding variable and binded the <address> node's xpath to it. The content of the address node is html value. The document.xml didn't have od:path as od:xpath=xHtmlPropertyData&od:ContentType=application/xhtml+xml.

My xml node is

<person>
<lastname>my last name</lastname>
<firstname>my First name</firstname>
<age>30</age>
<address>
<h1>my address, city, state. </h1>
</address>
</person>


I am listing the steps I followed to add a html custom node using opendope add in.

1) Opened the word document.
2) clicked on OpenDope ribbon
3) Clicked on Bind this text.
4) Entered a text and clicked on Bind This button in the task pane.
5) Pasted my custom xml. Clicked on the Address node.
6) Gave an xpath id and clicked on Use this xPath button.
7) Saved the document.
8)Opened the document.xml to see if the contentType is set to xhtml, but didn't find it.

Please let me know if I am doing something wrong.

Re: How to set the od:xpath

PostPosted: Sun Feb 24, 2013 12:42 pm
by jason
Make sure your XML part is attached, and that the node you want to bind contains escaped XHTML.

You need the node you want to bind to contain escaped XHTML before you do the binding, since od:ContentType=application/xhtml+xml is only added to the content control tag if escaped XHTML is detected at the time the binding is being set up.

Once you have your escaped XHTML in place, you can bind in any of three ways:

1. via the button add XPath
2. by dragging from the custom task pane
3. by right clicking on the custom task pane

If you have an existing content control, you can also use the edit XPath button

Note that for block level content (such as your h1 example), you generally need a block level content control.

The best way to be sure of this right now is as follows:

- create a couple of empty paragraphs; select them; Developer menu > Insert Rich Text Control
- that'll give you a block level rich text control
- now use method 3 above ie with your cursor in the rich text control, go to the task pane > right click on node containing escaped XHTML > data value > map to content control

The authoring add-in probably ought to be enhanced to create the rich text control at block or inline level depending on whether the escaped XHTML contains div|p|table|h1 etc or not

Re: How to set the od:xpath

PostPosted: Sun Aug 04, 2013 4:48 pm
by psychic
Hi there,

I'm newbie in docx4j and OpenDoPE. I already follow jason's instruction to set od:xpath and OpenDoPE seems to realize my xhtml and add od:ContentType=application/xhtml+xml tag. But, my xhtml can't be converted to word. Could you please help me to figure out what step that I miss or incorrect or guide me to any useful link about this problem.

Attached file is my doc.
Thanks in advanced.

Re: How to set the od:xpath

PostPosted: Sun Aug 04, 2013 9:08 pm
by jason
Using nightly build's ContentControlBindingExtensions, I get:

org.xml.sax.SAXParseException: The document type declaration for root element type "htmlPUBLIC" must end with '>'.

Your xml contains:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
   <document><data><htmlProperty>&lt;!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


I removed the DOCTYPE declaration, leaving

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<document><data><htmlProperty>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;&lt;head&gt;&lt;title&gt;A Sample&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;This is sample of xhtml to docx.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</htmlProperty></data><today>03 Aug 2013</today><currentTime>09:37</currentTime></document>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


and things work.

If you do decide you use a current nightly, rather than docx4j 2.8.1, note that the XHTML Import stuff is now in a separate project and jar. Try http://www.docx4java.org/docx4j/docx4j- ... 130801.jar

Re: How to set the od:xpath

PostPosted: Mon Aug 05, 2013 1:20 pm
by psychic
Thank you, jason.

I'm able to generate pdf from xhtml now. But still I'm using docx4j-2.8.1, itext-2.7.1 and xhtmlrenderer-1.0.0.

Best regards

Re: How to set the od:xpath

PostPosted: Mon Aug 05, 2013 3:04 pm
by jason
psychic wrote: But still I'm using docx4j-2.8.1, itext-2.7.1 and xhtmlrenderer-1.0.0.


That's fine of course, if it works adequately for you.

The import quality will be significantly improved when docx4j 3.0.0 lands; the nightlies just give you early access to the work in progress