[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Xalan XSLT transformation using XML Catalog

Subject: Xalan XSLT transformation using XML Catalog
From: Ivan.Price@xxxxxxxxx
Date: Tue, 18 Jan 2005 16:39:51 +0930
ivan price
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 = 
TransformerFactory.newInstance();
                CatalogResolver resolver = new CatalogResolver();
                tFactory.setURIResolver(resolver);
                Transformer transformer = tFactory.newTransformer(new 
StreamSource(xslFile));
                transformer.setURIResolver(resolver);
                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
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

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.