use of org.apache.xalan.templates.OutputProperties in project j2objc by google.
the class TransformerIdentityImpl method reset.
/**
* Reset the status of the transformer.
*/
public void reset() {
m_flushedStartDoc = false;
m_foundFirstElement = false;
m_outputStream = null;
clearParameters();
m_result = null;
m_resultContentHandler = null;
m_resultDeclHandler = null;
m_resultDTDHandler = null;
m_resultLexicalHandler = null;
m_serializer = null;
m_systemID = null;
m_URIResolver = null;
m_outputFormat = new OutputProperties(Method.XML);
}
use of org.apache.xalan.templates.OutputProperties in project j2objc by google.
the class TransformerImpl method setOutputProperties.
/**
* Set the output properties for the transformation. These
* properties will override properties set in the templates
* with xsl:output.
*
* <p>If argument to this function is null, any properties
* previously set will be removed.</p>
*
* @param oformat A set of output properties that will be
* used to override any of the same properties in effect
* for the transformation.
*
* @see javax.xml.transform.OutputKeys
* @see java.util.Properties
*
* @throws IllegalArgumentException if any of the argument keys are not
* recognized and are not namespace qualified.
*/
public void setOutputProperties(Properties oformat) throws IllegalArgumentException {
synchronized (m_reentryGuard) {
if (null != oformat) {
// See if an *explicit* method was set.
String method = (String) oformat.get(OutputKeys.METHOD);
if (null != method)
m_outputFormat = new OutputProperties(method);
else if (m_outputFormat == null)
m_outputFormat = new OutputProperties();
m_outputFormat.copyFrom(oformat);
// copyFrom does not set properties that have been already set, so
// this must be called after, which is a bit in the reverse from
// what one might think.
m_outputFormat.copyFrom(m_stylesheetRoot.getOutputProperties());
} else {
// if oformat is null JAXP says that any props previously set are removed
// and we are to revert back to those in the templates object (i.e. Stylesheet).
m_outputFormat = null;
}
}
}
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 transformer Non-null transformer instance
* @param ns Namespace URI of the element
* @param localName Local part of name of element
*
* @throws TransformerException
*/
public static void switchSerializerIfHTML(TransformerImpl transformer, String ns, String localName) throws TransformerException {
if (null == transformer)
return;
if (((null == ns) || (ns.length() == 0)) && localName.equalsIgnoreCase("html")) {
// Access at level of hashtable to see if the method has been set.
if (null != transformer.getOutputPropertyNoDefault(OutputKeys.METHOD))
return;
// Getting the output properties this way won't cause a clone of
// the properties.
Properties prevProperties = transformer.getOutputFormat().getProperties();
// 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 {
// Serializer oldSerializer = transformer.getSerializer();
Serializer oldSerializer = null;
if (null != oldSerializer) {
Serializer serializer = SerializerFactory.getSerializer(htmlProperties);
Writer writer = oldSerializer.getWriter();
if (null != writer)
serializer.setWriter(writer);
else {
OutputStream os = oldSerializer.getOutputStream();
if (null != os)
serializer.setOutputStream(os);
}
// transformer.setSerializer(serializer);
ContentHandler ch = serializer.asContentHandler();
transformer.setContentHandler(ch);
}
} catch (java.io.IOException e) {
throw new TransformerException(e);
}
}
}
use of org.apache.xalan.templates.OutputProperties in project robovm by robovm.
the class TransformerImpl method setOutputProperties.
/**
* Set the output properties for the transformation. These
* properties will override properties set in the templates
* with xsl:output.
*
* <p>If argument to this function is null, any properties
* previously set will be removed.</p>
*
* @param oformat A set of output properties that will be
* used to override any of the same properties in effect
* for the transformation.
*
* @see javax.xml.transform.OutputKeys
* @see java.util.Properties
*
* @throws IllegalArgumentException if any of the argument keys are not
* recognized and are not namespace qualified.
*/
public void setOutputProperties(Properties oformat) throws IllegalArgumentException {
synchronized (m_reentryGuard) {
if (null != oformat) {
// See if an *explicit* method was set.
String method = (String) oformat.get(OutputKeys.METHOD);
if (null != method)
m_outputFormat = new OutputProperties(method);
else if (m_outputFormat == null)
m_outputFormat = new OutputProperties();
m_outputFormat.copyFrom(oformat);
// copyFrom does not set properties that have been already set, so
// this must be called after, which is a bit in the reverse from
// what one might think.
m_outputFormat.copyFrom(m_stylesheetRoot.getOutputProperties());
} else {
// if oformat is null JAXP says that any props previously set are removed
// and we are to revert back to those in the templates object (i.e. Stylesheet).
m_outputFormat = null;
}
}
}
use of org.apache.xalan.templates.OutputProperties in project robovm by robovm.
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;
}
Aggregations