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


Java NodeInfo类代码示例

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


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

示例1: advance

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
private NodeInfo advance() {
	Node nextChild;
	do {
		if (forwards) {
			if (cursor == par.getChildCount()) return null;
			nextChild = par.getChild(cursor++);
		} else { // backwards
			if (cursor == 0) return null;
			nextChild = par.getChild(--cursor);
		}
	} while (nextChild instanceof DocType);
	// DocType is not an XPath node; can occur for /child::node()

	NodeInfo curr = makeWrapper(nextChild, docWrapper, commonParent, ix);
	ix += (forwards ? 1 : -1);
	return curr;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:18,代码来源:NodeWrapper.java

示例2: namespaceProcess

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
private void namespaceProcess(final XdmNode node) {
	final NodeInfo inode = node.getUnderlyingNode();
	final NamespaceBinding[] inscopeNS = inode.getDeclaredNamespaces(null);
	// NamespaceIterator.getInScopeNamespaceCodes(inode);

	if (inscopeNS.length > 0) {
		for (final NamespaceBinding ns : inscopeNS) {
			final String pfx = ns.getPrefix();
			final String uri = ns.getURI();
			this.doc.append(
					AQuiXEvent.getNamespace(QuiXCharStream.fromSequence(pfx), QuiXCharStream.fromSequence(uri)));
		}
	}

	// Careful, we're messing with the namespace bindings
	// Make sure the nameCode is right...
	// int nameCode = inode.getNameCode();
	// int typeCode = inode.getTypeAnnotation() & NamePool.FP_MASK;
	// String pfx = pool.getPrefix(nameCode);
	// String uri = pool.getURI(nameCode);

	// if (excludeDefault && "".equals(pfx) && !usesDefaultNS) {
	// nameCode = pool.allocate("", "", pool.getLocalName(nameCode));
	// }

	// tree.addStartElement(nameCode, typeCode, newNS);
	// tree.addAttributes(node);

}
 
开发者ID:Innovimax-SARL,项目名称:QuiXDM,代码行数:30,代码来源:AXdmNode2QuiXEventStreamConverter.java

示例3: evaluateInternal

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
private NodeInfo evaluateInternal(String pLabel){
  ContextUElem lContextUElem = SaxonEnvironment.getThreadLocalContextUElem();
  DOM lDOM = lContextUElem.getUElem(pLabel);

  if(!lDOM.isAttached()) {
    throw new ExInternal("Node with context label " + pLabel + " is unattached and cannot be used for XPath evaluation");
  }

  return lDOM.wrap();
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:11,代码来源:FoxContextFunction.java

示例4: resolveToString

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
public String resolveToString(List<Parameter> frameworkParameters) throws XPathException, TempContextException {
	//logger.info("resolveToString: " + getScriptName());
	final NodeInfo 	resolvedNode 	= resolve(frameworkParameters);
	final String resolvedString = SaxonNodeWrapper.serializeNode(resolvedNode);
	//logger.info(resolvedString);
	return resolvedString;
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:8,代码来源:XsltConref.java

示例5: resolveToNode

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
public NodeInfo resolveToNode(List<Parameter> frameworkParameters) throws XPathException, TempContextException {
	//logger.info("resolveToNode: " + getScriptName());
	final NodeInfo 	resolvedNode 	= resolve(frameworkParameters);
	NodeInfo 		resolvedElement = resolvedNode.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT).next();
	//logger.info("needsReparse: " + XsltConref.needsReparse(resolvedElement));
	if (XsltConref.needsReparse(resolvedElement)) {
		final String 	serialized 		= SaxonNodeWrapper.serializeNode(resolvedNode);
		try {
			//logger.info("reparsing...");
			//logger.info(serialized);
			final XdmNode 	reparsedNode 	= xsltConrefCache.getDocumentBuilder().buildFromString(serialized, true);
			
			resolvedElement = reparsedNode.getUnderlyingNode().iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT).next();
			//logger.info("---");
			//logger.info(SaxonNodeWrapper.serializeNode(reparsedElement));
		} catch (SaxonApiException e) {
			logger.info("------");
			logger.info("serialized node:");
			logger.info(serialized);
			logger.info("------");
			throw new XPathException("Failed to reparse resolved xslt-conref ('" + getScriptName() + "'): " + e.getMessage());
		}
	} 
	resolvedElement.setSystemId(node.getBaseUrl().toString());
	return resolvedElement;
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:27,代码来源:XsltConref.java

示例6: getChildElementIndexWithinParent

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public int getChildElementIndexWithinParent() {
	final NodeInfo parent = saxonNode.getParent();
	if (parent == null) {
		return -1;
	} else {
		final AxisIterator 	iterator 	= saxonNode.getParent().iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT);
		int index = 1;
		NodeInfo sibling = null;
		do {
			sibling = iterator.next();
			if (saxonNode.getNodeKind() == Type.ELEMENT) {
				if (saxonNode.isSameNodeInfo(sibling)) {
					//logger.info("getChildIndexWithinParent(" + saxonNode.getLocalPart() + "): " + index);
					return index;
				}
				++index;
			}
		}
		while (sibling != null);
	}
	return -1;
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:24,代码来源:SaxonNodeWrapper.java

示例7: evaluateXPathToNode

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
public static NodeInfo evaluateXPathToNode(ElementOverNodeInfo currentElement, String xPath) {
	if(xPath != null) {
		try {
			final SaxonNodeWrapper result = (SaxonNodeWrapper)createSaxonNodeWrapper(currentElement).evaluateXPathToNode(xPath);
			if (result != null) {
				return result.getNodeInfo(); 
			} else {
				return null;
			}
		} catch (Exception e) {
			logger.error(e, e);
			return null;
		}
	} else {
		return null;
	}
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:18,代码来源:SchematronUtil.java

示例8: checkResult

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
private void checkResult(final XsltConref xsltConref, final NodeInfo resolvedElement) {
	
	// check for missing class attribute
	try {
		final XdmNode		context	= new XdmNode(resolvedElement);
		final XPathSelector sel		= otResolver.getXPathCache().getXPathSelector(MISSING_CLASS_XPATH, context);
		final XdmItem item = sel.evaluateSingle();
		if (item != null) {
			String name;
			if (item instanceof XdmNode) {
				name = "node '" + ((XdmNode)item).getNodeName() + "'";
			} else {
				name = "item '" + item.getStringValue() + "'";
			}
			otResolver.getOtLogger().error("[DOT-DITA-SEMIA][ERROR] Missing class attribute in resolved xslt-conref '" + xsltConref.getScriptName() + "'. E.g. on " + name + ".");
		}
		
	} catch (SaxonApiException | XPathException e) {
		logger.error(e.getMessage(), e);
	}
	
	
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:24,代码来源:ResolveXsltConrefCall.java

示例9: call

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
	
	final Item contextItem = context.getContextItem();
	if (!(contextItem instanceof NodeInfo)) {
		throw new XPathException("Context item '" + contextItem.getClass() + "'needs to be an instance of NodeInfo.");
	}
	
	final String 			xPath 			= arguments[0].head().getStringValue();
	final SaxonNodeWrapper 	contextNode 	= new SaxonNodeWrapper((NodeInfo)contextItem, otResolver.getXPathCache());
	final String			resolvedXPath	= EmbeddedXPathResolver.resolve(xPath, contextNode);
	
	return new StringValue(resolvedXPath);
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:15,代码来源:ResolveEmbeddedXPathCall.java

示例10: call

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {

	final SaxonNodeWrapper 	keyRefNode	= new SaxonNodeWrapper((NodeInfo)arguments[0].head(), otResolver.getXPathCache());
	final KeyRef 			keyRef		= KeyRef.fromNode(keyRefNode);
	final Item 				keyDefItem	= arguments[1].head();	

	if ((keyRef == null) || (keyDefItem == null)) {
		return EmptySequence.getInstance();
	} else {
		final KeyDefInterface 	keyDef 			= DitaSemiaOtResolver.getKeyDefFromItem(arguments[1].head());
		final DisplaySuffix		displaySuffix	= keyRef.getDisplaySuffix(keyDef, false);
		final List<Item> 		list 			= new LinkedList<>();
		
		list.add(new StringValue(displaySuffix.keySuffix));
		list.add(new StringValue(displaySuffix.nameSuffix));

		return new SequenceExtent(list);
	}
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:21,代码来源:GetKeyRefDisplaySuffixCall.java

示例11: wrap

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
/**
 * Converts a xom node into something readable by Saxon
 * @param node
 * @param config
 * @return
 */
static NodeInfo wrap(Node node, Configuration config) {
	if (node == null) 
		throw new IllegalArgumentException("node must not be null"); //$NON-NLS-1$
	if (node instanceof DocType)
		throw new IllegalArgumentException("DocType can't be queried by XQuery/XPath"); //$NON-NLS-1$
	
	Node root = node;
	while (root.getParent() != null) {
		root = root.getParent();
	}

	DocumentWrapper docWrapper = new DocumentWrapper(root, root.getBaseURI(), config);
	
	return docWrapper.wrap(node);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:22,代码来源:XQueryEvaluator.java

示例12: call

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {

	String	keyTypeName = null;
	
	final SaxonNodeWrapper 	node 	= new SaxonNodeWrapper((NodeInfo)arguments[0].head(), otResolver.getXPathCache());
	final KeyRef 			keyRef	= KeyRef.fromNode(node);
	if (keyRef != null) {
		keyTypeName = keyRef.getType();
	} else {
		final String ikdType = node.getAttribute(KeyDef.ATTR_TYPE, KeyDef.NAMESPACE_URI);
		if ((ikdType != null) && (!ikdType.isEmpty())) {
			keyTypeName = ikdType;
		}
	}

	Sequence keyTypeElement = cache.get(keyTypeName);
	if (keyTypeElement == null) {
		keyTypeElement = createKeyTypeElement(context, keyTypeName);
		cache.put(keyTypeName, keyTypeElement);
	}

	return keyTypeElement;
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:25,代码来源:GetKeyTypeDefCall.java

示例13: evaluate

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public List<Object> evaluate(TestCase testCase, String file) throws Exception{
    XPathFactoryImpl xpf = new XPathFactoryImpl();
    XPathEvaluator xpe = (XPathEvaluator)xpf.newXPath();
    xpe.getConfiguration().setVersionWarning(false);
    ((StandardErrorListener)xpe.getConfiguration().getErrorListener()).setRecoveryPolicy(Configuration.RECOVER_SILENTLY);
    xpe.getStaticContext().setBackwardsCompatibilityMode(true);
    xpe.setXPathVariableResolver(testCase.variableResolver);
    xpe.setXPathFunctionResolver(testCase.functionResolver);
    xpe.setNamespaceContext(testCase.nsContext);
    NodeInfo doc = xpe.getConfiguration().buildDocument(new SAXSource(new InputSource(file)));

    List<Object> results = new ArrayList<Object>(testCase.xpaths.size());
    for(XPathInfo xpathInfo: testCase.xpaths){
        if(xpathInfo.forEach==null)
            results.add(xpe.evaluate(xpathInfo.xpath, doc, xpathInfo.resultType));
        else{
            List<Object> list = new ArrayList<Object>();
            List nodeList = (List)xpe.evaluate(xpathInfo.forEach, doc, XPathConstants.NODESET);
            for(Object context: nodeList)
                list.add(xpe.evaluate(xpathInfo.xpath, context, xpathInfo.resultType));
            results.add(list);
        }
    }
    return results;
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:27,代码来源:SaxonEngine.java

示例14: serialize

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
protected void serialize(Sequence seq, OutputStream os, Properties outputProperties) throws XPathException {
  String encoding = "UTF-8";
  if (outputProperties != null) {
    encoding = outputProperties.getProperty("encoding", encoding);
  }
  try {
    SequenceIterator iter = seq.iterate(); 
    Item item;
    while ((item = iter.next()) != null) {
      if (item instanceof NodeInfo) {
        serialize((NodeInfo) item, new StreamResult(os), outputProperties);
      } else {
        new OutputStreamWriter(os, encoding).append(item.getStringValue());
      }
    }
  } catch (Exception e) {
    throw new XPathException(e);
  }
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:20,代码来源:ExtensionFunctionCall.java

示例15: sequenceToAttributeCollection

import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
protected Collection<Attribute> sequenceToAttributeCollection(Sequence seq) throws XPathException {
  ArrayList<Attribute> attrs = new ArrayList<Attribute>();
  Item item;
  SequenceIterator iter = seq.iterate();
  while ((item = iter.next()) != null) {                
    Object value;
    String type;
    boolean isSerialized;
    if (item instanceof NodeInfo) {
      value = serialize((NodeInfo) item);
      type = "node()";
      isSerialized = true;
    } else {                             
      value = SequenceTool.convertToJava(item);
      ItemType itemType = Type.getItemType(item, null);
      type = itemType.toString();
      isSerialized = false;
    }
    attrs.add(new Attribute(value, type, isSerialized));
  }
  return attrs;
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:23,代码来源:ExtensionFunctionCall.java


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