use of org.apache.xml.utils.SAXSourceLocator in project robovm by robovm.
the class XPath method error.
/**
* Tell the user of an error, and probably throw an
* exception.
*
* @param xctxt The XPath runtime context.
* @param sourceNode Not used.
* @param msg An error msgkey that corresponds to one of the constants found
* in {@link org.apache.xpath.res.XPATHErrorResources}, which is
* a key for a format string.
* @param args An array of arguments represented in the format string, which
* may be null.
*
* @throws TransformerException if the current ErrorListoner determines to
* throw an exception.
*/
public void error(XPathContext xctxt, int sourceNode, String msg, Object[] args) throws javax.xml.transform.TransformerException {
String fmsg = XSLMessages.createXPATHMessage(msg, args);
ErrorListener ehandler = xctxt.getErrorListener();
if (null != ehandler) {
ehandler.fatalError(new TransformerException(fmsg, (SAXSourceLocator) xctxt.getSAXLocator()));
} else {
SourceLocator slocator = xctxt.getSAXLocator();
System.out.println(fmsg + "; file " + slocator.getSystemId() + "; line " + slocator.getLineNumber() + "; column " + slocator.getColumnNumber());
}
}
use of org.apache.xml.utils.SAXSourceLocator in project robovm by robovm.
the class XPath method warn.
/**
* Warn the user of an problem.
*
* @param xctxt The XPath runtime context.
* @param sourceNode Not used.
* @param msg An error msgkey that corresponds to one of the constants found
* in {@link org.apache.xpath.res.XPATHErrorResources}, which is
* a key for a format string.
* @param args An array of arguments represented in the format string, which
* may be null.
*
* @throws TransformerException if the current ErrorListoner determines to
* throw an exception.
*/
public void warn(XPathContext xctxt, int sourceNode, String msg, Object[] args) throws javax.xml.transform.TransformerException {
String fmsg = XSLMessages.createXPATHWarning(msg, args);
ErrorListener ehandler = xctxt.getErrorListener();
if (null != ehandler) {
// TO DO: Need to get stylesheet Locator from here.
ehandler.warning(new TransformerException(fmsg, (SAXSourceLocator) xctxt.getSAXLocator()));
}
}
use of org.apache.xml.utils.SAXSourceLocator in project robovm by robovm.
the class TransformerImpl method transformNode.
/**
* Process the source node to the output result, if the
* processor supports the "http://xml.org/trax/features/dom/input"
* feature.
* %REVIEW% Do we need a Node version of this?
* @param node The input source node, which can be any valid DTM node.
*
* @throws TransformerException
*/
public void transformNode(int node) throws TransformerException {
//dml
setExtensionsTable(getStylesheet());
// Make sure we're not writing to the same output content handler.
synchronized (m_serializationHandler) {
m_hasBeenReset = false;
XPathContext xctxt = getXPathContext();
DTM dtm = xctxt.getDTM(node);
try {
pushGlobalVars(node);
// ==========
// Give the top-level templates a chance to pass information into
// the context (this is mainly for setting up tables for extensions).
StylesheetRoot stylesheet = this.getStylesheet();
int n = stylesheet.getGlobalImportCount();
for (int i = 0; i < n; i++) {
StylesheetComposed imported = stylesheet.getGlobalImport(i);
int includedCount = imported.getIncludeCountComposed();
for (int j = -1; j < includedCount; j++) {
Stylesheet included = imported.getIncludeComposed(j);
included.runtimeInit(this);
for (ElemTemplateElement child = included.getFirstChildElem(); child != null; child = child.getNextSiblingElem()) {
child.runtimeInit(this);
}
}
}
// ===========
// System.out.println("Calling applyTemplateToNode - "+Thread.currentThread().getName());
DTMIterator dtmIter = new org.apache.xpath.axes.SelfIteratorNoPredicate();
dtmIter.setRoot(node, xctxt);
xctxt.pushContextNodeList(dtmIter);
try {
this.applyTemplateToNode(null, null, node);
} finally {
xctxt.popContextNodeList();
}
// System.out.println("Done with applyTemplateToNode - "+Thread.currentThread().getName());
if (null != m_serializationHandler) {
m_serializationHandler.endDocument();
}
} catch (Exception se) {
// SAXSourceLocator
while (se instanceof org.apache.xml.utils.WrappedRuntimeException) {
Exception e = ((org.apache.xml.utils.WrappedRuntimeException) se).getException();
if (null != e)
se = e;
}
if (null != m_serializationHandler) {
try {
if (se instanceof org.xml.sax.SAXParseException)
m_serializationHandler.fatalError((org.xml.sax.SAXParseException) se);
else if (se instanceof TransformerException) {
TransformerException te = ((TransformerException) se);
SAXSourceLocator sl = new SAXSourceLocator(te.getLocator());
m_serializationHandler.fatalError(new org.xml.sax.SAXParseException(te.getMessage(), sl, te));
} else {
m_serializationHandler.fatalError(new org.xml.sax.SAXParseException(se.getMessage(), new SAXSourceLocator(), se));
}
} catch (Exception e) {
}
}
if (se instanceof TransformerException) {
m_errorHandler.fatalError((TransformerException) se);
} else if (se instanceof org.xml.sax.SAXParseException) {
m_errorHandler.fatalError(new TransformerException(se.getMessage(), new SAXSourceLocator((org.xml.sax.SAXParseException) se), se));
} else {
m_errorHandler.fatalError(new TransformerException(se));
}
} finally {
this.reset();
}
}
}
use of org.apache.xml.utils.SAXSourceLocator in project robovm by robovm.
the class FuncFormatNumb method warn.
/**
* Warn the user of a problem.
*
* @param xctxt The XPath runtime state.
* @param msg Warning message key
* @param args Arguments to be used in warning message
* @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
* the error condition is severe enough to halt processing.
*
* @throws javax.xml.transform.TransformerException
*/
public void warn(XPathContext xctxt, String msg, Object[] args) throws javax.xml.transform.TransformerException {
String formattedMsg = XSLMessages.createWarning(msg, args);
ErrorListener errHandler = xctxt.getErrorListener();
errHandler.warning(new TransformerException(formattedMsg, (SAXSourceLocator) xctxt.getSAXLocator()));
}
Aggregations