Java Code Examples for com.sun.org.apache.xml.internal.utils.SystemIDResolver#getAbsoluteURI()

The following examples show how to use com.sun.org.apache.xml.internal.utils.SystemIDResolver#getAbsoluteURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformerImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This class should only be used as a DOMCache for the translet if the
 * URIResolver has been set.
 *
 * The method implements XSLTC's DOMCache interface, which is used to
 * plug in an external document loader into a translet. This method acts
 * as an adapter between TrAX's URIResolver interface and XSLTC's
 * DOMCache interface. This approach is simple, but removes the
 * possibility of using external document caches with XSLTC.
 *
 * @param baseURI The base URI used by the document call.
 * @param href The href argument passed to the document function.
 * @param translet A reference to the translet requesting the document
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet translet) {
    try {
        // Argument to document function was: document('');
        if (href.length() == 0) {
            href = baseURI;
        }

        /*
         *  Fix for bug 24188
         *  Incase the _uriResolver.resolve(href,base) is null
         *  try to still  retrieve the document before returning null
         *  and throwing the FileNotFoundException in
         *  com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument
         *
         */
        Source resolvedSource = _uriResolver.resolve(href, baseURI);
        if (resolvedSource == null)  {
            StreamSource streamSource = new StreamSource(
                 SystemIDResolver.getAbsoluteURI(href, baseURI));
            return getDOM(streamSource) ;
        }

        return getDOM(resolvedSource);
    }
    catch (TransformerException e) {
        if (_errorListener != null)
            postErrorToListener("File not found: " + e.getMessage());
        return(null);
    }
}
 
Example 2
Source File: TransformerImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This class should only be used as a DOMCache for the translet if the
 * URIResolver has been set.
 *
 * The method implements XSLTC's DOMCache interface, which is used to
 * plug in an external document loader into a translet. This method acts
 * as an adapter between TrAX's URIResolver interface and XSLTC's
 * DOMCache interface. This approach is simple, but removes the
 * possibility of using external document caches with XSLTC.
 *
 * @param baseURI The base URI used by the document call.
 * @param href The href argument passed to the document function.
 * @param translet A reference to the translet requesting the document
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet translet) {
    try {
        // Argument to document function was: document('');
        if (href.length() == 0) {
            href = baseURI;
        }

        /*
         *  Fix for bug 24188
         *  Incase the _uriResolver.resolve(href,base) is null
         *  try to still  retrieve the document before returning null
         *  and throwing the FileNotFoundException in
         *  com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument
         *
         */
        Source resolvedSource = _uriResolver.resolve(href, baseURI);
        if (resolvedSource == null)  {
            StreamSource streamSource = new StreamSource(
                 SystemIDResolver.getAbsoluteURI(href, baseURI));
            return getDOM(streamSource) ;
        }

        return getDOM(resolvedSource);
    }
    catch (TransformerException e) {
        if (_errorListener != null)
            postErrorToListener("File not found: " + e.getMessage());
        return(null);
    }
}
 
Example 3
Source File: TransformerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * This class should only be used as a DOMCache for the translet if the
 * URIResolver has been set.
 *
 * The method implements XSLTC's DOMCache interface, which is used to
 * plug in an external document loader into a translet. This method acts
 * as an adapter between TrAX's URIResolver interface and XSLTC's
 * DOMCache interface. This approach is simple, but removes the
 * possibility of using external document caches with XSLTC.
 *
 * @param baseURI The base URI used by the document call.
 * @param href The href argument passed to the document function.
 * @param translet A reference to the translet requesting the document
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet translet) {
    try {
        // Argument to document function was: document('');
        if (href.length() == 0) {
            href = baseURI;
        }

        /*
         *  Fix for bug 24188
         *  Incase the _uriResolver.resolve(href,base) is null
         *  try to still  retrieve the document before returning null
         *  and throwing the FileNotFoundException in
         *  com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument
         *
         */
        Source resolvedSource = _uriResolver.resolve(href, baseURI);
        if (resolvedSource == null)  {
            StreamSource streamSource = new StreamSource(
                 SystemIDResolver.getAbsoluteURI(href, baseURI));
            return getDOM(streamSource) ;
        }

        return getDOM(resolvedSource);
    }
    catch (TransformerException e) {
        if (_errorListener != null)
            postErrorToListener("File not found: " + e.getMessage());
        return(null);
    }
}
 
Example 4
Source File: Stylesheet.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}
 
