org.apache.xpath
Class SourceTreeManager
java.lang.Object
org.apache.xpath.SourceTreeManager
public class SourceTreeManager
extends java.lang.Object
This class bottlenecks all management of source trees. The methods
in this class should allow easy garbage collection of source
trees (not yet!), and should centralize parsing for those source trees.
String | findURIFromDoc(int owner) - Given a document, find the URL associated with that document.
|
int | getNode(Source source) - Given a Source object, find the node associated with it.
|
int | getSourceTree(String base, String urlString, SourceLocator locator, XPathContext xctxt) - Get the source tree from the a base URL and a URL string.
|
int | getSourceTree(Source source, SourceLocator locator, XPathContext xctxt) - Get the source tree from the input source.
|
URIResolver | getURIResolver() - Get the object that will be used to resolve URIs used in
document(), etc.
|
static XMLReader | getXMLReader(Source inputSource, SourceLocator locator) - This method returns the SAX2 parser to use with the InputSource
obtained from this URI.
|
int | parseToNode(Source source, SourceLocator locator, XPathContext xctxt) - Try to create a DOM source tree from the input source.
|
void | putDocumentInCache(int n, Source source) - Put the source tree root node in the document cache.
|
void | removeDocumentFromCache(int n) - JJK: Support <?
|
void | reset() - Reset the list of SourceTree objects that this manager manages.
|
Source | resolveURI(String base, String urlString, SourceLocator locator) - This will be called by the processor when it encounters
an xsl:include, xsl:import, or document() function.
|
void | setURIResolver(URIResolver resolver) - Set an object that will be used to resolve URIs used in
document(), etc.
|
findURIFromDoc
public String findURIFromDoc(int owner)
Given a document, find the URL associated with that document.
owner
- Document that was previously processed by this liaison.
- The base URI of the owner argument.
getNode
public int getNode(Source source)
Given a Source object, find the node associated with it.
source
- The Source object to act as the key.
- The node that is associated with the Source, or null if not found.
getSourceTree
public int getSourceTree(String base,
String urlString,
SourceLocator locator,
XPathContext xctxt)
throws TransformerException
Get the source tree from the a base URL and a URL string.
base
- The base URI to use if the urlString is relative.urlString
- An absolute or relative URL string.locator
- The location of the caller, for diagnostic purposes.
- should be a non-null reference to the node identified by the
base and urlString.
TransformerException
- If the URL can not resolve to a node.
getSourceTree
public int getSourceTree(Source source,
SourceLocator locator,
XPathContext xctxt)
throws TransformerException
Get the source tree from the input source.
source
- The Source object that should identify the desired node.locator
- The location of the caller, for diagnostic purposes.
- non-null reference to a node.
TransformerException
- if the Source argument can't be resolved to
a node.
getURIResolver
public URIResolver getURIResolver()
Get the object that will be used to resolve URIs used in
document(), etc.
- An object that implements the URIResolver interface,
or null.
getXMLReader
public static XMLReader getXMLReader(Source inputSource,
SourceLocator locator)
throws TransformerException
This method returns the SAX2 parser to use with the InputSource
obtained from this URI.
It may return null if any SAX2-conformant XML parser can be used,
or if getInputSource() will also return null. The parser must
be free for use (i.e.
not currently in use for another parse().
inputSource
- The value returned from the URIResolver.locator
- The location of the original caller, for diagnostic purposes.
- non-null XMLReader reference ready to parse.
TransformerException
- if the reader can not be created.
parseToNode
public int parseToNode(Source source,
SourceLocator locator,
XPathContext xctxt)
throws TransformerException
Try to create a DOM source tree from the input source.
source
- The Source object that identifies the source node.locator
- The location of the caller, for diagnostic purposes.
- non-null reference to node identified by the source argument.
TransformerException
- if the source argument can not be resolved
to a source node.
putDocumentInCache
public void putDocumentInCache(int n,
Source source)
Put the source tree root node in the document cache.
TODO: This function needs to be a LOT more sophisticated.
n
- The node to cache.source
- The Source object to cache.
removeDocumentFromCache
public void removeDocumentFromCache(int n)
JJK: Support <?xalan:doc_cache_off?> kluge in ElemForEach.
TODO: This function is highly dangerous. Cache management must be improved.
n
- The node to remove.
reset
public void reset()
Reset the list of SourceTree objects that this manager manages.
resolveURI
public Source resolveURI(String base,
String urlString,
SourceLocator locator)
throws TransformerException,
IOException
This will be called by the processor when it encounters
an xsl:include, xsl:import, or document() function.
base
- The base URI that should be used.urlString
- Value from an xsl:import or xsl:include's href attribute,
or a URI specified in the document() function.
- a Source that can be used to process the resource.
TransformerException
-
setURIResolver
public void setURIResolver(URIResolver resolver)
Set an object that will be used to resolve URIs used in
document(), etc.
resolver
- An object that implements the URIResolver interface,
or null.
Copyright B) 2004 Apache XML Project. All Rights Reserved.