本文整理汇总了Java中net.sf.saxon.om.NodeInfo类的典型用法代码示例。如果您正苦于以下问题:Java NodeInfo类的具体用法?Java NodeInfo怎么用?Java NodeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeInfo类属于net.sf.saxon.om包,在下文中一共展示了NodeInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: call
import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
NodeInfo cookieElem = unwrapNodeInfo((NodeInfo) arguments[0].head());
String comment = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "comment", context);
String domain = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "domain", context);
String maxAge = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "max-age", context);
String name = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "name", context);
String path = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "path", context);
String isSecure = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "is-secure", context);
String value = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "value", context);
String version = NodeInfoUtils.getValueOfChildElementByLocalName(cookieElem, "version", context);
Cookie cookie = new Cookie(name, value);
if (comment != null) cookie.setComment(comment);
if (domain != null) cookie.setDomain(domain);
if (maxAge != null) cookie.setMaxAge(Integer.parseInt(maxAge));
if (path != null) cookie.setPath(path);
if (isSecure != null) cookie.setSecure(Boolean.parseBoolean(isSecure));
if (version != null) cookie.setVersion(Integer.parseInt(version));
getResponse(context).addCookie(cookie);
return EmptySequence.getInstance();
}
开发者ID:Armatiek,项目名称:xslweb,代码行数:22,代码来源:AddCookie.java
示例17: call
import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public StringValue call(XPathContext context, Sequence[] arguments) throws XPathException {
StringWriter sw = new StringWriter();
JsonXMLConfig config = new JsonXMLConfigBuilder().
prettyPrint(true).
build();
XMLOutputFactory jFactory = new JsonXMLOutputFactory(config);
TransformerFactory tFactory = new TransformerFactoryImpl();
try {
SequenceIterator iter = arguments[0].iterate();
Item item;
while ((item = iter.next()) != null) {
if (item instanceof NodeInfo) {
Transformer transformer = tFactory.newTransformer();
XMLStreamWriter xsw = jFactory.createXMLStreamWriter(sw);
transformer.transform((NodeInfo) item, new StAXResult(xsw));
} else {
sw.append(item.getStringValue());
}
}
} catch (Exception e) {
throw new XPathException("Error serializing sequence to JSON", e);
}
return StringValue.makeStringValue(sw.toString());
}
开发者ID:Armatiek,项目名称:xslweb,代码行数:26,代码来源:SerializeJSON.java
示例18: call
import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public StringValue call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
String queueName = ((StringValue) arguments[0].head()).getStringValue();
String path = ((StringValue) arguments[1].head()).getStringValue();
String extraInfo = arguments.length > 2 ? serialize((NodeInfo) arguments[2].head()) : null;
WebApp webApp = getWebApp(context);
ExecutorService service = webApp.getExecutorService(queueName);
String ticket = UUID.randomUUID().toString();
File queueDir = Context.getInstance().getQueueDir();
if (!queueDir.isDirectory() && !queueDir.mkdirs())
throw new IOException("Could not create queue directory \"" + queueDir.getAbsolutePath() + "\"");
File lockFile = new File(queueDir, ticket + ".lck");
FileUtils.touch(lockFile);
try {
service.execute(new QueuedRequest(ticket, webApp.getPath() + "/" + path, extraInfo));
} catch (RejectedExecutionException ree) {
FileUtils.deleteQuietly(lockFile);
return StringValue.makeStringValue("rejected");
}
return StringValue.makeStringValue(ticket);
} catch (IOException e) {
throw new XPathException("Error adding asynchronous request", e);
}
}
开发者ID:Armatiek,项目名称:xslweb,代码行数:26,代码来源:AddRequest.java
示例19: call
import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public ZeroOrOne<NodeInfo> call(XPathContext context, Sequence[] arguments) throws XPathException {
if (arguments.length == 0) {
return new ZeroOrOne<NodeInfo>(null);
}
TreeInfo doc = ((TinyDocumentImpl) arguments[0].head()).getTreeInfo();
if (doc == null) {
return new ZeroOrOne<NodeInfo>(null);
}
Controller c = context.getController();
String uri = c.getDocumentPool().getDocumentURI(doc.getRootNode());
if (uri != null) {
c.removeUnavailableOutputDestination(new DocumentURI(uri));
}
c.getDocumentPool().discard(doc);
return new ZeroOrOne<NodeInfo>(doc.getRootNode());
}
开发者ID:Armatiek,项目名称:xslweb,代码行数:18,代码来源:DiscardDocument.java
示例20: call
import net.sf.saxon.om.NodeInfo; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] params) throws XPathException {
NodeInfo request = null;
String href = null;
SequenceIterator bodies = null;
switch (params.length) {
case 3:
bodies = params[2].iterate();
case 2:
href = getHref(params[1].iterate());
case 1:
request = getRequest(params[0].iterate());
break;
default:
throw new XPathException("Incorrect number of params: " + params.length);
}
return SequenceTool.toLazySequence(HttpClient.sendRequest(context, request, href, bodies, getWebApp(context).getHttpClient()));
}
开发者ID:Armatiek,项目名称:xslweb,代码行数:19,代码来源:SendRequestCall.java
注:本文中的net.sf.saxon.om.NodeInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论