use of org.apache.xalan.templates.ElemTemplateElement in project j2objc by google.
the class ProcessorExsltFunction method ancestorIsOk.
/**
* Verify that a literal result belongs to a result element, a variable,
* or a parameter.
*/
boolean ancestorIsOk(ElemTemplateElement child) {
while (child.getParentElem() != null && !(child.getParentElem() instanceof ElemExsltFunction)) {
ElemTemplateElement parent = child.getParentElem();
if (parent instanceof ElemExsltFuncResult || parent instanceof ElemVariable || parent instanceof ElemParam || parent instanceof ElemMessage)
return true;
child = parent;
}
return false;
}
use of org.apache.xalan.templates.ElemTemplateElement in project j2objc by google.
the class ProcessorText method appendAndPush.
/**
* Append the current template element to the current
* template element, and then push it onto the current template
* element stack.
*
* @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
* @param elem non-null reference to a {@link org.apache.xalan.templates.ElemText}.
*
* @throws org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
protected void appendAndPush(StylesheetHandler handler, ElemTemplateElement elem) throws org.xml.sax.SAXException {
// Don't push this element onto the element stack.
ProcessorCharacters charProcessor = (ProcessorCharacters) handler.getProcessorFor(null, "text()", "text");
charProcessor.setXslTextElement((ElemText) elem);
ElemTemplateElement parent = handler.getElemTemplateElement();
parent.appendChild(elem);
elem.setDOMBackPointer(handler.getOriginatingNode());
}
use of org.apache.xalan.templates.ElemTemplateElement in project j2objc by google.
the class StylesheetHandler method getElemVersion.
private double getElemVersion() {
ElemTemplateElement elem = getElemTemplateElement();
double version = -1;
while ((version == -1 || version == Constants.XSLTVERSUPPORTED) && elem != null) {
try {
version = Double.valueOf(elem.getXmlVersion()).doubleValue();
} catch (Exception ex) {
version = -1;
}
elem = elem.getParentElem();
}
return (version == -1) ? Constants.XSLTVERSUPPORTED : version;
}
use of org.apache.xalan.templates.ElemTemplateElement in project j2objc by google.
the class TransformerImpl method executeChildTemplates.
/**
* Execute each of the children of a template element.
*
* @param elem The ElemTemplateElement that contains the children
* that should execute.
* @param shouldAddAttrs true if xsl:attributes should be executed.
*
* @throws TransformerException
* @xsl.usage advanced
*/
public void executeChildTemplates(ElemTemplateElement elem, boolean shouldAddAttrs) throws TransformerException {
// Does this element have any children?
ElemTemplateElement t = elem.getFirstChildElem();
if (null == t)
return;
if (elem.hasTextLitOnly() && m_optimizer) {
char[] chars = ((ElemTextLiteral) t).getChars();
try {
// Have to push stuff on for tooling...
this.pushElemTemplateElement(t);
m_serializationHandler.characters(chars, 0, chars.length);
} catch (SAXException se) {
throw new TransformerException(se);
} finally {
this.popElemTemplateElement();
}
return;
}
// // Check for infinite loops if we have to.
// boolean check = (m_stackGuard.m_recursionLimit > -1);
//
// if (check)
// getStackGuard().push(elem, xctxt.getCurrentNode());
XPathContext xctxt = m_xcontext;
xctxt.pushSAXLocatorNull();
int currentTemplateElementsTop = m_currentTemplateElements.size();
m_currentTemplateElements.push(null);
try {
// each of them.
for (; t != null; t = t.getNextSiblingElem()) {
if (!shouldAddAttrs && t.getXSLToken() == Constants.ELEMNAME_ATTRIBUTE)
continue;
xctxt.setSAXLocator(t);
m_currentTemplateElements.setElementAt(t, currentTemplateElementsTop);
t.execute(this);
}
} catch (RuntimeException re) {
TransformerException te = new TransformerException(re);
te.setLocator(t);
throw te;
} finally {
m_currentTemplateElements.pop();
xctxt.popSAXLocator();
}
// Check for infinite loops if we have to
// if (check)
// getStackGuard().pop();
}
use of org.apache.xalan.templates.ElemTemplateElement 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();
}
}
}
Aggregations