本文整理汇总了Java中org.apache.xalan.transformer.TransformerImpl.getSerializationHandler方法的典型用法代码示例。如果您正苦于以下问题:Java TransformerImpl.getSerializationHandler方法的具体用法?Java TransformerImpl.getSerializationHandler怎么用?Java TransformerImpl.getSerializationHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xalan.transformer.TransformerImpl
的用法示例。
在下文中一共展示了TransformerImpl.getSerializationHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructNode
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Construct a node in the result tree. This method is overloaded by
* xsl:attribute. At this class level, this method creates an element.
*
* @param nodeName The name of the node, which may be null.
* @param prefix The prefix for the namespace, which may be null.
* @param nodeNamespace The namespace of the node, which may be null.
* @param transformer non-null reference to the the current transform-time state.
* @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
* @param mode reference, which may be null, to the <a href="http://www.w3.org/TR/xslt#modes">current mode</a>.
*
* @throws TransformerException
*/
void constructNode(
String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer)
throws TransformerException
{
if(null != nodeName && nodeName.length() > 0)
{
SerializationHandler rhandler = transformer.getSerializationHandler();
// Evaluate the value of this attribute
String val = transformer.transformToString(this);
try
{
// Let the result tree handler add the attribute and its String value.
String localName = QName.getLocalPart(nodeName);
if(prefix != null && prefix.length() > 0){
rhandler.addAttribute(nodeNamespace, localName, nodeName, "CDATA", val, true);
}else{
rhandler.addAttribute("", localName, nodeName, "CDATA", val, true);
}
}
catch (SAXException e)
{
}
}
}
示例2: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* The xsl:copy element provides an easy way of copying the current node.
* Executing this function creates a copy of the current node into the
* result tree.
* <p>The namespace nodes of the current node are automatically
* copied as well, but the attributes and children of the node are not
* automatically copied. The content of the xsl:copy element is a
* template for the attributes and children of the created node;
* the content is instantiated only for nodes of types that can have
* attributes or children (i.e. root nodes and element nodes).</p>
* <p>The root node is treated specially because the root node of the
* result tree is created implicitly. When the current node is the
* root node, xsl:copy will not create a root node, but will just use
* the content template.</p>
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(
TransformerImpl transformer)
throws TransformerException
{
XPathContext xctxt = transformer.getXPathContext();
try
{
int sourceNode = xctxt.getCurrentNode();
xctxt.pushCurrentNode(sourceNode);
DTM dtm = xctxt.getDTM(sourceNode);
short nodeType = dtm.getNodeType(sourceNode);
if ((DTM.DOCUMENT_NODE != nodeType) && (DTM.DOCUMENT_FRAGMENT_NODE != nodeType))
{
SerializationHandler rthandler = transformer.getSerializationHandler();
// TODO: Process the use-attribute-sets stuff
ClonerToResultTree.cloneToResultTree(sourceNode, nodeType, dtm,
rthandler, false);
if (DTM.ELEMENT_NODE == nodeType)
{
super.execute(transformer);
SerializerUtils.processNSDecls(rthandler, sourceNode, nodeType, dtm);
transformer.executeChildTemplates(this, true);
String ns = dtm.getNamespaceURI(sourceNode);
String localName = dtm.getLocalName(sourceNode);
transformer.getResultTreeHandler().endElement(ns, localName,
dtm.getNodeName(sourceNode));
}
}
else
{
super.execute(transformer);
transformer.executeChildTemplates(this, true);
}
}
catch(org.xml.sax.SAXException se)
{
throw new TransformerException(se);
}
finally
{
xctxt.popCurrentNode();
}
}