use of org.apache.xpath.SourceTreeManager in project j2objc by google.
the class FuncDocument method getDoc.
/**
* Get the document from the given URI and base
*
* @param xctxt The XPath runtime state.
* @param context The current context node
* @param uri Relative(?) URI of the document
* @param base Base to resolve relative URI from.
*
* @return The document Node pointing to the document at the given URI
* or null
*
* @throws javax.xml.transform.TransformerException
*/
int getDoc(XPathContext xctxt, int context, String uri, String base) throws javax.xml.transform.TransformerException {
// System.out.println("base: "+base+", uri: "+uri);
SourceTreeManager treeMgr = xctxt.getSourceTreeManager();
Source source;
int newDoc;
try {
source = treeMgr.resolveURI(base, uri, xctxt.getSAXLocator());
newDoc = treeMgr.getNode(source);
} catch (IOException ioe) {
throw new TransformerException(ioe.getMessage(), (SourceLocator) xctxt.getSAXLocator(), ioe);
} catch (TransformerException te) {
throw new TransformerException(te);
}
if (DTM.NULL != newDoc)
return newDoc;
// If the uri length is zero, get the uri of the stylesheet.
if (uri.length() == 0) {
// Hmmm... this seems pretty bogus to me... -sb
uri = xctxt.getNamespaceContext().getBaseIdentifier();
try {
source = treeMgr.resolveURI(base, uri, xctxt.getSAXLocator());
} catch (IOException ioe) {
throw new TransformerException(ioe.getMessage(), (SourceLocator) xctxt.getSAXLocator(), ioe);
}
}
String diagnosticsString = null;
try {
if ((null != uri) && (uri.length() > 0)) {
newDoc = treeMgr.getSourceTree(source, xctxt.getSAXLocator(), xctxt);
// System.out.println("newDoc: "+((Document)newDoc).getDocumentElement().getNodeName());
} else
warn(xctxt, XSLTErrorResources.WG_CANNOT_MAKE_URL_FROM, //"Can not make URL from: "+((base == null) ? "" : base )+uri);
new Object[] { ((base == null) ? "" : base) + uri });
} catch (Throwable throwable) {
// throwable.printStackTrace();
newDoc = DTM.NULL;
// path.warn(XSLTErrorResources.WG_ENCODING_NOT_SUPPORTED_USING_JAVA, new Object[]{((base == null) ? "" : base )+uri}); //"Can not load requested doc: "+((base == null) ? "" : base )+uri);
while (throwable instanceof org.apache.xml.utils.WrappedRuntimeException) {
throwable = ((org.apache.xml.utils.WrappedRuntimeException) throwable).getException();
}
if ((throwable instanceof NullPointerException) || (throwable instanceof ClassCastException)) {
throw new org.apache.xml.utils.WrappedRuntimeException((Exception) throwable);
}
StringWriter sw = new StringWriter();
PrintWriter diagnosticsWriter = new PrintWriter(sw);
if (throwable instanceof TransformerException) {
TransformerException spe = (TransformerException) throwable;
{
Throwable e = spe;
while (null != e) {
if (null != e.getMessage()) {
diagnosticsWriter.println(" (" + e.getClass().getName() + "): " + e.getMessage());
}
if (e instanceof TransformerException) {
TransformerException spe2 = (TransformerException) e;
SourceLocator locator = spe2.getLocator();
if ((null != locator) && (null != locator.getSystemId()))
diagnosticsWriter.println(" ID: " + locator.getSystemId() + " Line #" + locator.getLineNumber() + " Column #" + locator.getColumnNumber());
e = spe2.getException();
if (e instanceof org.apache.xml.utils.WrappedRuntimeException)
e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
} else
e = null;
}
}
} else {
diagnosticsWriter.println(" (" + throwable.getClass().getName() + "): " + throwable.getMessage());
}
//sw.toString();
diagnosticsString = throwable.getMessage();
}
if (DTM.NULL == newDoc) {
// System.out.println("what?: "+base+", uri: "+uri);
if (null != diagnosticsString) {
warn(xctxt, XSLTErrorResources.WG_CANNOT_LOAD_REQUESTED_DOC, //"Can not load requested doc: "+((base == null) ? "" : base )+uri);
new Object[] { diagnosticsString });
} else
warn(xctxt, XSLTErrorResources.WG_CANNOT_LOAD_REQUESTED_DOC, new Object[] { uri == null ? ((base == null) ? "" : base) + uri : //"Can not load requested doc: "+((base == null) ? "" : base )+uri);
uri.toString() });
} else {
// %REVIEW%
// TBD: What to do about XLocator?
// xctxt.getSourceTreeManager().associateXLocatorToNode(newDoc, url, null);
}
return newDoc;
}
use of org.apache.xpath.SourceTreeManager in project robovm by robovm.
the class FuncDocument method getDoc.
/**
* Get the document from the given URI and base
*
* @param xctxt The XPath runtime state.
* @param context The current context node
* @param uri Relative(?) URI of the document
* @param base Base to resolve relative URI from.
*
* @return The document Node pointing to the document at the given URI
* or null
*
* @throws javax.xml.transform.TransformerException
*/
int getDoc(XPathContext xctxt, int context, String uri, String base) throws javax.xml.transform.TransformerException {
// System.out.println("base: "+base+", uri: "+uri);
SourceTreeManager treeMgr = xctxt.getSourceTreeManager();
Source source;
int newDoc;
try {
source = treeMgr.resolveURI(base, uri, xctxt.getSAXLocator());
newDoc = treeMgr.getNode(source);
} catch (IOException ioe) {
throw new TransformerException(ioe.getMessage(), (SourceLocator) xctxt.getSAXLocator(), ioe);
} catch (TransformerException te) {
throw new TransformerException(te);
}
if (DTM.NULL != newDoc)
return newDoc;
// If the uri length is zero, get the uri of the stylesheet.
if (uri.length() == 0) {
// Hmmm... this seems pretty bogus to me... -sb
uri = xctxt.getNamespaceContext().getBaseIdentifier();
try {
source = treeMgr.resolveURI(base, uri, xctxt.getSAXLocator());
} catch (IOException ioe) {
throw new TransformerException(ioe.getMessage(), (SourceLocator) xctxt.getSAXLocator(), ioe);
}
}
String diagnosticsString = null;
try {
if ((null != uri) && (uri.length() > 0)) {
newDoc = treeMgr.getSourceTree(source, xctxt.getSAXLocator(), xctxt);
// System.out.println("newDoc: "+((Document)newDoc).getDocumentElement().getNodeName());
} else
warn(xctxt, XSLTErrorResources.WG_CANNOT_MAKE_URL_FROM, //"Can not make URL from: "+((base == null) ? "" : base )+uri);
new Object[] { ((base == null) ? "" : base) + uri });
} catch (Throwable throwable) {
// throwable.printStackTrace();
newDoc = DTM.NULL;
// path.warn(XSLTErrorResources.WG_ENCODING_NOT_SUPPORTED_USING_JAVA, new Object[]{((base == null) ? "" : base )+uri}); //"Can not load requested doc: "+((base == null) ? "" : base )+uri);
while (throwable instanceof org.apache.xml.utils.WrappedRuntimeException) {
throwable = ((org.apache.xml.utils.WrappedRuntimeException) throwable).getException();
}
if ((throwable instanceof NullPointerException) || (throwable instanceof ClassCastException)) {
throw new org.apache.xml.utils.WrappedRuntimeException((Exception) throwable);
}
StringWriter sw = new StringWriter();
PrintWriter diagnosticsWriter = new PrintWriter(sw);
if (throwable instanceof TransformerException) {
TransformerException spe = (TransformerException) throwable;
{
Throwable e = spe;
while (null != e) {
if (null != e.getMessage()) {
diagnosticsWriter.println(" (" + e.getClass().getName() + "): " + e.getMessage());
}
if (e instanceof TransformerException) {
TransformerException spe2 = (TransformerException) e;
SourceLocator locator = spe2.getLocator();
if ((null != locator) && (null != locator.getSystemId()))
diagnosticsWriter.println(" ID: " + locator.getSystemId() + " Line #" + locator.getLineNumber() + " Column #" + locator.getColumnNumber());
e = spe2.getException();
if (e instanceof org.apache.xml.utils.WrappedRuntimeException)
e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
} else
e = null;
}
}
} else {
diagnosticsWriter.println(" (" + throwable.getClass().getName() + "): " + throwable.getMessage());
}
//sw.toString();
diagnosticsString = throwable.getMessage();
}
if (DTM.NULL == newDoc) {
// System.out.println("what?: "+base+", uri: "+uri);
if (null != diagnosticsString) {
warn(xctxt, XSLTErrorResources.WG_CANNOT_LOAD_REQUESTED_DOC, //"Can not load requested doc: "+((base == null) ? "" : base )+uri);
new Object[] { diagnosticsString });
} else
warn(xctxt, XSLTErrorResources.WG_CANNOT_LOAD_REQUESTED_DOC, new Object[] { uri == null ? ((base == null) ? "" : base) + uri : //"Can not load requested doc: "+((base == null) ? "" : base )+uri);
uri.toString() });
} else {
// %REVIEW%
// TBD: What to do about XLocator?
// xctxt.getSourceTreeManager().associateXLocatorToNode(newDoc, url, null);
}
return newDoc;
}
Aggregations