You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Susanne Wunsch <ap...@uriah.heep.sax.de> on 2010/05/10 21:33:59 UTC

xmlvalidate with xmlcatalog

Hello,

I try to use xmlcatalog within xmlvalidate, but ANT doesn't find a
resolver. I looked into the manual, but didn't find any idea for a
proper classpath in my environment. Any help would be appreciated.

I use Apache Ant version 1.7.1 at FreeBSD 8.0

-- Debug messages ------------------------------------------------

resolveEntity: 'null': 'file:/home/filename.xsd'
Apache resolver library not found, internal resolver will be used
Failed to load Apache resolver: java.lang.NoClassDefFoundError: org/apache/xml/resolver/tools/CatalogResolver
No matching catalog entry found, parser will use: 'file:/home/filename.xsd'

-- Ant task ------------------------------------------------------

<xmlvalidate file="filename.xml" failonerror="false"
  classname="org.apache.xerces.parsers.SAXParser">
  <xmlcatalog>
     <classpath>
       <pathelement 
         location="/usr/local/share/java/apache-ant/lib/ant-apache-resolver.jar"/>
     </classpath>
     <entity publicId="http://purl.org/dc/elements/1.1/"
       location="../DC/dc.xsd"/>
  </xmlcatalog>
  <attribute name="http://xml.org/sax/features/validation" value="true"/>
  <attribute name="http://apache.org/xml/features/validation/schema" 
    value="true"/>
  <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
  <attribute name="http://xml.org/sax/features/namespace-prefixes" 
    value="true"/>
</xmlvalidate>
-------------------------------------------------------------------

'location' inside <entity> is a relative path to the projects 'baseDir'.

Thanks for any hints.

read you ...
Susanne 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: xmlvalidate with xmlcatalog

Posted by Susanne Wunsch <ap...@uriah.heep.sax.de>.
Hello Stefan,

Thanks again for the helpful hint.

Stefan Bodewig <bo...@apache.org> writes:

> On 2010-05-11, Susanne Wunsch <ap...@uriah.heep.sax.de> wrote:
>
>> How to use catalog entity with XML Schema?
>
> I must admit I've never tried that.  Looking at the documentation of
> <schemavalidate>[1] - which really just is <xmlvalidate> with sensible
> defaults for XSD validation - it says
>
> ,----
> | Note that nested catalogs are still used for lookup of the URLs given
> | as the sources of schema documents, so you can still delegate lookup
> | to a catalog, you just need to list all schema URIs and their URL
> | equivalents.
> `----

I tried the same task with <schemavalidate> instead of <xmlvalidate>,
but it didn't work with <xmlcatalog> integrated in <schemavalidate>.

Now, I use the nested element <schema> that looks for the namespace.  It
works without any external resolver. It's no OASIS catalog solution, but
that's ok for me. :-)

<schemavalidate file="${xml-file}.xml" 
                classname="org.apache.xerces.parsers.SAXParser">
  <schema namespace="http://purl.org/dc/elements/1.1/"
    file="../DC/dc.xsd"/>
  <schema namespace="http://www.w3.org/XML/1998/namespace"
    file="../xml.xsd"/>
...

read you ...
Susanne 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: xmlvalidate with xmlcatalog

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-05-11, Susanne Wunsch <ap...@uriah.heep.sax.de> wrote:

> Thanks for the link. Now the resolver is loaded, but the catalog
> entities doesn't really fit.

> How to use catalog entity with XML Schema?

I must admit I've never tried that.  Looking at the documentation of
<schemavalidate>[1] - which really just is <xmlvalidate> with sensible
defaults for XSD validation - it says

,----
| Note that nested catalogs are still used for lookup of the URLs given
| as the sources of schema documents, so you can still delegate lookup
| to a catalog, you just need to list all schema URIs and their URL
| equivalents.
`----

> I tried 'namespace' and 'schemaLocation' as PublicId, but it didn't
> work.

Sounds as if the namespace's URI should be used as publicId.

Stefan

[1] http://ant.apache.org/manual/OptionalTasks/schemavalidate.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: xmlvalidate with xmlcatalog

Posted by Susanne Wunsch <ap...@uriah.heep.sax.de>.
Stefan Bodewig <bo...@apache.org> writes:

> On 2010-05-10, Susanne Wunsch <ap...@uriah.heep.sax.de> wrote:
>
>> I try to use xmlcatalog within xmlvalidate, but ANT doesn't find a
>> resolver. I looked into the manual, but didn't find any idea for a
>> proper classpath in my environment. Any help would be appreciated.
>
> Ant's distribution doesn't contain the XML resolver itself, only the
> bridge code needed to use one.  In addition to ant-apache-resolver.jar
> you also need the resolver library of Apache XML Commons
> <http://xml.apache.org/commons/components/resolver/>

Thanks for the link. Now the resolver is loaded, but the catalog
entities doesn't really fit.

How to use catalog entity with XML Schema?

I tried 'namespace' and 'schemaLocation' as PublicId, but it didn't
work.

-- Debug messages -------------------------------------------------

Class org.apache.tools.ant.types.resolver.ApacheCatalogResolver loaded from parent loader (parentFirst)
Apache resolver library found, xml-commons resolver will be used
Using catalogpath ''
...
resolveEntity: 'null': 'http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd'
No matching catalog entry found, parser will use: 'http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd'

-- ANT task -------------------------------------------------------

<xmlvalidate file="${xml-file}.xml" classname="org.apache.xerces.parsers.SAXParser">
  <xmlcatalog>
     <classpath>
       <pathelement location="/usr/local/share/java/apache-ant/lib/ant-apache-resolver.jar"/>
     </classpath>
     <entity publicId="http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd"
      location="../DC/dc.xsd"/>
  </xmlcatalog>
  <attribute name="http://xml.org/sax/features/validation" value="true"/>
  <attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
  <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
  <attribute name="http://xml.org/sax/features/namespace-prefixes" value="true"/>
</xmlvalidate>

--------------------------------------------------------------------

read you ...
Susanne 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: xmlvalidate with xmlcatalog

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-05-10, Susanne Wunsch <ap...@uriah.heep.sax.de> wrote:

> I try to use xmlcatalog within xmlvalidate, but ANT doesn't find a
> resolver. I looked into the manual, but didn't find any idea for a
> proper classpath in my environment. Any help would be appreciated.

Ant's distribution doesn't contain the XML resolver itself, only the
bridge code needed to use one.  In addition to ant-apache-resolver.jar
you also need the resolver library of Apache XML Commons
<http://xml.apache.org/commons/components/resolver/>

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org