Search in sources :

Example 31 with ElemTemplateElement

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

the class ProcessorOutputElem method startElement.

/**
   * Receive notification of the start of an xsl:output 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.
   *
   * @throws org.xml.sax.SAXException
   */
public void startElement(StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) throws org.xml.sax.SAXException {
    // Hmmm... for the moment I don't think I'll have default properties set for this. -sb
    m_outputProperties = new OutputProperties();
    m_outputProperties.setDOMBackPointer(handler.getOriginatingNode());
    m_outputProperties.setLocaterInfo(handler.getLocator());
    m_outputProperties.setUid(handler.nextUid());
    setPropertiesFromAttributes(handler, rawName, attributes, this);
    // Access this only from the Hashtable level... we don't want to 
    // get default properties.
    String entitiesFileName = (String) m_outputProperties.getProperties().get(OutputPropertiesFactory.S_KEY_ENTITIES);
    if (null != entitiesFileName) {
        try {
            String absURL = SystemIDResolver.getAbsoluteURI(entitiesFileName, handler.getBaseIdentifier());
            m_outputProperties.getProperties().put(OutputPropertiesFactory.S_KEY_ENTITIES, absURL);
        } catch (TransformerException te) {
            handler.error(te.getMessage(), te);
        }
    }
    handler.getStylesheet().setOutput(m_outputProperties);
    ElemTemplateElement parent = handler.getElemTemplateElement();
    parent.appendChild(m_outputProperties);
    m_outputProperties = null;
}
Also used : OutputProperties(org.apache.xalan.templates.OutputProperties) TransformerException(javax.xml.transform.TransformerException) ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement)

Example 32 with ElemTemplateElement

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

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

Example 33 with ElemTemplateElement

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

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

Example 34 with ElemTemplateElement

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

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

Example 35 with ElemTemplateElement

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

the class ProcessorExsltFunction method endElement.

/**
   * End an ElemExsltFunction, and verify its validity.
   */
public void endElement(StylesheetHandler handler, String uri, String localName, String rawName) throws SAXException {
    ElemTemplateElement function = handler.getElemTemplateElement();
    // may throw exception
    validate(function, handler);
    super.endElement(handler, uri, localName, rawName);
}
Also used : 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