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


Java NodeInfo.getNodeKind方法代码示例

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


在下文中一共展示了NodeInfo.getNodeKind方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: toDOMDocument

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
@Converter
public static Document toDOMDocument(NodeInfo node) throws XPathException {
    switch (node.getNodeKind()) {
    case Type.DOCUMENT:
        // DOCUMENT type nodes can be wrapped directly
        return (Document) NodeOverNodeInfo.wrap(node);
    case Type.ELEMENT:
        // ELEMENT nodes need to build a new DocumentInfo before wrapping
        Configuration config = node.getConfiguration();
        DocumentInfo documentInfo = config.buildDocument(node);
        return (Document) NodeOverNodeInfo.wrap(documentInfo);
    default:
        return null;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:SaxonConverter.java

示例4: createDocumentFromNodeInfo

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public static Document createDocumentFromNodeInfo(NodeInfo nodeInfo, 
    DiffXML.WhitespaceStrippingPolicy whitespaceHandling) throws ParserConfigurationException {
  if (nodeInfo.getNodeKind() == Type.DOCUMENT) {
    nodeInfo = nodeInfo.iterateAxis(AxisInfo.CHILD).next();
  }
  DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); 
  docFactory.setNamespaceAware(true);
  docFactory.setValidating(false);
  // docFactory.setExpandEntityReferences(true);
  Document doc = docFactory.newDocumentBuilder().newDocument();
  doc.setStrictErrorChecking(true); // TODO
  doc.appendChild(createNodeFromNodeInfo(nodeInfo, doc, whitespaceHandling));
  return doc;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:15,代码来源:DiffUtils.java

示例5: SaxonElement

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public SaxonElement(NodeInfo node, XPathContext ctxt) throws HttpClientException {
  if (node == null) {
    throw new HttpClientException("the node is null");
  }
  if (node.getNodeKind() != Type.ELEMENT) {
    throw new HttpClientException("the node is not an element");
  }
  myNode = node;
  myCtxt = ctxt;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:11,代码来源:SaxonElement.java

示例6: isNull

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public static boolean isNull(Item i) {
	if (i instanceof NodeInfo) {
		NodeInfo ni = (NodeInfo)i;
		return ni.getNodeKind() == net.sf.saxon.type.Type.ELEMENT && !ni.hasChildNodes() && Boolean.valueOf(ni.getAttributeValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "nil")); //$NON-NLS-1$
		/* ideally we'd be able to check for nilled, but that doesn't work without validation
		 if (ni.isNilled()) {
			tuple.add(null);
			continue;
		}*/
	}
	return false;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:13,代码来源:XMLSystemFunctions.java

示例7: getType

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public static XMLType.Type getType(NodeInfo info) {
	switch (info.getNodeKind()) {
		case net.sf.saxon.type.Type.DOCUMENT:
			return Type.DOCUMENT;
		case net.sf.saxon.type.Type.ELEMENT:
			return Type.ELEMENT;
		case net.sf.saxon.type.Type.TEXT:
			return Type.TEXT;
		case net.sf.saxon.type.Type.COMMENT:
			return Type.COMMENT;
		case net.sf.saxon.type.Type.PROCESSING_INSTRUCTION:
			return Type.PI;
	}
	return Type.CONTENT;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:16,代码来源:SaxonXQueryExpression.java

示例8: convert

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
@Override
public String convert(NodeInfo source){
    switch(source.getNodeKind()){
        case NodeType.ATTRIBUTE:
        case NodeType.NAMESPACE:
            return delegate.convert(source);
    }
    return super.convert(source);
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:10,代码来源:SaxonEngine.java

示例9: parseNode

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
private void parseNode(NodeInfo node, TopicRefContainer parentTopicRefContainer, String parentTopicId) throws TransformerException {
	//logger.info("parseNode: " + node/*.getUnderlyingNode()*/.getDisplayName() + ", " + node.getNodeKind());
	//if (node.getNodeKind() == XdmNodeKind.ELEMENT) {
	if (node.getNodeKind() == Type.ELEMENT) {
		
		final SaxonNodeWrapper nodeWrapper = new SaxonNodeWrapper(node/*.getUnderlyingNode()*/, bookCache.getXPathCache());
		
		final KeyDef keyDef = KeyDef.fromNode(nodeWrapper, parentTopicId);
		if (keyDef != null) {
			keyDefList.add(keyDef);
			bookCache.addKeyDef(keyDef);
		}
		
		final XsltConref xsltConref = XsltConref.fromNode(nodeWrapper, xsltConrefCache);
		if (xsltConref != null) {
			processXsltConref(xsltConref, parentTopicRefContainer, parentTopicId);
		}
		
		final String classAttr = nodeWrapper.getAttribute(DitaUtil.ATTR_CLASS, null);

		//logger.info("parsing element: <" + nodeWrapper.getName() + " class=\"" + classAttr + "\">");

		if (classAttr != null) {
			final TopicRef topicRef = parseTopicRef(nodeWrapper, classAttr, parentTopicRefContainer);
			if (topicRef != null) {
				parentTopicRefContainer = topicRef;	// take it as new parent for child nodes.
			}
			parseKeyTypeDefNode(nodeWrapper, classAttr);
			
			final String id = nodeWrapper.getAttribute(DitaUtil.ATTR_ID, null);
			if ((id != null) && (!id.isEmpty())) {
				if (classAttr.contains(DitaUtil.CLASS_TOPIC)) {
					addElementId(nodeWrapper, null, id);
					parentTopicId = id;
				} else {
					addElementId(nodeWrapper, parentTopicId, id);
				}
			}
		}

		final AxisIterator 	iterator 	= node.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT);
		NodeInfo child = iterator.next();
		while (child != null) {
			parseNode(child, parentTopicRefContainer, parentTopicId);
			child = iterator.next();
		}
	}
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:49,代码来源:FileCache.java

示例10: unwrapNodeInfo

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
protected NodeInfo unwrapNodeInfo(NodeInfo nodeInfo) {
  if (nodeInfo != null && nodeInfo.getNodeKind() == Type.DOCUMENT) {
    nodeInfo = nodeInfo.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT).next();
  }
  return nodeInfo;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:7,代码来源:ExtensionFunctionCall.java

示例11: 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

示例12: buildSegments

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
private static LinkedList<ContentPathSegment<?, ?>> buildSegments(LinkedList<ContentPathSegment<?, ?>> segments, NodeInfo nodeInfo,
    @Nullable String nsPrefix, @Nullable String nsUri, String localName) {
    boolean attrNode = (nodeInfo.getNodeKind() == Type.ATTRIBUTE);

    if (attrNode) {
        segments.add(0, new AttributePathSegmentImpl(nsPrefix, nsUri, localName));
    }

    ElementPathSegment elemSegment = new ElementPathSegmentImpl(nsPrefix, nsUri, localName);
    segments.add(0, elemSegment);

    NodeInfo parentNodeInfo = nodeInfo.getParent();

    if ((parentNodeInfo != null) && (parentNodeInfo.getNodeKind() != Type.DOCUMENT)) {
        if (!attrNode) {
            int nodeIndex = -1;
            SameNameTest siblingNodeTest = new SameNameTest(nodeInfo);
            AxisIterator precedingSiblingNodeIterator = nodeInfo.iterateAxis(AxisInfo.PRECEDING_SIBLING, siblingNodeTest);

            while (precedingSiblingNodeIterator.next() != null) {
                nodeIndex++;
            }

            if (nodeIndex == -1) {
                if (nodeInfo.iterateAxis(AxisInfo.FOLLOWING_SIBLING, siblingNodeTest).next() != null) {
                    nodeIndex = 0;
                }
            } else {
                nodeIndex++;
            }

            if (nodeIndex >= 0) {
                elemSegment.setIndex(nodeIndex);
            }
        }

        buildSegments(segments, parentNodeInfo, parentNodeInfo.getPrefix(), parentNodeInfo.getURI(), parentNodeInfo.getLocalPart());
    }

    return segments;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:42,代码来源:ContentPathBuilderImpl.java

示例13: getXPath

import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public String getXPath(NodeInfo node, NamespaceContext nsContext){
    if(node.getNodeKind()==NodeType.DOCUMENT)
        return "/";
    else
        return getPath(node, new XPathConvertor(nsContext), "/");
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:7,代码来源:SaxonEngine.java


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