I'm using <xmlvalidate> with <xmlcatalog>'s a fair bit, but only against 
filesystem DTD's, not ones embedded in JAR files.

There are some tests for <xmlcatalog> in Ant's CVS if you are looking 
for example usage, although those do not use JAR-nested DTD's either.

        Erik


Jason Untulis wrote:
> Does anyone have any small examples of build.xml's with <xmlvalidate> tasks
> and <xmlcatalog> items that are used to provide the DTDs for those tasks,
> with those DTDs or jars publicly available (so I can give it a try)? For
> those of you who have had success, were there any surprises or "ah ha!"s
> that you stumbled across? Feel free to reply to me privately and I'll
> summarize for the list.
> 
> The problem I'm having is that the DTDs, which I think are in the classpath
> of the <xmlcatalog>, aren't being found. For the snippet below, I have the
> build.xml, the XML file to validate, the extracted DTD and the jar file
> containging the DTD all in the same directory with no success in finding the
> DTD, even though the public ID is found in the <xmlcatalog>.
> 
> 
>>  <xmlcatalog id="allDTDs">
>>      <classpath>
>>          <pathelement location="." />
>>          <pathelement location="struts.jar" />
>>      </classpath>
> 
> 
> [...]
> 
> For the record, I didn't see anything in the FAQ or documentation about any
> special gotchas regarding either of these two elements.
> 
> Thanks for your help!
> Jason
> 
> 
> 
> On 02/09/10 4:04 PM, "Jason Untulis" <[EMAIL PROTECTED]> wrote:
> 
> 
>>I'm confused about how xmlcatalogs work. I can't seem to get it to find
>>local DTDs at all, either from files or from jars in the classpath (when
>>using the commented out <dtd> element). The items in the catalog are found
>>correctly (so the public IDs are set correctly), but I can't get it to find
>>the DTDs referenced in the location. The parser will subsequently find the
>>DTD at its defined SYSTEM URL path from the DOCTYPE in the XML file, but it
>>doesn't appear to find it via the xmlcatalog.
>>
>>I've tried paths and locations in the xmlcatalog's classpath element. I've
>>tried adding "./". Unfortunately, -debug doesn't tell you anything about any
>>paths, but I can't see anything wrong with what I currently have defined.
>>
>>I have both the jar file and the DTD file (extracted from the jar file) in
>>the same directory as the build.xml file, as well as the struts-config.xml
>>I'm trying to validate. I tried to simplify it down as much as possible.
>>
>>What am I doing wrong?
>>
>>Thanks!
>>Jason
>>
>>
>>ant 1.5, Sun JDK 1.3.1_04, using the default Xerces parser, default
>>CLASSPATH is empty
>>
>>build.xml:
>><project name="xmlTest" default="validateXML" basedir=".">
>>  <target name="validateXML">
>>      <xmlvalidate lenient="no" failonerror="no">
>>          <fileset dir=".">
>>              <include name="struts-config.xml" />
>>          </fileset>
>>          <xmlcatalog refid="allDTDs" />
>>      </xmlvalidate>
>>  </target>
>>
>>  <xmlcatalog id="allDTDs">
>>      <classpath>
>>          <pathelement location="." />
>>          <pathelement location="struts.jar" />
>>      </classpath>
>><!--         <dtd
>>          publicId="-//Apache Software Foundation//DTD Struts
>>Configuration 1.1//EN"
>>          location="org/apache/struts/resources/struts-config_1_1.dtd"/>
>>-->
>>      <dtd
>>          publicId="-//Apache Software Foundation//DTD Struts
>>Configuration 1.1//EN"
>>          location="struts-config_1_1.dtd"/>
>>  </xmlcatalog>
>></project>
>>
>>
>>command line:
>>
>>$ ant -debug
>>
>>Apache Ant version 1.5 compiled on July 9 2002
>>Buildfile: build.xml
>>Detected Java version: 1.3 in: d:\pkg\jdk1.3.1_04\jre
>>Detected OS: Windows 2000
>>
>>[extraneous user task messages deleted...]
>>
>>Project base dir set to: D:\anttest
>>+Target: validateXML
>> +Task: xmlvalidate
>> +DataType: xmlcatalog
>>Adding reference: allDTDs -> org.apache.tools.ant.types.XMLCatalog@189f84
>>Build sequence for target `validateXML' is [validateXML]
>>Complete build sequence is [validateXML]
>>
>>validateXML:
>>[xmlvalidate] Using SAX2 reader org.apache.xerces.parsers.SAXParser
>>fileset: Setup scanner in dir D:\anttest with patternSet{ includes:
>>[struts-config.xml] excludes: [] }
>>[xmlvalidate] Validating struts-config.xml...
>>resolveEntity: '-//Apache Software Foundation//DTD Struts Configuration
>>1.1//EN': 'http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd'
>>Matching catalog entry found for publicId: '-//Apache Software
>>Foundation//DTD Struts Configuration 1.1//EN' location:
>>'struts-config_1_1.dtd'
>>Couldn't load ResourceStream for struts-config_1_1.dtd
>>No matching catalog entry found, parser will use:
>>'http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd'
>>[xmlvalidate] 1 file(s) have been successfully validated.
>>
>>
>>
>>--
>>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>>
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to