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 j2objc by google.
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 j2objc by google.
the class ProcessorTemplateElem 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 the current template element.
*
* @throws org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
protected void appendAndPush(StylesheetHandler handler, ElemTemplateElement elem) throws org.xml.sax.SAXException {
ElemTemplateElement parent = handler.getElemTemplateElement();
if (// defensive, for better multiple error reporting. -sb
null != parent) {
parent.appendChild(elem);
handler.pushElemTemplateElement(elem);
}
}
use of org.apache.xalan.templates.ElemTemplateElement in project j2objc by google.
the class ProcessorAttributeSet method startElement.
/**
* Receive notification of the start of an xsl:attribute-set 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.
*
* @see org.apache.xalan.processor.StylesheetHandler#startElement
* @see org.xml.sax.ContentHandler#startElement
* @see org.xml.sax.ContentHandler#endElement
* @see org.xml.sax.Attributes
*/
public void startElement(StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) throws org.xml.sax.SAXException {
ElemAttributeSet eat = new ElemAttributeSet();
eat.setLocaterInfo(handler.getLocator());
try {
eat.setPrefixes(handler.getNamespaceSupport());
} catch (TransformerException te) {
throw new org.xml.sax.SAXException(te);
}
eat.setDOMBackPointer(handler.getOriginatingNode());
setPropertiesFromAttributes(handler, rawName, attributes, eat);
handler.getStylesheet().setAttributeSet(eat);
// handler.pushElemTemplateElement(eat);
ElemTemplateElement parent = handler.getElemTemplateElement();
parent.appendChild(eat);
handler.pushElemTemplateElement(eat);
}
Aggregations