Hi List,
I was working on multi replacement in Word docx. I saw a strange behavior of "copy/modify".
I modified a document.xml and zip my folder content twice when I realized my template was wrong. I had to do it again and, after a hundred tries, I realized that copy/modify clause restored every time the old version of my content.
I had to close basexGui and relaunch it to have my changes taken in charge.
Hi List,
I was working on multi replacement in Word docx. I saw a strange behavior of "copy/modify".
I modified a document.xml and zip my folder content twice when I realized my template was wrong. I had to do it again and, after a hundred tries, I realized that copy/modify clause restored every time the old version of my content.
I had to close basexGui and relaunch it to have my changes taken in charge.
Hi List,
I was working on multi replacement in Word docx. I saw a strange behavior of "copy/modify".
Here is the fact:
I use Basex to modify document.xml then zip its folder in a docx file. After a few try, I needed to modify the original and start the process again. But it always zipped back the elder document.xml version I had corrected ... and deleted (I mean, the text inside $doc was the elder version, see infra). I had to close basexGui and relaunch it to have my new file taken in charge. And I have to do this every time I modify the original docx file.
Here is the code :
declare function local:mapp($path,$space){ for $x at $count in file:list($path) order by $x descending return if (file:is-dir($path||'/'||$x)) then let $s := count(analyze-string($path||$x,'/')//fn:match) return <zip:dir name = "{replace($x,'/$','')}"> {local:mapp($path||'/'||$x,$s)} </zip:dir> else <zip:entry name="{$x}" src="{$path}/{$x}"/> };
for $x in file:read-text-lines('liste.txt') return *copy $doc := doc("/document.xml")* modify for $w in $doc//w:t[.//text() contains text 'XXXXX'] return replace value of node $w with replace($w,'XXXXX',$x) return ( file:write("document.xml",$doc) , let $rep := "/docx" let $dest := "/tmp" return zip:zip-file( <file xmlns="http://expath.org/ns/zip" href="{$dest}/courrier{$count} .docx"> {local:mapp($rep,1)} </file>) )
All the best,
X