Search in sources :

Example 11 with Stylesheet

use of org.apache.xalan.templates.Stylesheet in project j2objc by google.

the class ProcessorStylesheetElement method startElement.

/**
 * Receive notification of the start of an strip-space 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.
 */
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 {
        int stylesheetType = handler.getStylesheetType();
        Stylesheet stylesheet;
        if (stylesheetType == StylesheetHandler.STYPE_ROOT) {
            try {
                stylesheet = getStylesheetRoot(handler);
            } catch (TransformerConfigurationException tfe) {
                throw new TransformerException(tfe);
            }
        } else {
            Stylesheet parent = handler.getStylesheet();
            if (stylesheetType == StylesheetHandler.STYPE_IMPORT) {
                StylesheetComposed sc = new StylesheetComposed(parent);
                parent.setImport(sc);
                stylesheet = sc;
            } else {
                stylesheet = new Stylesheet(parent);
                parent.setInclude(stylesheet);
            }
        }
        stylesheet.setDOMBackPointer(handler.getOriginatingNode());
        stylesheet.setLocaterInfo(handler.getLocator());
        stylesheet.setPrefixes(handler.getNamespaceSupport());
        handler.pushStylesheet(stylesheet);
        setPropertiesFromAttributes(handler, rawName, attributes, handler.getStylesheet());
        handler.pushElemTemplateElement(handler.getStylesheet());
    } catch (TransformerException te) {
        throw new org.xml.sax.SAXException(te);
    }
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) StylesheetComposed(org.apache.xalan.templates.StylesheetComposed) Stylesheet(org.apache.xalan.templates.Stylesheet) TransformerException(javax.xml.transform.TransformerException)

Example 12 with Stylesheet

use of org.apache.xalan.templates.Stylesheet in project j2objc by google.

the class ProcessorPreserveSpace method startElement.

/**
 * Receive notification of the start of an preserve-space 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.
 */
public void startElement(StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) throws org.xml.sax.SAXException {
    Stylesheet thisSheet = handler.getStylesheet();
    WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet);
    setPropertiesFromAttributes(handler, rawName, attributes, paths);
    Vector xpaths = paths.getElements();
    for (int i = 0; i < xpaths.size(); i++) {
        WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), false, thisSheet);
        wsi.setUid(handler.nextUid());
        thisSheet.setPreserveSpaces(wsi);
    }
    paths.clearElements();
}
Also used : WhiteSpaceInfo(org.apache.xalan.templates.WhiteSpaceInfo) Vector(java.util.Vector) Stylesheet(org.apache.xalan.templates.Stylesheet)

Aggregations

Stylesheet (org.apache.xalan.templates.Stylesheet)12 TransformerException (javax.xml.transform.TransformerException)6 Vector (java.util.Vector)4 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)4 ElemTemplateElement (org.apache.xalan.templates.ElemTemplateElement)4 StylesheetComposed (org.apache.xalan.templates.StylesheetComposed)4 WhiteSpaceInfo (org.apache.xalan.templates.WhiteSpaceInfo)4 SAXSourceLocator (org.apache.xml.utils.SAXSourceLocator)4 SAXException (org.xml.sax.SAXException)4 IOException (java.io.IOException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 ElemExtensionCall (org.apache.xalan.templates.ElemExtensionCall)2 ElemLiteralResult (org.apache.xalan.templates.ElemLiteralResult)2 ElemTemplate (org.apache.xalan.templates.ElemTemplate)2 StylesheetRoot (org.apache.xalan.templates.StylesheetRoot)2 DTM (org.apache.xml.dtm.DTM)2 DTMIterator (org.apache.xml.dtm.DTMIterator)2 XPath (org.apache.xpath.XPath)2 XPathContext (org.apache.xpath.XPathContext)2 Locator (org.xml.sax.Locator)2