热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

net.sf.saxon.s9api.XPathCompiler.declareNamespace()方法的使用及代码示例

本文整理了Java中net.sf.saxon.s9api.XPathCompiler.declareNamespace()方法的一些代码示例,展示了XPat

本文整理了Java中net.sf.saxon.s9api.XPathCompiler.declareNamespace()方法的一些代码示例,展示了XPathCompiler.declareNamespace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPathCompiler.declareNamespace()方法的具体详情如下:
包路径:net.sf.saxon.s9api.XPathCompiler
类名称:XPathCompiler
方法名:declareNamespace

XPathCompiler.declareNamespace介绍

[英]Declare a namespace binding as part of the static context for XPath expressions compiled using this XPathCompiler
[中]声明命名空间绑定作为使用此XPath编译器编译的XPath表达式的静态上下文的一部分

代码示例

代码示例来源:origin: elsevierlabs-os/spark-xml-utils

while (it.hasNext()) {
Entry entry = it.next();
xpathCompiler.declareNamespace(entry.getKey(), entry.getValue());
xpathCompiler.declareNamespace("xml",NamespaceConstant.XML);
xpathCompiler.declareNamespace("xs",NamespaceConstant.SCHEMA);
xpathCompiler.declareNamespace("fn",NamespaceConstant.FN);

代码示例来源:origin: msokolov/lux

public XPathCompiler getXPathCompiler () {
XPathCompiler xpathCompiler = processor.newXPathCompiler();
xpathCompiler.declareNamespace("lux", FunCall.LUX_NAMESPACE);
return xpathCompiler;
}

代码示例来源:origin: msokolov/lux

/**
* this is primarily for internal use
* @return an XPathCompiler
*/
public XPathCompiler getXPathCompiler () {
if (compiler == null) {
compiler = getProcessor().newXPathCompiler();
for (Entry nsmap : configuration.getNamespaceMap().entrySet()) {
compiler.declareNamespace(nsmap.getKey(), nsmap.getValue());
}
}
return compiler;
}

代码示例来源:origin: stackoverflow.com

private void test(Document doc, String xpathString) throws Exception {
Processor proc = new Processor(false);
XdmNode docNode = proc.newDocumentBuilder().wrap(doc);
XPathCompiler xpath = proc.newXPathCompiler();
xpath.declareNamespace("", "http://www.xfa.org/schema/xfa-template/2.8/");
XdmValue result = xpath.evaluate(xpathString, docNode);
int fieldHits = 0;
for (XdmItem item : result) {
String name = ((XdmNode)node).getNodeName().getLocalName();
fieldHits = "field".equals(name) ? fieldHits + 1 : fieldHits;
}
System.out.println("#hits total: " + nodes.getLength());
System.out.println("#hits 'field': " + fieldHits);
}

代码示例来源:origin: com.taxonic.carml/carml-logical-source-resolver-xpath

private void setNamespaces(LogicalSource logicalSource) {
Object source = logicalSource.getSource();
if (source instanceof XmlSource) {
((XmlSource)source).getDeclaredNamespaces()
.forEach(n -> xpath.declareNamespace(n.getPrefix(), n.getName()));
}
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core

@Override
public XPathExecutable load(ImmutablePair key)
throws Exception {
String xPathQuery = key.left;
String namespacesString = key.right;
Processor processor = XPathUtil.getProcessor();
XPathCompiler xPathCompiler = processor.newXPathCompiler();
List namespacesList = XPathUtil.namespacesParse(namespacesString);
log.debug("Parsed namespaces:{} into list of namespaces:{}", namespacesString, namespacesList);
for (String[] namespaces : namespacesList) {
xPathCompiler.declareNamespace(namespaces[0], namespaces[1]);
}
log.debug("Declared namespaces:{}, now compiling xPathQuery:{}", namespacesList, xPathQuery);
return xPathCompiler.compile(xPathQuery);
}
}

代码示例来源:origin: carml/carml

private void setNamespaces(LogicalSource logicalSource) {
Object source = logicalSource.getSource();
if (source instanceof XmlSource) {
((XmlSource)source).getDeclaredNamespaces()
.forEach(n -> xpath.declareNamespace(n.getPrefix(), n.getName()));
}
}

代码示例来源:origin: stackoverflow.com

Processor proc = new Processor();
XdmNode docw = proc.newDocumentBuilder().wrap(doc);
XPathCompiler xpath = proc.newXPathCompiler();
xpath.declareNamespace("ns", "http://www.example.com/XMLSchema");
XdmValue bookNodes = xpath.evaluate(
"//ns:book[matches(./ns:title, '^ *XML.*?Developer.*?Guide *$', 'i')]", docw);
for (XdmItem book : bookNodes) {
....
}

代码示例来源:origin: org.opengis.cite/schema-utils

/**
* Counts all rule violations: failed asserts and successful reports).
*
* @param results
* The validation results (svrl:schematron-output).
* @return An integer value.
*/
private int countRuleViolations(XdmDestination results) {
XPathCompiler xpath = processor.newXPathCompiler();
xpath.declareNamespace("svrl", ISO_SCHEMATRON_SVRL_NS);
XdmAtomicValue totalCount = null;
try {
XPathExecutable exe = xpath.compile("count(//svrl:failed-assert) + count(//svrl:successful-report)");
XPathSelector selector = exe.load();
selector.setContextItem(results.getXdmNode());
totalCount = (XdmAtomicValue) selector.evaluateSingle();
} catch (SaxonApiException e) {
LOGR.warning(e.getMessage());
}
return Integer.parseInt(totalCount.getValue().toString());
}

代码示例来源:origin: msokolov/lux

XPathCompiler xPathCompiler = getXPathCompiler();
for (Map.Entry e : indexConfig.getNamespaceMap().entrySet()) {
xPathCompiler.declareNamespace(e.getKey(), e.getValue());

代码示例来源:origin: com.xmlcalabash/xmlcalabash

XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
for (String prefix : nsBindings.keySet()) {
xcomp.declareNamespace(prefix, nsBindings.get(prefix));

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
for (String prefix : nsBindings.keySet()) {
xcomp.declareNamespace(prefix, nsBindings.get(prefix));

代码示例来源:origin: org.opengis.cite/ets-cat30

if (null != nsBindings) {
for (String nsURI : nsBindings.keySet()) {
compiler.declareNamespace(nsBindings.get(nsURI), nsURI);

代码示例来源:origin: org.opengis.cite/ets-kml22

if (null != nsBindings) {
for (String nsURI : nsBindings.keySet()) {
compiler.declareNamespace(nsBindings.get(nsURI), nsURI);

代码示例来源:origin: org.opengis.cite/ets-owc10

if (null != nsBindings) {
for (String nsURI : nsBindings.keySet()) {
compiler.declareNamespace(nsBindings.get(nsURI), nsURI);

代码示例来源:origin: com.xmlcalabash/xmlcalabash

private XdmItem computeGroup(XdmNode node) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix));
}
XPathExecutable xexec = xcomp.compile(groupAdjacent.getString());
XPathSelector selector = xexec.load();
selector.setContextItem(node);
Iterator values = selector.iterator();
if (values.hasNext()) {
return values.next();
} else {
return null;
}
} catch (SaxonApiException sae) {
throw new XProcException(sae);
}
}
}

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

private XdmItem computeGroup(XdmNode node) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix));
}
XPathExecutable xexec = xcomp.compile(groupAdjacent.getString());
XPathSelector selector = xexec.load();
selector.setContextItem(node);
Iterator values = selector.iterator();
if (values.hasNext()) {
return values.next();
} else {
return null;
}
} catch (SaxonApiException sae) {
throw new XProcException(sae);
}
}
}

