Xmltask tangled up in dtd

I am trying to use xmltask for ant to modify a file in a subdirectory:

project/path/to/file.xml

The file refers to the DTD as follows:

<!DOCTYPE data SYSTEM "mydtd.dtd">

I do not have the flexibility to modify these documents.

This DTD is stored in the same subdirectory, which always worked fine:

project/path/to/mydtd.dtd

Unfortunately, xmltask is trying to find dtd in my top-level directory of the project, where my build file is located, and where I run from:

[xmltask] java.io.FileNotFoundException: /home/me/project/mydtd.dtd (the system cannot find the specified file)

xmltask, xmlcatalog, , . dtd, , ; publicId, XML, . , , , , DTD , ?

xmltask DTD ? ?

+5
5

XML - , .

, Ant <XmlCatalog> DTD , . , <XmlCatalog> OASIS, , DTD SYSTEM.

OASIS ( spec ) :

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">      
  <system systemId="mydtd.dtd" uri="project/path/to/mydtd.dtd"/>
</catalog>

<XmlCatalog>:

<xmlcatalog refid="commonDTDs"/>
  <catalogpath>
    <pathelement location="path/to/oasis.catalog"/>
  </catalogpath>
</xmlcatalog>

. OASIS XML Ant, <XmlCatalog>.

+5

, , , , DVD, , . , , .

+1

:

<!DOCTYPE data SYSTEM "./path/to/mydtd.dtd">

? ?

, <dtd> .

0

xmltask , . Ant , basedir <target>. :

<target basedir="path/to" ...>
  <xmltask...
</target>

, XML/DTD, xmltask , .

, Ant Copy, XML DTD xmltask, .

0

, XML doctype SYSTEM, .

<!DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd">

OASIS, , , Apache Commons Resolver 1.1 (resolver.jar) w40 > classpath (. http://ant.apache.org/manual/Types/xmlcatalog.html).

, , , , xmltask , doctype. , doctype .

I ended up using this workaround: I commented on the definition of doctype using the Ant task replace, ran it xmltask, and then returned the doctype to the file.

<replace file="myxmlfile.xml">
    <replacetoken>&lt;!DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd"&gt;</replacetoken>
    <replacevalue>&lt;!-- !DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd" --&gt;</replacevalue>
</replace>

<xmltask .../>

<replace file="${local.opencms.webapp.webinf}/config/opencms-modules.xml">
    <replacetoken>&lt;!-- !DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd" --&gt;</replacetoken>
    <replacevalue>&lt;!DOCTYPE opencms SYSTEM "http://www.opencms.org/dtd/6.0/opencms-modules.dtd"&gt;</replacevalue>
</replace>
0
source

All Articles