当前位置: 首页>>代码示例>>Java>>正文


Java NodeInfo.getLocalPart方法代码示例

本文整理汇总了Java中net.sf.saxon.om.NodeInfo.getLocalPart方法的典型用法代码示例。如果您正苦于以下问题:Java NodeInfo.getLocalPart方法的具体用法?Java NodeInfo.getLocalPart怎么用?Java NodeInfo.getLocalPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.saxon.om.NodeInfo的用法示例。


在下文中一共展示了NodeInfo.getLocalPart方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeNodeInfo

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
private void initializeNodeInfo(@Nullable NodeInfo nodeInfo) {
    if (nodeInfo == null) {
        return;
    }

    int nodeKind = nodeInfo.getNodeKind();
    NodeInfo elemInfo = null;

    if (nodeKind == Type.ATTRIBUTE) {
        this.attrQname = new QName(nodeInfo.getPrefix(), nodeInfo.getURI(), nodeInfo.getLocalPart());

        elemInfo = nodeInfo.getParent();
    } else if (nodeKind == Type.ELEMENT) {
        elemInfo = nodeInfo;
    }

    if (elemInfo == null) {
        return;
    }

    this.elemQname = new QName(elemInfo.getPrefix(), elemInfo.getURI(), elemInfo.getLocalPart());
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:23,代码来源:SdcctLocation.java

示例2: 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;
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:27,代码来源:SaxonEngine.java

示例3: convert

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
@Override
public String convert(NodeInfo source){
    switch(source.getNodeKind()){
        case Node.DOCUMENT_NODE:
            return "";
        case Node.TEXT_NODE:
        case Node.CDATA_SECTION_NODE:
            return "text()";
        case Node.COMMENT_NODE:
            return "comment()";
        case Node.PROCESSING_INSTRUCTION_NODE:
            return "processing-instruction('"+source.getDisplayName() +"')";
        case Node.ELEMENT_NODE:
            String prefix = nsContext.getPrefix(source.getURI());
            String name = source.getLocalPart();
            return StringUtil.isEmpty(prefix) ? name : prefix+':'+name;
        case Node.ATTRIBUTE_NODE:
            if(Namespaces.URI_XMLNS.equals(source.getURI()))
                return "namespace::"+source.getLocalPart();
            prefix = nsContext.getPrefix(source.getURI());
            name = source.getLocalPart();
            return '@'+ (StringUtil.isEmpty(prefix) ? name : prefix+':'+name);
        case NodeType.NAMESPACE:
            return "namespace::"+source.getLocalPart();
        default:
            return null;
    }
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:29,代码来源:SaxonEngine.java

示例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;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:79,代码来源:DiffUtils.java


注:本文中的net.sf.saxon.om.NodeInfo.getLocalPart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。