Page 1 of 1

xpath count whith OpenDoPE Add-in in Word

PostPosted: Wed May 21, 2014 4:11 am
by erwangouyette
Hi,

I don't know if i'm posting in the good place. So please excuse me if it's the case.
I'm currently trying, in Word, with the OpenDoPE Add-in, to display the number of occurences of an element from the XML i'm working with.
To achieve this, I tried "Add data value" and then entered the xpath expression to count the occurrences.
I did it by simply clicking on the element I want to count the occurrences in the XML. Then copying the xpath value. Then pasting it in the xpath field of "Add data value" and wrapping it with count(<expression>).

Unfortunately, a pop-up message appeared telling this would not return an element and asking me "Check this is what you want ? ".

So here's my question: is what I'm trying to do possible to achieve ? And if yes, how to do it ?

Thank you very much, regards,

Erwan Gouyette

Re: xpath count whith OpenDoPE Add-in in Word

PostPosted: Wed Jun 04, 2014 2:59 am
by erwangouyette
Well actually it works. Sorry for posting but in the case you're interested in the way to do it, this is an example.

Say you want to display the number of "host" nodes in your XML file.
Just click "Add Data Value" and enter the xpath expression "count(//tns:host)".
NB : "tns" stands for target namespace, so it could be "ns0". It depends on the namespace used in the XML file.

Then click "OK".

Careful : once the xpath expression confirmed, it's not possible to edit-change this one.

A window appears saying: "XPath count(//tns:host) does not return an element. Ckeck this is what you want ? ".
Click "OK".

Then, in the Word document, a content control with the default grey text "Click here to enter text." appears.

When generating the document from this template, the default grey text is replaced by the value desired (i. e. the number of nodes "host").

PS: I'm using Microsoft Office Word 2010 Professional Plus, 32 bits.