use of org.apache.xalan.templates.StylesheetComposed in project robovm by robovm.
the class ProcessorStylesheetElement method startElement.
/**
* Receive notification of the start of an strip-space element.
*
* @param handler The calling StylesheetHandler/TemplatesBuilder.
* @param uri The Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
* processing is not being performed.
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
* @param rawName The raw XML 1.0 name (with prefix), or the
* empty string if raw names are not available.
* @param attributes The attributes attached to the element. If
* there are no attributes, it shall be an empty
* Attributes object.
*/
public void startElement(StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) throws org.xml.sax.SAXException {
super.startElement(handler, uri, localName, rawName, attributes);
try {
int stylesheetType = handler.getStylesheetType();
Stylesheet stylesheet;
if (stylesheetType == StylesheetHandler.STYPE_ROOT) {
try {
stylesheet = getStylesheetRoot(handler);
} catch (TransformerConfigurationException tfe) {
throw new TransformerException(tfe);
}
} else {
Stylesheet parent = handler.getStylesheet();
if (stylesheetType == StylesheetHandler.STYPE_IMPORT) {
StylesheetComposed sc = new StylesheetComposed(parent);
parent.setImport(sc);
stylesheet = sc;
} else {
stylesheet = new Stylesheet(parent);
parent.setInclude(stylesheet);
}
}
stylesheet.setDOMBackPointer(handler.getOriginatingNode());
stylesheet.setLocaterInfo(handler.getLocator());
stylesheet.setPrefixes(handler.getNamespaceSupport());
handler.pushStylesheet(stylesheet);
setPropertiesFromAttributes(handler, rawName, attributes, handler.getStylesheet());
handler.pushElemTemplateElement(handler.getStylesheet());
} catch (TransformerException te) {
throw new org.xml.sax.SAXException(te);
}
}
use of org.apache.xalan.templates.StylesheetComposed in project j2objc by google.
the class ProcessorStylesheetElement method startElement.
/**
* Receive notification of the start of an strip-space element.
*
* @param handler The calling StylesheetHandler/TemplatesBuilder.
* @param uri The Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
* processing is not being performed.
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
* @param rawName The raw XML 1.0 name (with prefix), or the
* empty string if raw names are not available.
* @param attributes The attributes attached to the element. If
* there are no attributes, it shall be an empty
* Attributes object.
*/
public void startElement(StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) throws org.xml.sax.SAXException {
super.startElement(handler, uri, localName, rawName, attributes);
try {
int stylesheetType = handler.getStylesheetType();
Stylesheet stylesheet;
if (stylesheetType == StylesheetHandler.STYPE_ROOT) {
try {
stylesheet = getStylesheetRoot(handler);
} catch (TransformerConfigurationException tfe) {
throw new TransformerException(tfe);
}
} else {
Stylesheet parent = handler.getStylesheet();
if (stylesheetType == StylesheetHandler.STYPE_IMPORT) {
StylesheetComposed sc = new StylesheetComposed(parent);
parent.setImport(sc);
stylesheet = sc;
} else {
stylesheet = new Stylesheet(parent);
parent.setInclude(stylesheet);
}
}
stylesheet.setDOMBackPointer(handler.getOriginatingNode());
stylesheet.setLocaterInfo(handler.getLocator());
stylesheet.setPrefixes(handler.getNamespaceSupport());
handler.pushStylesheet(stylesheet);
setPropertiesFromAttributes(handler, rawName, attributes, handler.getStylesheet());
handler.pushElemTemplateElement(handler.getStylesheet());
} catch (TransformerException te) {
throw new org.xml.sax.SAXException(te);
}
}
use of org.apache.xalan.templates.StylesheetComposed in project j2objc by google.
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.xalan.templates.StylesheetComposed 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();
}
}
}
Aggregations