/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SourceTreeManager.java,v 1.2.4.1 2005/09/10 18:14:09 jeffsuttor Exp $
*/
/**
* 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.
*/
public class SourceTreeManager
{
/** Vector of SourceTree objects that this manager manages. */
/**
* Reset the list of SourceTree objects that this manager manages.
*
*/
public void reset()
{
m_sourceTree = new Vector();
}
/** The TrAX URI resolver used to obtain source trees. */
/**
* Set an object that will be used to resolve URIs used in
* document(), etc.
* @param resolver An object that implements the URIResolver interface,
* or null.
*/
{
}
/**
* Get the object that will be used to resolve URIs used in
* document(), etc.
* @return An object that implements the URIResolver interface,
* or null.
*/
{
return m_uriResolver;
}
/**
* Given a document, find the URL associated with that document.
* @param owner Document that was previously processed by this liaison.
*
* @return The base URI of the owner argument.
*/
{
int n = m_sourceTree.size();
for (int i = 0; i < n; i++)
{
}
return null;
}
/**
* 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
*/
throws TransformerException, IOException
{
if (null != m_uriResolver)
{
}
{
}
return source;
}
/** JJK: Support <?xalan:doc_cache_off?> kluge in ElemForEach.
* TODO: This function is highly dangerous. Cache management must be improved.
*
* @param n The node to remove.
*/
public void removeDocumentFromCache(int n)
{
return;
{
{
return;
}
}
}
/**
* Put the source tree root node in the document cache.
* TODO: This function needs to be a LOT more sophisticated.
*
* @param n The node to cache.
* @param source The Source object to cache.
*/
{
{
if (!(cachedNode == n))
throw new RuntimeException(
"Programmer's Error! "
+ "putDocumentInCache found reparse of doc: "
+ source.getSystemId());
return;
}
{
}
}
/**
* Given a Source object, find the node associated with it.
*
* @param source The Source object to act as the key.
*
* @return The node that is associated with the Source, or null if not found.
*/
{
// if (source instanceof DOMSource)
// return ((DOMSource) source).getNode();
// TODO: Not sure if the BaseID is really the same thing as the ID.
int n = m_sourceTree.size();
// System.out.println("getNode: "+n);
for (int i = 0; i < n; i++)
{
// System.out.println("getNode - url: "+url);
// System.out.println("getNode - sTree.m_url: "+sTree.m_url);
}
// System.out.println("getNode - returning: "+node);
}
/**
* Get the source tree from the a base URL and a URL string.
*
* @param base The base URI to use if the urlString is relative.
* @param urlString An absolute or relative URL string.
* @param locator The location of the caller, for diagnostic purposes.
*
* @return should be a non-null reference to the node identified by the
* base and urlString.
*
* @throws TransformerException If the URL can not resolve to a node.
*/
public int getSourceTree(
throws TransformerException
{
// System.out.println("getSourceTree");
try
{
// System.out.println("getSourceTree - base: "+base+", urlString: "+urlString+", source: "+source.getSystemId());
}
catch (IOException ioe)
{
}
/* catch (TransformerException te)
{
throw new TransformerException(te.getMessage(), locator, te);
}*/
}
/**
* Get the source tree from the input source.
*
* @param source The Source object that should identify the desired node.
* @param locator The location of the caller, for diagnostic purposes.
*
* @return non-null reference to a node.
*
* @throws TransformerException if the Source argument can't be resolved to
* a node.
*/
throws TransformerException
{
return n;
putDocumentInCache(n, source);
return n;
}
/**
* Try to create a DOM source tree from the input source.
*
* @param source The Source object that identifies the source node.
* @param locator The location of the caller, for diagnostic purposes.
*
* @return non-null reference to node identified by the source argument.
*
* @throws TransformerException if the source argument can not be resolved
* to a source node.
*/
throws TransformerException
{
try
{
{
}
else
{
}
return dtm.getDocument();
}
catch (Exception e)
{
//e.printStackTrace();
}
}
/**
* 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().
*
* @param inputSource The value returned from the URIResolver.
* @return a SAX2 XMLReader to use to resolve the inputSource argument.
* @param locator The location of the original caller, for diagnostic purposes.
*
* @throws TransformerException if the reader can not be created.
*/
throws TransformerException
{
try
{
{
try {
factory.setNamespaceAware( true );
} catch( NoSuchMethodError ex2 ) {
}
catch (AbstractMethodError ame){}
}
try
{
true);
}
{
// What can we do?
// TODO: User diagnostics.
}
return reader;
}
{
}
}
}