Example 5
Source File: TransformerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This class should only be used as a DOMCache for the translet if the
 * URIResolver has been set.
 *
 * The method implements XSLTC's DOMCache interface, which is used to
 * plug in an external document loader into a translet. This method acts
 * as an adapter between TrAX's URIResolver interface and XSLTC's
 * DOMCache interface. This approach is simple, but removes the
 * possibility of using external document caches with XSLTC.
 *
 * @param baseURI The base URI used by the document call.
 * @param href The href argument passed to the document function.
 * @param translet A reference to the translet requesting the document
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet translet) {
    try {
        // Argument to document function was: document('');
        if (href.length() == 0) {
            href = baseURI;
        }

        /*
         *  Fix for bug 24188
         *  Incase the _uriResolver.resolve(href,base) is null
         *  try to still  retrieve the document before returning null
         *  and throwing the FileNotFoundException in
         *  com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument
         *
         */
        Source resolvedSource = null;
        if (_uriResolver != null) {
            resolvedSource = _uriResolver.resolve(href, baseURI);
        }

        if (resolvedSource == null && _useCatalog &&
                _catalogFeatures.get(CatalogFeatures.Feature.FILES) != null)  {
            if (_catalogUriResolver == null) {
                _catalogUriResolver = CatalogManager.catalogResolver(_catalogFeatures);
            }
            resolvedSource = _catalogUriResolver.resolve(href, baseURI);
        }

        if (resolvedSource == null)  {
            StreamSource streamSource = new StreamSource(
                 SystemIDResolver.getAbsoluteURI(href, baseURI));
            return getDOM(streamSource) ;
        }

        return getDOM(resolvedSource);
    }
    catch (TransformerException | CatalogException e) {
        if (_errorListener != null)
            postErrorToListener("File not found: " + e.getMessage());
        return(null);
    }
}
 
Example 6
Source File: TransformerImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * This class should only be used as a DOMCache for the translet if the
 * URIResolver has been set.
 *
 * The method implements XSLTC's DOMCache interface, which is used to
 * plug in an external document loader into a translet. This method acts
 * as an adapter between TrAX's URIResolver interface and XSLTC's
 * DOMCache interface. This approach is simple, but removes the
 * possibility of using external document caches with XSLTC.
 *
 * @param baseURI The base URI used by the document call.
 * @param href The href argument passed to the document function.
 * @param translet A reference to the translet requesting the document
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet translet) {
    try {
        // Argument to document function was: document('');
        if (href.length() == 0) {
            href = baseURI;
        }

        /*
         *  Fix for bug 24188
         *  Incase the _uriResolver.resolve(href,base) is null
         *  try to still  retrieve the document before returning null
         *  and throwing the FileNotFoundException in
         *  com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument
         *
         */
        Source resolvedSource = null;
        if (_uriResolver != null) {
            resolvedSource = _uriResolver.resolve(href, baseURI);
        }

        if (resolvedSource == null && _useCatalog &&
                _catalogFeatures.get(CatalogFeatures.Feature.FILES) != null)  {
            if (_catalogUriResolver == null) {
                _catalogUriResolver = CatalogManager.catalogResolver(_catalogFeatures);
            }
            resolvedSource = _catalogUriResolver.resolve(href, baseURI);
        }

        if (resolvedSource == null)  {
            StreamSource streamSource = new StreamSource(
                 SystemIDResolver.getAbsoluteURI(href, baseURI));
            return getDOM(streamSource) ;
        }

        return getDOM(resolvedSource);
    }
    catch (TransformerException | CatalogException e) {
        if (_errorListener != null)
            postErrorToListener("File not found: " + e.getMessage());
        return(null);
    }
}
 
Example 7
Source File: Stylesheet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}
 
Example 8
Source File: DocumentCache.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 9
Source File: Stylesheet.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}
 
Example 10
Source File: Stylesheet.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}
 
Example 11
Source File: DocumentCache.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 12
Source File: DocumentCache.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 13
Source File: Stylesheet.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}
 
Example 14
Source File: DocumentCache.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 15
Source File: Stylesheet.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}
 
Example 16
Source File: DocumentCache.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 17
Source File: Stylesheet.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}
 
Example 18
Source File: DocumentCache.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 19
Source File: DocumentCache.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 20
Source File: Stylesheet.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void setSystemId(String systemId) {
    if (systemId != null) {
        _systemId = SystemIDResolver.getAbsoluteURI(systemId);
    }
}