Search in sources :

Example 6 with OutputProperties

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

the class TransformerIdentityImpl method getOutputProperty.

/**
   * Get an output property that is in effect for the
   * transformation.  The property specified may be a property
   * that was set with setOutputProperty, or it may be a
   * property specified in the stylesheet.
   *
   * @param name A non-null String that specifies an output
   * property name, which may be namespace qualified.
   *
   * @return The string value of the output property, or null
   * if no property was found.
   *
   * @throws IllegalArgumentException If the property is not supported.
   *
   * @see javax.xml.transform.OutputKeys
   */
public String getOutputProperty(String name) throws IllegalArgumentException {
    String value = null;
    OutputProperties props = m_outputFormat;
    value = props.getProperty(name);
    if (null == value) {
        if (!OutputProperties.isLegalPropertyKey(name))
            //"output property not recognized: "
            throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, new Object[] { name }));
    // + name);
    }
    return value;
}
Also used : OutputProperties(org.apache.xalan.templates.OutputProperties)

Example 7 with OutputProperties

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

the class TransformerImpl method getOutputPropertyNoDefault.

/**
   * Get the value of a property, without using the default properties.  This
   * can be used to test if a property has been explicitly set by the stylesheet
   * or user.
   *
   * NEEDSDOC @param qnameString
   *
   * @return The value of the property, or null if not found.
   *
   * @throws IllegalArgumentException If the property is not supported,
   * and is not namespaced.
   */
public String getOutputPropertyNoDefault(String qnameString) throws IllegalArgumentException {
    String value = null;
    OutputProperties props = getOutputFormat();
    value = (String) props.getProperties().get(qnameString);
    if (null == value) {
        if (!OutputProperties.isLegalPropertyKey(qnameString))
            //"output property not recognized: "
            throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, new Object[] { qnameString }));
    // + qnameString);
    }
    return value;
}
Also used : OutputProperties(org.apache.xalan.templates.OutputProperties)

Example 8 with OutputProperties

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

the class SerializerSwitcher method switchSerializerIfHTML.

/**
   * Switch to HTML serializer if element is HTML
   *
   *
   * @param ns Namespace URI of the element
   * @param localName Local part of name of element
   *
   * @throws TransformerException
   * @return new contentHandler.
   */
public static Serializer switchSerializerIfHTML(String ns, String localName, Properties props, Serializer oldSerializer) throws TransformerException {
    Serializer newSerializer = oldSerializer;
    if (((null == ns) || (ns.length() == 0)) && localName.equalsIgnoreCase("html")) {
        // Access at level of hashtable to see if the method has been set.
        if (null != getOutputPropertyNoDefault(OutputKeys.METHOD, props))
            return newSerializer;
        // Getting the output properties this way won't cause a clone of 
        // the properties.
        Properties prevProperties = props;
        // We have to make sure we get an output properties with the proper 
        // defaults for the HTML method.  The easiest way to do this is to 
        // have the OutputProperties class do it.
        OutputProperties htmlOutputProperties = new OutputProperties(Method.HTML);
        htmlOutputProperties.copyFrom(prevProperties, true);
        Properties htmlProperties = htmlOutputProperties.getProperties();
        //      try
        {
            if (null != oldSerializer) {
                Serializer serializer = SerializerFactory.getSerializer(htmlProperties);
                Writer writer = oldSerializer.getWriter();
                if (null != writer)
                    serializer.setWriter(writer);
                else {
                    OutputStream os = serializer.getOutputStream();
                    if (null != os)
                        serializer.setOutputStream(os);
                }
                newSerializer = serializer;
            }
        }
    //      catch (java.io.IOException e)
    //      {
    //        throw new TransformerException(e);
    //      }
    }
    return newSerializer;
}
Also used : OutputStream(java.io.OutputStream) OutputProperties(org.apache.xalan.templates.OutputProperties) Properties(java.util.Properties) OutputProperties(org.apache.xalan.templates.OutputProperties) Writer(java.io.Writer) Serializer(org.apache.xml.serializer.Serializer)

Example 9 with OutputProperties

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

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 10 with OutputProperties

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

the class TransformerImpl method getOutputProperty.

/**
   * Get an output property that is in effect for the
   * transformation.  The property specified may be a property
   * that was set with setOutputProperty, or it may be a
   * property specified in the stylesheet.
   *
   * NEEDSDOC @param qnameString
   *
   * @return The string value of the output property, or null
   * if no property was found.
   *
   * @throws IllegalArgumentException If the property is not supported.
   *
   * @see javax.xml.transform.OutputKeys
   */
public String getOutputProperty(String qnameString) throws IllegalArgumentException {
    String value = null;
    OutputProperties props = getOutputFormat();
    value = props.getProperty(qnameString);
    if (null == value) {
        if (!OutputProperties.isLegalPropertyKey(qnameString))
            //"output property not recognized: "
            throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, new Object[] { qnameString }));
    //+ qnameString);
    }
    return value;
}
Also used : OutputProperties(org.apache.xalan.templates.OutputProperties)

Aggregations

OutputProperties (org.apache.xalan.templates.OutputProperties)16 OutputStream (java.io.OutputStream)4 Writer (java.io.Writer)4 Properties (java.util.Properties)4 TransformerException (javax.xml.transform.TransformerException)4 Serializer (org.apache.xml.serializer.Serializer)4 ElemTemplateElement (org.apache.xalan.templates.ElemTemplateElement)2 ContentHandler (org.xml.sax.ContentHandler)2