[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Xalan XSLT transformation using XML Catalog

Subject: [xsl] Xalan XSLT transformation using XML Catalog
From: Ivan.Price@xxxxxxxxx
Date: Tue, 18 Jan 2005 16:39:51 +0930

Hi there,

I've been trying to get a Xalan XSLT transformation working with an XML 
catalog for a while now.

After reading around about the (newer version) classes needing to be in 
the jre/lib/endorsed directory (e.g. 
http://www.laurenwood.org/anyway/index.php?p=16) I have successfully 
gotten the following to work using Xalan 2.6.2 and the jdk 1.4:

java   org.apache.xalan.xslt.Process  -ENTITYRESOLVER 
org.apache.xml.resolver.tools.CatalogResolver -URIRESOLVER 
org.apache.xml.resolver.tools.CatalogResolver -out out.xml -in dd/in.xml 
-xsl the.xsl

The catalog is invoked and everything works fine. However, for scalability 
and reusability I am trying to build this into a class (i.e. no have to 
start this process 100 times for 100 xmls) and have written a little java 
class containing:

import org.apache.xml.resolver.tools.CatalogResolver;
import java.util.Properties;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

                TransformerFactory tFactory = 
                CatalogResolver resolver = new CatalogResolver();
                Transformer transformer = tFactory.newTransformer(new 
                transformer.transform(new StreamSource(xmlFile), new 
StreamResult(new FileOutputStream(outFile)));

The catalog resolver sucessfully initialises.. i get the :
Parse catalog: file:/xxx/catalog.xml
Loading catalog: file:/xxx/catalog.xml
Default BASE: file:/xxx/catalog.xml
override: yes

but it is never invoked during the parse of the input file, instead the 
transformer returns all sorts of http server errors and parse errors as it 
tries to get the (often missing/broken) dtds and entities. Note these are 
the same input files as are being successfully resolved using the command 
line method. Should there be an entity method on the transformer?

What is the point of the  tFactory.setURIResolver(resolver); method ? is 
this a bug or am I misusing it ?

I would rather the transformer not validate the XML before transforming 
it, allowing me to validate the result and reject the file at that stage 
if i choose to.

Thanks in advance..


Ivan Price
Department of Infrastructure, Planning and Environment
Northern Territory Government
Tel: (08) 8924 4024
Fax: (08) 8924 4045
Email: ivan.price@xxxxxxxxx

Current Thread