本文整理汇总了Java中net.sf.saxon.om.NodeInfo.getStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java NodeInfo.getStringValue方法的具体用法?Java NodeInfo.getStringValue怎么用?Java NodeInfo.getStringValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.om.NodeInfo
的用法示例。
在下文中一共展示了NodeInfo.getStringValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public List<?> translate(Object result, NamespaceContext nsContext){
List nodeList = (List)result;
int i = 0;
for(Object item: nodeList){
if(item instanceof List)
nodeList.set(i, translate(item, nsContext));
else{
NodeInfo node = (NodeInfo)item;
int type = node.getNodeKind();
String value = "";
if(type!=NodeType.DOCUMENT && type!=NodeType.ELEMENT)
value = node.getStringValue();
String localName = node.getLocalPart();
String namespaceURI = node.getURI();
String qualifiedName = node.getDisplayName();
String location = SaxonNavigator.INSTANCE.getXPath(node, nsContext);
NodeItem nodeItem = new NodeItem(type, location, value, localName, namespaceURI, qualifiedName);
nodeItem.xml = node;
nodeList.set(i, nodeItem);
}
i++;
}
return nodeList;
}
示例2: getValueOfChildElementByLocalName
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public static String getValueOfChildElementByLocalName(NodeInfo parentElement, String localName, XPathContext context) {
NodeInfo nodeInfo = parentElement.iterateAxis(AxisInfo.CHILD, new LocalNameTest(context.getNamePool(), Type.ELEMENT, localName)).next();
if (nodeInfo != null) {
return nodeInfo.getStringValue();
}
return null;
}
示例3: getAttribute
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
@Override
public String getAttribute(String local_name) throws HttpClientException {
// get the attribute
NamePool pool = myNode.getConfiguration().getNamePool();
NodeTest pred = new NameTest(Type.ATTRIBUTE, "", local_name, pool);
AxisIterator attrs = myNode.iterateAxis(AxisInfo.ATTRIBUTE, pred);
NodeInfo a = (NodeInfo) attrs.next();
// return its string value, or null if there is no such attribute
if (a == null) {
return null;
} else {
return a.getStringValue();
}
}
示例4: createNodeFromNodeInfo
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public static Node createNodeFromNodeInfo(NodeInfo nodeInfo,
Document doc, DiffXML.WhitespaceStrippingPolicy whitespaceHandling) {
Node node = null;
switch (nodeInfo.getNodeKind()) {
case Type.TEXT:
String content = nodeInfo.getStringValue();
boolean isWhitespace = Whitespace.isWhite(content);
if (isWhitespace && whitespaceHandling.equals(DiffXML.WhitespaceStrippingPolicy.ALL)) {
break;
}
node = doc.createTextNode(content);
break;
case Type.WHITESPACE_TEXT:
content = nodeInfo.getStringValue();
if (whitespaceHandling.equals(DiffXML.WhitespaceStrippingPolicy.ALL)) {
node = doc.createTextNode(content);
}
break;
case Type.ELEMENT:
if (nodeInfo.getURI().equals("")) {
node = doc.createElement(nodeInfo.getLocalPart());
} else {
node = doc.createElementNS(nodeInfo.getURI(), nodeInfo.getLocalPart());
}
AxisIterator namespaces = nodeInfo.iterateAxis(AxisInfo.NAMESPACE);
NodeInfo ns;
while ((ns = namespaces.next()) != null) {
String localPart = ns.getLocalPart();
String qualifiedName;
if (localPart.equals(""))
qualifiedName = "xmlns";
else
qualifiedName = "xmlns:" + localPart;
((Element) node).setAttributeNS("http://www.w3.org/2000/xmlns/", qualifiedName, ns.getStringValue());
}
AxisIterator attrs = nodeInfo.iterateAxis(AxisInfo.ATTRIBUTE);
NodeInfo attr;
while ((attr = attrs.next()) != null) {
if (attr.getURI().equals("")) {
((Element) node).setAttribute(attr.getLocalPart(), attr.getStringValue());
} else if (attr.getURI().equals(Definitions.NAMESPACEURI_DELTAXML) && attr.getLocalPart().equals("whitespace")) {
String value = attr.getStringValue();
try {
whitespaceHandling = WhitespaceStrippingPolicy.valueOf(value);
} catch (Exception e) {
throw new XSLWebException("Value for whitespace handling not supported: \"" + value + "\"");
}
} else {
((Element) node).setAttributeNS(attr.getURI(), attr.getPrefix() + ":" + attr.getLocalPart(), attr.getStringValue());
}
}
break;
/*
case Type.COMMENT:
treeNode = new CommentNode(nodeInfo.getStringValue());
break;
case Type.PROCESSING_INSTRUCTION:
treeNode = new ProcessingInstructionNode(nodeInfo.getStringValue()); // TODO
break;
*/
}
if (node != null && nodeInfo.hasChildNodes()) {
AxisIterator childs = nodeInfo.iterateAxis(AxisInfo.CHILD);
NodeInfo childNodeInfo;
while ((childNodeInfo = childs.next()) != null) {
Node newNode = createNodeFromNodeInfo(childNodeInfo, doc, whitespaceHandling);
if (newNode != null) {
node.appendChild(newNode);
}
}
}
return node;
}