本文整理汇总了Java中net.sf.saxon.query.DynamicQueryContext.setApplyFunctionConversionRulesToExternalVariables方法的典型用法代码示例。如果您正苦于以下问题:Java DynamicQueryContext.setApplyFunctionConversionRulesToExternalVariables方法的具体用法?Java DynamicQueryContext.setApplyFunctionConversionRulesToExternalVariables怎么用?Java DynamicQueryContext.setApplyFunctionConversionRulesToExternalVariables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.query.DynamicQueryContext
的用法示例。
在下文中一共展示了DynamicQueryContext.setApplyFunctionConversionRulesToExternalVariables方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPersonQuery
import net.sf.saxon.query.DynamicQueryContext; //导入方法依赖的package包/类
@Test
public void testPersonQuery() throws XPathException, XQException {
Configuration config = Configuration.newConfiguration();
StaticQueryContext sqc = config.newStaticQueryContext();
DynamicQueryContext dqc = new DynamicQueryContext(config);
dqc.setApplyFunctionConversionRulesToExternalVariables(false);
String query = "declare base-uri \"../../etc/samples/xmark/\";\n" +
"let $auction := fn:doc(\"auction.xml\") return\n" +
"for $b in $auction/site/people/person[@id = 'person0'] return $b/name/text()";
//dqc.setParameter(new StructuredQName("", "", "v"), objectToItem(Boolean.TRUE, config));
XQueryExpression xqExp = sqc.compileQuery(query);
SequenceIterator itr = xqExp.iterator(dqc);
Item item = itr.next();
assertNotNull(item);
String val = item.getStringValue();
assertEquals("Huei Demke", val);
assertNull(itr.next());
}
示例2: testCollationQuery
import net.sf.saxon.query.DynamicQueryContext; //导入方法依赖的package包/类
@Test
public void testCollationQuery() throws XPathException {
Configuration config = Configuration.newConfiguration();
StaticQueryContext sqc = config.newStaticQueryContext();
// this causes Saxon throw NPE and query processing!
//sqc.declareDefaultCollation("");
DynamicQueryContext dqc = new DynamicQueryContext(config);
dqc.setApplyFunctionConversionRulesToExternalVariables(false);
String query = "declare base-uri \"../../etc/samples/xmark/\";\n" +
"let $auction := fn:doc(\"auction.xml\") return\n" +
"for $i in $auction/site//item\n" +
"where contains(string(exactly-one($i/description)), \"gold\")\n" +
"return $i/name/text()";
XQueryExpression xqExp = sqc.compileQuery(query);
SequenceIterator itr = xqExp.iterator(dqc);
Item item = itr.next();
assertNotNull(item);
assertNotNull(item.getStringValue());
}
示例3: XQProcessorImpl
import net.sf.saxon.query.DynamicQueryContext; //导入方法依赖的package包/类
public XQProcessorImpl() {
config = Configuration.newConfiguration();
//config.setSchemaValidationMode(Validation.STRIP);
//config.setConfigurationProperty(FeatureKeys.PRE_EVALUATE_DOC_FUNCTION, Boolean.TRUE);
sqc = config.newStaticQueryContext();
// supported in Saxon-EE only
//sqc.setUpdatingEnabled(true);
dqc = new DynamicQueryContext(config);
dqc.setApplyFunctionConversionRulesToExternalVariables(false);
//sqc. cvr = new StandardObjectConverter();
//JPConverter.allocate(XQItem.class, null, config);
}
示例4: testMapQuery
import net.sf.saxon.query.DynamicQueryContext; //导入方法依赖的package包/类
@Test
public void testMapQuery() throws XPathException {
Configuration config = Configuration.newConfiguration();
config.setDefaultCollection("");
StaticQueryContext sqc = config.newStaticQueryContext();
DynamicQueryContext dqc = new DynamicQueryContext(config);
dqc.setApplyFunctionConversionRulesToExternalVariables(false);
//String xml = "<map>\n" +
// " <boolProp>false</boolProp>\n" +
// " <strProp>XYZ</strProp>\n" +
// " <intProp>1</intProp>\n" +
// "</map>";
//String baseURI = sqc.getBaseURI();
//StringReader sr = new StringReader(xml);
//InputSource is = new InputSource(sr);
//is.setSystemId(baseURI);
//Source source = new SAXSource(is);
//source.setSystemId(baseURI);
//config.getGlobalDocumentPool().add(config.buildDocumentTree(source), "map.xml");
String query = "declare base-uri \"../../etc/samples/xdm/\";\n" +
"declare variable $value external;\n" +
"for $doc in fn:collection()/map\n" +
"where $doc/intProp = $value\n" +
//"where $doc[intProp = $value]\n" +
"return $doc/strProp/text()";
XQueryExpression xqExp = sqc.compileQuery(query);
dqc.setParameter(new StructuredQName("", "", "value"), objectToItem(1, config));
SequenceIterator itr = xqExp.iterator(dqc);
Item item = itr.next();
assertNotNull(item);
String val = item.getStringValue();
assertEquals("XYZ", val);
assertNull(itr.next());
}
示例5: testJsonQuery
import net.sf.saxon.query.DynamicQueryContext; //导入方法依赖的package包/类
@Test
@Ignore
public void testJsonQuery() throws XPathException {
Configuration config = Configuration.newConfiguration();
config.setDefaultCollection("");
StaticQueryContext sqc = config.newStaticQueryContext();
sqc.setLanguageVersion(saxon_xquery_version);
DynamicQueryContext dqc = new DynamicQueryContext(config);
dqc.setApplyFunctionConversionRulesToExternalVariables(false);
String query = "declare base-uri \"../../etc/samples/json/\";\n" +
//"declare base-uri \"C:/Work/Bagri/git/bagri/etc/samples/json/\";\n" +
"declare namespace map=\"http://www.w3.org/2005/xpath-functions/map\";\n" +
//"declare variable $value external;\n" +
"for $map in fn:collection()\n" +
//"where $map?Security?Symbol = $value\n" +
"let $v := map:get($map, 'Security')\n" +
//"where get($map, '-id') = '5621'\n" +
"where map:get($v, 'Symbol') = 'IBM'\n" +
"return $v?Name";
XQueryExpression xqExp = sqc.compileQuery(query);
//dqc.setParameter(new StructuredQName("", "", "value"), objectToItem("IBM", config));
SequenceIterator itr = xqExp.iterator(dqc);
Item item = itr.next();
assertNotNull(item);
String val = item.getStringValue();
assertEquals("Internatinal Business Machines Corporation", val);
assertNull(itr.next());
}