本文整理汇总了Java中org.jaxen.BaseXPath.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java BaseXPath.evaluate方法的具体用法?Java BaseXPath.evaluate怎么用?Java BaseXPath.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jaxen.BaseXPath
的用法示例。
在下文中一共展示了BaseXPath.evaluate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLangFunctionAppliedToDocument
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testLangFunctionAppliedToDocument()
throws JaxenException {
BaseXPath xpath = new DOMXPath("lang('fr')");
Element a = doc.createElementNS("", "a");
Element b = doc.createElementNS("", "b");
b.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang", "fr-CA");
doc.appendChild(a);
a.appendChild(b);
Element x2 = doc.createElementNS("", "x");
Element x3 = doc.createElementNS("", "x");
Element x4 = doc.createElementNS("", "x");
a.appendChild(x4);
b.appendChild(x2);
b.appendChild(x3);
x2.appendChild(doc.createTextNode("fr"));
x3.appendChild(doc.createTextNode("3"));
x4.appendChild(doc.createTextNode("4"));
Boolean result = (Boolean) xpath.evaluate(doc);
assertEquals(Boolean.FALSE, result);
}
示例2: testNaNIsFalse
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testNaNIsFalse()
throws JaxenException {
BaseXPath xpath = new DOMXPath("not(0 div 0)");
Object result = xpath.evaluate(null);
assertEquals(Boolean.TRUE, result);
}
示例3: testNaNIsFalse
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testNaNIsFalse()
throws JaxenException {
BaseXPath xpath = new DOMXPath("boolean(0 div 0)");
Object result = xpath.evaluate(null);
assertEquals(Boolean.FALSE, result);
}
示例4: testCountRootElement
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testCountRootElement()
throws JaxenException {
BaseXPath xpath = new DOMXPath("count(/*)");
Double result = (Double) xpath.evaluate(doc);
assertEquals(1.0, result.doubleValue(), 0.00001);
}
示例5: testStringLengthFunctionOperatesOnContextNode
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testStringLengthFunctionOperatesOnContextNode()
throws JaxenException {
BaseXPath xpath = new DOMXPath("string-length()");
Double result = (Double) xpath.evaluate( doc );
assertEquals(0, result.intValue());
}
示例6: testStringLengthFunctionCountsUnicodeCharactersNotJavaChars
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testStringLengthFunctionCountsUnicodeCharactersNotJavaChars()
throws JaxenException {
BaseXPath xpath = new DOMXPath("string-length('\uD834\uDD00')");
Double result = (Double) xpath.evaluate( doc );
assertEquals(1, result.intValue());
}
示例7: testStringLengthFunctionWithMalformedString
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testStringLengthFunctionWithMalformedString()
throws JaxenException {
BaseXPath xpath = new DOMXPath("string-length('\uD834A\uDD00')");
try {
xpath.evaluate( doc );
fail("Allowed Malformed string");
}
catch (FunctionCallException ex) {
assertNotNull(ex.getMessage());
}
}
示例8: testFloor
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testFloor() throws JaxenException {
BaseXPath xpath = new DOMXPath("floor(1.5)");
Object result = xpath.evaluate(doc);
assertEquals(1, ((Double) result).doubleValue(), 0.0001);
}
示例9: testNegativeFloor
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testNegativeFloor() throws JaxenException {
BaseXPath xpath = new DOMXPath("floor(-1.5)");
Object result = xpath.evaluate(doc);
assertEquals(-2, ((Double) result).doubleValue(), 0.0001);
}
示例10: testEvaluateString
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testEvaluateString() throws JaxenException {
BaseXPath xpath = new DOMXPath("string(/*)");
doc.appendChild(doc.createElement("root"));
String stringValue = (String) xpath.evaluate(doc);
assertEquals("", stringValue);
}
示例11: testEvaluateWithMultiNodeAnswer
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testEvaluateWithMultiNodeAnswer() throws JaxenException {
BaseXPath xpath = new DOMXPath("(/descendant-or-self::node())");
doc.appendChild(doc.createElement("root"));
List result = (List) xpath.evaluate(doc);
assertEquals(2, result.size());
}
示例12: testCeiling
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testCeiling() throws JaxenException {
BaseXPath xpath = new DOMXPath("ceiling(1.5)");
Object result = xpath.evaluate(doc);
assertEquals(2, ((Double) result).doubleValue(), 0.0001);
}
示例13: testNegativeCeiling
import org.jaxen.BaseXPath; //导入方法依赖的package包/类
public void testNegativeCeiling() throws JaxenException {
BaseXPath xpath = new DOMXPath("ceiling(-1.5)");
Object result = xpath.evaluate(doc);
assertEquals(-1, ((Double) result).doubleValue(), 0.0001);
}