本文整理汇总了Java中com.sun.org.apache.xml.internal.utils.SystemIDResolver.getAbsoluteURI方法的典型用法代码示例。如果您正苦于以下问题:Java SystemIDResolver.getAbsoluteURI方法的具体用法?Java SystemIDResolver.getAbsoluteURI怎么用?Java SystemIDResolver.getAbsoluteURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xml.internal.utils.SystemIDResolver
的用法示例。
在下文中一共展示了SystemIDResolver.getAbsoluteURI方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveURI
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* This will be called by the processor when it encounters
* an xsl:include, xsl:import, or document() function.
*
* @param base The base URI that should be used.
* @param urlString Value from an xsl:import or xsl:include's href attribute,
* or a URI specified in the document() function.
*
* @return a Source that can be used to process the resource.
*
* @throws IOException
* @throws TransformerException
*/
public Source resolveURI(
String base, String urlString, SourceLocator locator)
throws TransformerException, IOException
{
Source source = null;
if (null != m_uriResolver)
{
source = m_uriResolver.resolve(urlString, base);
}
if (null == source)
{
String uri = SystemIDResolver.getAbsoluteURI(urlString, base);
source = new StreamSource(uri);
}
return source;
}
示例2: retrieveDocument
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* 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);
}
}
示例3: unparsedEntityDecl
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* Receive notification of an unparsed entity declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to keep track of the unparsed entities
* declared in a document.</p>
*
* @param name The entity name.
* @param publicId The entity public identifier, or null if not
* available.
* @param systemId The entity system identifier.
* @param notationName The name of the associated notation.
* @throws SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DTDHandler#unparsedEntityDecl
*
* @throws SAXException
*/
public void unparsedEntityDecl(String name, String publicId, String systemId,
String notationName) throws SAXException
{
if (null == m_entities) {
m_entities = new ArrayList<>();
}
try {
systemId = SystemIDResolver.getAbsoluteURI(systemId,
getDocumentBaseURI());
} catch (Exception e) {
throw new SAXException(e);
}
// private static final int ENTITY_FIELD_PUBLICID = 0;
m_entities.add(publicId);
// private static final int ENTITY_FIELD_SYSTEMID = 1;
m_entities.add(systemId);
// private static final int ENTITY_FIELD_NOTATIONNAME = 2;
m_entities.add(notationName);
// private static final int ENTITY_FIELD_NAME = 3;
m_entities.add(name);
}
示例4: unparsedEntityDecl
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* Receive notification of an unparsed entity declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to keep track of the unparsed entities
* declared in a document.</p>
*
* @param name The entity name.
* @param publicId The entity public identifier, or null if not
* available.
* @param systemId The entity system identifier.
* @param notationName The name of the associated notation.
* @throws SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DTDHandler#unparsedEntityDecl
*
* @throws SAXException
*/
public void unparsedEntityDecl(
String name, String publicId, String systemId, String notationName)
throws SAXException
{
if (null == m_entities)
{
m_entities = new Vector();
}
try
{
systemId = SystemIDResolver.getAbsoluteURI(systemId,
getDocumentBaseURI());
}
catch (Exception e)
{
throw new org.xml.sax.SAXException(e);
}
// private static final int ENTITY_FIELD_PUBLICID = 0;
m_entities.addElement(publicId);
// private static final int ENTITY_FIELD_SYSTEMID = 1;
m_entities.addElement(systemId);
// private static final int ENTITY_FIELD_NOTATIONNAME = 2;
m_entities.addElement(notationName);
// private static final int ENTITY_FIELD_NAME = 3;
m_entities.addElement(name);
}
示例5: retrieveDocument
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* 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
*/
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);
}
}
示例6: retrieveDocument
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* 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());
}
示例7: setSystemId
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
public void setSystemId(String systemId) {
if (systemId != null) {
_systemId = SystemIDResolver.getAbsoluteURI(systemId);
}
}
示例8: retrieveDocument
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* 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);
}
}
示例9: retrieveDocument
import com.sun.org.apache.xml.internal.utils.SystemIDResolver; //导入方法依赖的package包/类
/**
* Returns a document either by finding it in the cache or
* downloading it and putting it in the cache.
*/
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());
}