dita - Ant xmlproperty task fails due to validation error -
i want extract application version dita map file. ditamap file valid , looks this:
<?xml version="1.0" encoding="utf-8"?> <!doctype map public "-//oasis//dtd dita map//en" "map.dtd"> <map id="user-manual"> <title><ph keyref="product"/> user manual</title> <topicmeta> <prodinfo> <prodname><keyword keyref="product"/></prodname> <vrmlist> <vrm version="4" release="3" modification="0"/> </vrmlist> </prodinfo> </topicmeta> <!-- [...] --> </map>
the information want in <vrm>
element.
"easy peasy," think myself. use ant's <xmlproperty>
task load xml file.
<project default="test"> <!-- notice @validate --> <xmlproperty file="path/to/user-manual.ditamap" validate="false"/> <target name="test"> <echo>${map.topicmeta.prodinfo.vrmlist.vrm(version)}</echo> </target> </project>
i don't want validate because ant isn't going find map.dtd.
loading file returns error:
java.io.filenotfoundexception: /home/user/user-manual/map.dtd (no such file or directory)
if remove <!doctype>
declaration or add nested <xmlcatalog>
path dtd, file loads , can use properties it.
i tested ant 1.7.1 , 1.9.4. bug ant, or misunderstanding how ant loads xml properties , purpose of validate
attribute?
how can make ant obey will?
i recommend not use <xmlproperty>
this. please have @ docs:
for example, semantic attribute processing enabled, xml property file:
<root> <properties> <foo location="bar"/> <quux>${root.properties.foo}</quux> </properties> </root>
is equivalent following fragments in build.xml file:
<property name="root.properties.foo" location="bar"/> <property name="root.properties.quux" value="${root.properties.foo}"/>
so name of properties set generated using paths root element, rely on structure of dita map. many elements in dita may set @ different positions on dita map. means, if move metadata parent element, property name changes , build fails. not, want.
i'd recommend grab values via xslt , set properties. way, could, example, say, "give me first occurance of element simple //foo[1]
xpath selector. further on, have power of xslt , xpath slice values, format dates , on before setting property.
update can use oops consultancy ant xmltask that. easy set property using <copy>
:
<copy path="//critdates/created/@date" property="document.date" append="false"/>
Comments
Post a Comment