本文整理汇总了Java中org.apache.xml.serializer.SerializationHandler.startElement方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationHandler.startElement方法的具体用法?Java SerializationHandler.startElement怎么用?Java SerializationHandler.startElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.serializer.SerializationHandler
的用法示例。
在下文中一共展示了SerializationHandler.startElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructNode
import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
* Construct a node in the result tree. This method is overloaded by
* xsl:attribute. At this class level, this method creates an element.
* If the node is null, we instantiate only the content of the node in accordance
* with section 7.1.2 of the XSLT 1.0 Recommendation.
*
* @param nodeName The name of the node, which may be <code>null</code>. If <code>null</code>,
* only the non-attribute children of this node will be processed.
* @param prefix The prefix for the namespace, which may be <code>null</code>.
* If not <code>null</code>, this prefix will be mapped and unmapped.
* @param nodeNamespace The namespace of the node, which may be not be <code>null</code>.
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
void constructNode(
String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer)
throws TransformerException
{
boolean shouldAddAttrs;
try
{
SerializationHandler rhandler = transformer.getResultTreeHandler();
if (null == nodeName)
{
shouldAddAttrs = false;
}
else
{
if (null != prefix)
{
rhandler.startPrefixMapping(prefix, nodeNamespace, true);
}
rhandler.startElement(nodeNamespace, QName.getLocalPart(nodeName),
nodeName);
super.execute(transformer);
shouldAddAttrs = true;
}
transformer.executeChildTemplates(this, shouldAddAttrs);
// Now end the element if name was valid
if (null != nodeName)
{
rhandler.endElement(nodeNamespace, QName.getLocalPart(nodeName),
nodeName);
if (null != prefix)
{
rhandler.endPrefixMapping(prefix);
}
}
}
catch (SAXException se)
{
throw new TransformerException(se);
}
}
示例2: copyElement
import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
* Copy an Element node to a SerializationHandler.
*
* @param nodeID The node identity
* @param exptype The expanded type of the Element node
* @param handler The SerializationHandler
* @return The qualified name of the Element node.
*/
protected final String copyElement(int nodeID, int exptype,
SerializationHandler handler)
throws SAXException
{
final ExtendedType extType = m_extendedTypes[exptype];
String uri = extType.getNamespace();
String name = extType.getLocalName();
if (uri.length() == 0) {
handler.startElement(name);
return name;
}
else {
int qnameIndex = m_dataOrQName.elementAt(nodeID);
if (qnameIndex == 0) {
handler.startElement(name);
handler.namespaceAfterStartElement(EMPTY_STR, uri);
return name;
}
if (qnameIndex < 0) {
qnameIndex = -qnameIndex;
qnameIndex = m_data.elementAt(qnameIndex);
}
String qName = m_valuesOrPrefixes.indexToString(qnameIndex);
handler.startElement(qName);
int prefixIndex = qName.indexOf(':');
String prefix;
if (prefixIndex > 0) {
prefix = qName.substring(0, prefixIndex);
}
else {
prefix = null;
}
handler.namespaceAfterStartElement(prefix, uri);
return qName;
}
}