You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by WULMS Alex <Al...@swift.com> on 2013/04/25 15:05:08 UTC

Ant xslt task seems to ignore xmlcatalog for mapping dtds

Hi,

I'm trying to use the xslt task in Ant to validate some xhtml files. The xhtml files start with a <!DOCTYPE ...> line to indicate the xhtml version. The doctype refers a DTD, like in following example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  xmlns:h="http://java.sun.com/jsf/html">
<h:head>
</h:head>
<h:body>
</h:body>
</html>

The xslt task tries to connect to www.w3.org to fetch the dtd. But I'm behind a firewall so that fails. When I run ant with -v, I get amongst others following message in the stack trace:

java.net.UnknownHostException: www.w3.org
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:529)
	at java.net.Socket.connect(Socket.java:478)
... some stuff about HttpClient and HttpURLConnection
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1315)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1282)
...

I have read about the xmlcatalog element that can be used to map the dtd-id to a local file. I have tried to set it up as follows:

  <xmlcatalog id="xhtmlDTDs">
	  <dtd publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" location="${product.home}/dtd/xhtml1-transitional.dtd"/>
  </xmlcatalog>
	
  <target name="validate-xhtml">
  	<mkdir dir="${module.home}/validate-xhtml-rslt}"/>
  	<xslt 
  		basedir="${module.home}/src/webroot" 
  		destdir="${module.home}/validate-xhtml-rslt" 
  		style="${module.home}/validate-xhtml.xslt"
  		includes="**/alex.xhtml"
  	>
  		<xmlcatalog refid="xhtmlDTDs" />
  		<mapper type="glob" from="*.xhtml" to="*.html"/>
  	</xslt>
  </target>

But despite the xmlcatalog being defined, I still get the very same exception.

Note that I'm using ant 1.7.1 which is bundled with eclipse and I'm running it with a JRE 1.6.0.22. I have also added resolver.jar from apache xml-commons to the classpath but it does not help neither.

Note that this is the output from ant with -v option:
validate-xhtml:
    [mkdir] Skipping P:\srcSDC\idm\modules\identitypublicweb\validate-xhtml-rslt} because it already exists.
     [xslt] Using class org.apache.tools.ant.taskdefs.optional.TraXLiaison
     [xslt] Transforming into P:\srcSDC\idm\modules\identitypublicweb\validate-xhtml-rslt
     [xslt] Processing P:\srcSDC\idm\modules\identitypublicweb\src\webroot\alex.xhtml to P:\srcSDC\idm\modules\identitypublicweb\validate-xhtml-rslt\alex.html
     [xslt] Loading stylesheet P:\srcSDC\idm\modules\identitypublicweb\validate-xhtml.xslt
Apache resolver library found, xml-commons resolver will be used
     [xslt] : Error! www.w3.org
     [xslt] : Error! com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: www.w3.org
     [xslt] Failed to process null

After that comes the stacktrace with the host not found exception


Any help or hints in fixing this are appreciated.

Thanks and kind regards,
Alex




Alex Wulms
SWIFT | Lead Developer / E-channel 
Tel: +32 2 6553931
www.swift.com

This e-mail and any attachments thereto may contain information which is confidential and/or proprietary and intended for the sole use of the recipient(s) named above. If you have received this e-mail in error, please immediately notify the sender and delete the mail.  Thank you for your co-operation.  SWIFT reserves the right to retain e-mail messages on its systems and, under circumstances permitted by applicable law, to monitor and intercept e-mail messages to and from its systems.



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