You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dan Sanderson <li...@dansanderson.com> on 2006/03/08 00:04:04 UTC

Ant, Xerces 2.8.0, and XInclude

Hi all -

I have two questions regarding Ant, Xerces 2, and XInclude.  I'm using Ant 
1.6.5, and have upgraded its xercesImpl.jar and xml-apis.jar 
to Xerces 2.8.0.

The first question is regarding XmlValidate.  My understanding is that I 
can turn on the XInclude feature with an <attribute> in the <xmlvalidate> 
task:

  <attribute name="http://apache.org/xml/features/xinclude" value="true" />

When I try to validate, however, it fails on the <include> elements, as if 
XInclude were not working.

My first guess was that I wasn't turning on the feature correctly, but I 
noticed this in the Xerces 2 FAQ:  "If the validation feature is turned on 
then DTD validation will be performed on each source document (to the 
XInclude processor) against their respective DTDs."

My Ant target for validation:

   <target
       name="validate-xerces"
       >
     <java classname="org.apache.xerces.impl.Version" />
     <xmlvalidate
 	failonerror="yes"
 	warn="yes"
 	lenient="no">
       <attribute name="http://apache.org/xml/features/xinclude" 
value="true" />
       <xmlcatalog>
 	<catalogpath>
 	  <pathelement location="../schemas/docbook-4.4/catalog.xml"/>
 	</catalogpath>
       </xmlcatalog>
       <fileset
 	  dir="${book.dir}"
 	  includes="${book.file}" />
     </xmlvalidate>
   </target>

Is my task defined correctly to turn on XInclude?  Is Xerces refusing to 
do XInclude prior to DTD validation as a normal behavior?  What is the 
correct way for me to perform DTD validation with a document that uses 
XInclude?  (Must my DTD explicitly accommodate XInclude?)


My second question is regarding the Xslt task.  I would like to turn on 
the same Xerces feature for the purposes of XSLT processing (with Xalan). 
I'm not clear on how to do this.  I tried:

   <target
       name="xslt-xerces"
       description="test XSLT with Xerces XInclude"
       >
     <java classname="org.apache.xerces.impl.Version" />
     <xslt
 	in="${book.dir}/${book.file}"
 	out="${temp.dir}/test-xsl-out.txt"
 	style="test.xsl"
 	>
       <factory>
 	<attribute name="http://apache.org/xml/features/xinclude" 
value="true" />
       </factory>
     </xslt>
   </target>

but got:

BUILD FAILED
/workplace/sandersd/Projects/NewAWSDocTools/AWSDocTools/tools/TEMP/build.xml:89: 
java.lang.IllegalArgumentException: Not supported: 
http://apache.org/xml/features/xinclude

What is the correct way to turn on XInclude with Xerces with the Xslt 
task?


Thanks for any assistance you can provide!  Let me know if I should post 
more complete examples.

-- Dan


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


Re: Ant, Xerces 2.8.0, and XInclude

Posted by Steve Loughran <st...@apache.org>.
Dan Sanderson wrote:
> Hi all -
> 
> I have two questions regarding Ant, Xerces 2, and XInclude.  I'm using 
> Ant 1.6.5, and have upgraded its xercesImpl.jar and xml-apis.jar to 
> Xerces 2.8.0.
> 
> The first question is regarding XmlValidate.  My understanding is that I 
> can turn on the XInclude feature with an <attribute> in the 
> <xmlvalidate> task:
> 
>  <attribute name="http://apache.org/xml/features/xinclude" value="true" />
> 
> When I try to validate, however, it fails on the <include> elements, as 
> if XInclude were not working.
> 
> My first guess was that I wasn't turning on the feature correctly, but I 
> noticed this in the Xerces 2 FAQ:  "If the validation feature is turned 
> on then DTD validation will be performed on each source document (to the 
> XInclude processor) against their respective DTDs."
> 
> My Ant target for validation:
> 
>   <target
>       name="validate-xerces"
>       >
>     <java classname="org.apache.xerces.impl.Version" />
>     <xmlvalidate
>     failonerror="yes"
>     warn="yes"
>     lenient="no">
>       <attribute name="http://apache.org/xml/features/xinclude" 
> value="true" />
>       <xmlcatalog>
>     <catalogpath>
>       <pathelement location="../schemas/docbook-4.4/catalog.xml"/>
>     </catalogpath>
>       </xmlcatalog>
>       <fileset
>       dir="${book.dir}"
>       includes="${book.file}" />
>     </xmlvalidate>
>   </target>
> 
> Is my task defined correctly to turn on XInclude?  Is Xerces refusing to 
> do XInclude prior to DTD validation as a normal behavior?  What is the 
> correct way for me to perform DTD validation with a document that uses 
> XInclude?  (Must my DTD explicitly accommodate XInclude?)
> 
> 
> My second question is regarding the Xslt task.  I would like to turn on 
> the same Xerces feature for the purposes of XSLT processing (with 
> Xalan). I'm not clear on how to do this.  I tried:
> 
>   <target
>       name="xslt-xerces"
>       description="test XSLT with Xerces XInclude"
>       >
>     <java classname="org.apache.xerces.impl.Version" />
>     <xslt
>     in="${book.dir}/${book.file}"
>     out="${temp.dir}/test-xsl-out.txt"
>     style="test.xsl"
>     >
>       <factory>
>     <attribute name="http://apache.org/xml/features/xinclude" 
> value="true" />
>       </factory>
>     </xslt>
>   </target>
> 
> but got:
> 
> BUILD FAILED
> /workplace/sandersd/Projects/NewAWSDocTools/AWSDocTools/tools/TEMP/build.xml:89: 
> java.lang.IllegalArgumentException: Not supported: 
> http://apache.org/xml/features/xinclude
> 
> What is the correct way to turn on XInclude with Xerces with the Xslt task?
> 
> 
> Thanks for any assistance you can provide!  Let me know if I should post 
> more complete examples.
> 

I think you are pushing the envelope with what the xml tasks do, so 
there is no guarantee that things will work as expected.

Do make sure that you are using xalan for <xslt>, and not anything built 
into the JVM; there is a processor attribute in <Xslt> for that; the 
classname attribute in <xmlvalidate>.

Other than that, you are probably on your own, though patches to fix 
things are welcome. Know that Ant1.7's version of xmlvalidate was 
tweaked to create a new parser for every file on a bulk validate, as the 
one parser-many-files process didnt work for XSD validation.

-steve

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