代码示例来源:origin: com.xmlcalabash/xmlcalabash

private String computedLabel(XdmNode node) throws SaxonApiException {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
// Make sure any namespace bindings in-scope for the label are available for the expression
for (String prefix : label.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, label.getNamespaceBindings().get(prefix));
}
xcomp.declareVariable(p_index);
XPathExecutable xexec = xcomp.compile(label.getString());
XPathSelector selector = xexec.load();
selector.setVariable(p_index,new XdmAtomicValue(count++));
selector.setContextItem(node);
Iterator values = selector.iterator();
XdmItem item = values.next();
return item.getStringValue();
}
}

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

private String computedLabel(XdmNode node) throws SaxonApiException {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
// Make sure any namespace bindings in-scope for the label are available for the expression
for (String prefix : label.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, label.getNamespaceBindings().get(prefix));
}
xcomp.declareVariable(p_index);
XPathExecutable xexec = xcomp.compile(label.getString());
XPathSelector selector = xexec.load();
selector.setVariable(p_index,new XdmAtomicValue(count++));
selector.setContextItem(node);
Iterator values = selector.iterator();
XdmItem item = values.next();
return item.getStringValue();
}
}

代码示例来源:origin: org.daisy.maven/xspec-runner

xpathCompiler.declareNamespace("", XSPEC_NAMESPACE);

推荐阅读
author-avatar
liuluoyu
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有