Search in sources :

Example 1 with XMLCatalog

use of org.apache.tools.ant.types.XMLCatalog in project ant by apache.

the class TraXLiaison method configure.

/**
 * Specific configuration for the TRaX liaison.
 * @param xsltTask the XSLTProcess task instance from which this liaison
 *        is to be configured.
 */
public void configure(final XSLTProcess xsltTask) {
    project = xsltTask.getProject();
    final XSLTProcess.Factory factory = xsltTask.getFactory();
    if (factory != null) {
        setFactory(factory.getName());
        // configure factory attributes
        for (final XSLTProcess.Factory.Attribute attr : Collections.list(factory.getAttributes())) {
            setAttribute(attr.getName(), attr.getValue());
        }
        for (final XSLTProcess.Factory.Feature feature : factory.getFeatures()) {
            setFeature(feature.getName(), feature.getValue());
        }
    }
    final XMLCatalog xmlCatalog = xsltTask.getXMLCatalog();
    // use XMLCatalog as the entity resolver and URI resolver
    if (xmlCatalog != null) {
        setEntityResolver(xmlCatalog);
        setURIResolver(xmlCatalog);
    }
    // configure output properties
    for (final XSLTProcess.OutputProperty prop : Collections.list(xsltTask.getOutputProperties())) {
        setOutputProperty(prop.getName(), prop.getValue());
    }
    suppressWarnings = xsltTask.getSuppressWarnings();
    traceConfiguration = xsltTask.getTraceConfiguration();
}
Also used : XMLCatalog(org.apache.tools.ant.types.XMLCatalog) SAXParserFactory(javax.xml.parsers.SAXParserFactory) TransformerFactory(javax.xml.transform.TransformerFactory) XSLTProcess(org.apache.tools.ant.taskdefs.XSLTProcess)

Example 2 with XMLCatalog

use of org.apache.tools.ant.types.XMLCatalog in project ant by apache.

the class ApacheCatalogResolver method parseCatalog.

/**
 * XMLCatalog calls this to add an external catalog file for each
 * file within a <code>&lt;catalogfiles&gt;</code> fileset.
 * @param file the external catalog file.
 */
public void parseCatalog(final String file) {
    final Catalog catalog = getCatalog();
    if (!(catalog instanceof ApacheCatalog)) {
        throw new BuildException("Wrong catalog type found: %s", catalog.getClass().getName());
    }
    final ApacheCatalog apacheCatalog = (ApacheCatalog) catalog;
    // Pass in reference to ourselves so we can be called back.
    apacheCatalog.setResolver(this);
    try {
        apacheCatalog.parseCatalog(file);
    } catch (IOException ex) {
        throw new BuildException(ex);
    }
}
Also used : BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) XMLCatalog(org.apache.tools.ant.types.XMLCatalog) Catalog(org.apache.xml.resolver.Catalog)

Aggregations

XMLCatalog (org.apache.tools.ant.types.XMLCatalog)2 IOException (java.io.IOException)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 BuildException (org.apache.tools.ant.BuildException)1 XSLTProcess (org.apache.tools.ant.taskdefs.XSLTProcess)1 Catalog (org.apache.xml.resolver.Catalog)1