use of javax.xml.transform.ErrorListener in project robovm by robovm.
the class StylesheetHandler method pushSpaceHandling.
/**
* Push boolean value on to the spacePreserve stack depending on the value
* of xml:space=default/preserve.
*
* @param attrs list of attributes that were passed to startElement.
*/
void pushSpaceHandling(Attributes attrs) throws org.xml.sax.SAXParseException {
String value = attrs.getValue("xml:space");
if (null == value) {
m_spacePreserveStack.push(m_spacePreserveStack.peekOrFalse());
} else if (value.equals("preserve")) {
m_spacePreserveStack.push(true);
} else if (value.equals("default")) {
m_spacePreserveStack.push(false);
} else {
SAXSourceLocator locator = getLocator();
ErrorListener handler = m_stylesheetProcessor.getErrorListener();
try {
//"Illegal value for xml:space", locator));
handler.error(new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_ILLEGAL_XMLSPACE_VALUE, null), locator));
} catch (TransformerException te) {
throw new org.xml.sax.SAXParseException(te.getMessage(), locator, te);
}
m_spacePreserveStack.push(m_spacePreserveStack.peek());
}
}
use of javax.xml.transform.ErrorListener in project robovm by robovm.
the class StylesheetHandler method warn.
/**
* Warn the user of an problem.
*
* @param msg An key into the {@link org.apache.xalan.res.XSLTErrorResources}
* table, that is one of the WG_ prefixed definitions.
* @param args An array of arguments for the given warning.
*
* @throws org.xml.sax.SAXException that wraps a
* {@link javax.xml.transform.TransformerException} if the current
* {@link javax.xml.transform.ErrorListener#warning}
* method chooses to flag this condition as an error.
* @xsl.usage internal
*/
public void warn(String msg, Object[] args) throws org.xml.sax.SAXException {
String formattedMsg = XSLMessages.createWarning(msg, args);
SAXSourceLocator locator = getLocator();
ErrorListener handler = m_stylesheetProcessor.getErrorListener();
try {
if (null != handler)
handler.warning(new TransformerException(formattedMsg, locator));
} catch (TransformerException te) {
throw new org.xml.sax.SAXException(te);
}
}
use of javax.xml.transform.ErrorListener in project robovm by robovm.
the class StylesheetHandler method createMatchPatternXPath.
/**
* Process an expression string into an XPath.
*
* @param str A non-null reference to a valid or invalid match pattern string.
*
* @return A non-null reference to an XPath object that represents the string argument.
*
* @throws javax.xml.transform.TransformerException if the pattern can not be processed.
* @see <a href="http://www.w3.org/TR/xslt#patterns">Section 5.2 Patterns in XSLT Specification</a>
*/
XPath createMatchPatternXPath(String str, ElemTemplateElement owningTemplate) throws javax.xml.transform.TransformerException {
ErrorListener handler = m_stylesheetProcessor.getErrorListener();
XPath xpath = new XPath(str, owningTemplate, this, XPath.MATCH, handler, m_funcTable);
// Visit the expression, registering namespaces for any extension functions it includes.
xpath.callVisitors(xpath, new ExpressionVisitor(getStylesheetRoot()));
return xpath;
}
use of javax.xml.transform.ErrorListener in project robovm by robovm.
the class StylesheetHandler method error.
/**
* Receive notification of a recoverable XSLT processing error.
*
* @param e The error information encoded as an exception.
*
* @throws org.xml.sax.SAXException that wraps a
* {@link javax.xml.transform.TransformerException} if the current
* {@link javax.xml.transform.ErrorListener#error}
* method chooses to flag this condition as an error.
*/
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException {
String formattedMsg = e.getMessage();
SAXSourceLocator locator = getLocator();
ErrorListener handler = m_stylesheetProcessor.getErrorListener();
try {
handler.error(new TransformerException(formattedMsg, locator));
} catch (TransformerException te) {
throw new org.xml.sax.SAXException(te);
}
}
use of javax.xml.transform.ErrorListener in project robovm by robovm.
the class ToXMLStream method getXMLVersion.
/**
* This method checks for the XML version of output document.
* If XML version of output document is not specified, then output
* document is of version XML 1.0.
* If XML version of output doucment is specified, but it is not either
* XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
* output document is set to XML 1.0 and processing continues.
* @return string (XML version)
*/
private String getXMLVersion() {
String xmlVersion = getVersion();
if (xmlVersion == null || xmlVersion.equals(XMLVERSION10)) {
xmlVersion = XMLVERSION10;
} else if (xmlVersion.equals(XMLVERSION11)) {
xmlVersion = XMLVERSION11;
} else {
String msg = Utils.messages.createMessage(MsgKey.ER_XML_VERSION_NOT_SUPPORTED, new Object[] { xmlVersion });
try {
// Prepare to issue the warning message
Transformer tran = super.getTransformer();
ErrorListener errHandler = tran.getErrorListener();
// Issue the warning message
if (null != errHandler && m_sourceLocator != null)
errHandler.warning(new TransformerException(msg, m_sourceLocator));
else
System.out.println(msg);
} catch (Exception e) {
}
xmlVersion = XMLVERSION10;
}
return xmlVersion;
}
Aggregations