Search in sources :

Example 1 with ElemTemplateElement

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);
    }
}
Also used : ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement) TransformerException(javax.xml.transform.TransformerException)

Example 2 with ElemTemplateElement

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());
}
Also used : ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement)

Example 3 with ElemTemplateElement

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);
}
Also used : ElemLiteralResult(org.apache.xalan.templates.ElemLiteralResult) ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement)

Example 4 with ElemTemplateElement

use of org.apache.xalan.templates.ElemTemplateElement in project robovm by robovm.

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);
}
Also used : ElemAttributeSet(org.apache.xalan.templates.ElemAttributeSet) TransformerException(javax.xml.transform.TransformerException) ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement)

Example 5 with ElemTemplateElement

use of org.apache.xalan.templates.ElemTemplateElement in project robovm by robovm.

the class ProcessorCharacters method startNonText.

/**
   * Receive notification of the start of the non-text event.  This
   * is sent to the current processor when any non-text event occurs.
   *
   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
   */
public void startNonText(StylesheetHandler handler) throws org.xml.sax.SAXException {
    if (this == handler.getCurrentProcessor()) {
        handler.popProcessor();
    }
    int nChars = m_accumulator.length();
    if ((nChars > 0) && ((null != m_xslTextElement) || !XMLCharacterRecognizer.isWhiteSpace(m_accumulator)) || handler.isSpacePreserve()) {
        ElemTextLiteral elem = new ElemTextLiteral();
        elem.setDOMBackPointer(m_firstBackPointer);
        elem.setLocaterInfo(handler.getLocator());
        try {
            elem.setPrefixes(handler.getNamespaceSupport());
        } catch (TransformerException te) {
            throw new org.xml.sax.SAXException(te);
        }
        boolean doe = (null != m_xslTextElement) ? m_xslTextElement.getDisableOutputEscaping() : false;
        elem.setDisableOutputEscaping(doe);
        elem.setPreserveSpace(true);
        char[] chars = new char[nChars];
        m_accumulator.getChars(0, nChars, chars, 0);
        elem.setChars(chars);
        ElemTemplateElement parent = handler.getElemTemplateElement();
        parent.appendChild(elem);
    }
    m_accumulator.setLength(0);
    m_firstBackPointer = null;
}
Also used : ElemTextLiteral(org.apache.xalan.templates.ElemTextLiteral) TransformerException(javax.xml.transform.TransformerException) ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement)

Aggregations

ElemTemplateElement (org.apache.xalan.templates.ElemTemplateElement)35 TransformerException (javax.xml.transform.TransformerException)18 SAXException (org.xml.sax.SAXException)10 ElemTextLiteral (org.apache.xalan.templates.ElemTextLiteral)8 ElemExsltFuncResult (org.apache.xalan.templates.ElemExsltFuncResult)6 ElemExsltFunction (org.apache.xalan.templates.ElemExsltFunction)6 ElemLiteralResult (org.apache.xalan.templates.ElemLiteralResult)6 ElemVariable (org.apache.xalan.templates.ElemVariable)5 IOException (java.io.IOException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)4 ElemParam (org.apache.xalan.templates.ElemParam)4 Stylesheet (org.apache.xalan.templates.Stylesheet)4 SAXSourceLocator (org.apache.xml.utils.SAXSourceLocator)4 XPathContext (org.apache.xpath.XPathContext)4 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)4 SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)4 StringWriter (java.io.StringWriter)2 Vector (java.util.Vector)2 ElemApplyImport (org.apache.xalan.templates.ElemApplyImport)2