[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Xalan XSLT transformation using XML Catalog
Subject: RE: [xsl] Xalan XSLT transformation using XML Catalog From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 18 Jan 2005 09:56:36 -0000 |
The URIResolver handles URIs appearing at the XSLT level, the EntityResolver does the same for URIs appearing at the XML level. In your command line you set both; in your Java application you have set the URIResolver but not the EntityResolver. To set an EntityResolver from a Java application, you need to create a SAXSource rather than a stream source, to instantiate your own XMLReader (the SAX parser), set the EntityResolver on the XMLReader, and then do saxSource.setXMLReader(). Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Ivan.Price@xxxxxxxxx [mailto:Ivan.Price@xxxxxxxxx] > Sent: 18 January 2005 07:10 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Xalan XSLT transformation using XML Catalog > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Xalan XSLT transformation usi, Ivan . Price | Thread | [xsl] generating numerical characte, Rossella Rosin |
RE: [xsl] selecting HTML Options, Michael Kay | Date | [xsl] generating numerical characte, Rossella Rosin |
Month |