use of org.apache.xalan.templates.ElemTemplateElement in project robovm by robovm.
the class ProcessorExsltFuncResult method startElement.
/**
* Verify that the func:result element does not appear within a variable,
* parameter, or another func:result, and that it belongs to a func:function
* element.
*/
public void startElement(StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) throws SAXException {
String msg = "";
super.startElement(handler, uri, localName, rawName, attributes);
ElemTemplateElement ancestor = handler.getElemTemplateElement().getParentElem();
while (ancestor != null && !(ancestor instanceof ElemExsltFunction)) {
if (ancestor instanceof ElemVariable || ancestor instanceof ElemParam || ancestor instanceof ElemExsltFuncResult) {
msg = "func:result cannot appear within a variable, parameter, or another func:result.";
handler.error(msg, new SAXException(msg));
}
ancestor = ancestor.getParentElem();
}
if (ancestor == null) {
msg = "func:result must appear in a func:function element";
handler.error(msg, new SAXException(msg));
}
}
use of org.apache.xalan.templates.ElemTemplateElement in project robovm by robovm.
the class ProcessorExsltFunction method validate.
/**
* Non-recursive traversal of FunctionElement tree based on TreeWalker to verify that
* there are no literal result elements except within a func:result element and that
* the func:result element does not contain any following siblings except xsl:fallback.
*/
public void validate(ElemTemplateElement elem, StylesheetHandler handler) throws SAXException {
String msg = "";
while (elem != null) {
//System.out.println("elem " + elem);
if (elem instanceof ElemExsltFuncResult && elem.getNextSiblingElem() != null && !(elem.getNextSiblingElem() instanceof ElemFallback)) {
msg = "func:result has an illegal following sibling (only xsl:fallback allowed)";
handler.error(msg, new SAXException(msg));
}
if ((elem instanceof ElemApplyImport || elem instanceof ElemApplyTemplates || elem instanceof ElemAttribute || elem instanceof ElemCallTemplate || elem instanceof ElemComment || elem instanceof ElemCopy || elem instanceof ElemCopyOf || elem instanceof ElemElement || elem instanceof ElemLiteralResult || elem instanceof ElemNumber || elem instanceof ElemPI || elem instanceof ElemText || elem instanceof ElemTextLiteral || elem instanceof ElemValueOf) && !(ancestorIsOk(elem))) {
msg = "misplaced literal result in a func:function container.";
handler.error(msg, new SAXException(msg));
}
ElemTemplateElement nextElem = elem.getFirstChildElem();
while (nextElem == null) {
nextElem = elem.getNextSiblingElem();
if (nextElem == null)
elem = elem.getParentElem();
if (elem == null || elem instanceof ElemExsltFunction)
// ok
return;
}
elem = nextElem;
}
}
use of org.apache.xalan.templates.ElemTemplateElement in project robovm by robovm.
the class ProcessorTemplateElem method startElement.
/**
* Receive notification of the start of an element.
*
* @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
* @param uri The Namespace URI, or an empty string.
* @param localName The local name (without prefix), or empty string if not namespace processing.
* @param rawName The qualified name (with prefix).
* @param attributes The specified or defaulted attributes.
*/
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 {
// ElemTemplateElement parent = handler.getElemTemplateElement();
XSLTElementDef def = getElemDef();
Class classObject = def.getClassObject();
ElemTemplateElement elem = null;
try {
elem = (ElemTemplateElement) classObject.newInstance();
elem.setDOMBackPointer(handler.getOriginatingNode());
elem.setLocaterInfo(handler.getLocator());
elem.setPrefixes(handler.getNamespaceSupport());
} catch (InstantiationException ie) {
//"Failed creating ElemTemplateElement instance!", ie);
handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMTMPL, null, ie);
} catch (IllegalAccessException iae) {
//"Failed creating ElemTemplateElement instance!", iae);
handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMTMPL, null, iae);
}
setPropertiesFromAttributes(handler, rawName, attributes, elem);
appendAndPush(handler, elem);
} catch (TransformerException te) {
throw new org.xml.sax.SAXException(te);
}
}
use of org.apache.xalan.templates.ElemTemplateElement in project robovm by robovm.
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 robovm by robovm.
the class ProcessorLRE method endElement.
/**
* Receive notification of the end of an element.
*
* @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
* @param uri The Namespace URI, or an empty string.
* @param localName The local name (without prefix), or empty string if not namespace processing.
* @param rawName The qualified name (with prefix).
*/
public void endElement(StylesheetHandler handler, String uri, String localName, String rawName) throws org.xml.sax.SAXException {
ElemTemplateElement elem = handler.getElemTemplateElement();
if (elem instanceof ElemLiteralResult) {
if (((ElemLiteralResult) elem).getIsLiteralResultAsStylesheet()) {
handler.popStylesheet();
}
}
super.endElement(handler, uri, localName, rawName);
}
Aggregations