本文整理汇总了Java中net.sf.saxon.s9api.XdmValue.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java XdmValue.wrap方法的具体用法?Java XdmValue.wrap怎么用?Java XdmValue.wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.s9api.XdmValue
的用法示例。
在下文中一共展示了XdmValue.wrap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import net.sf.saxon.s9api.XdmValue; //导入方法依赖的package包/类
@Override
public XdmValue evaluate() throws SaxonApiException {
try {
return XdmValue.wrap(SequenceExtent.makeSequenceExtent(this.expr.iterate(this.dynamicContext)));
} catch (XPathException e) {
throw new SaxonApiException(e);
}
}
示例2: call
import net.sf.saxon.s9api.XdmValue; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] args) throws XPathException {
XdmValue[] wrappedArgs = new XdmValue[args.length];
for (int a = 0; a < args.length; a++) {
wrappedArgs[a] = XdmValue.wrap(SequenceExtent.makeSequenceExtent(args[a].iterate()));
}
try {
return AbstractCrigttExtensionFunction.this.call(context, ((CrigttController) context.getController()).getContextData(), wrappedArgs)
.getUnderlyingValue();
} catch (Exception e) {
throw new SaxonApiUncheckedException(e);
}
}
示例3: constructAtomicDatatype
import net.sf.saxon.s9api.XdmValue; //导入方法依赖的package包/类
private Datatype constructAtomicDatatype(final QName qn, final boolean allowsEmpty, final boolean allowsMultiple) {
String localName = qn.getLocalName();
StructuredQName baseType = new StructuredQName(qn.getPrefix(), qn.getNamespaceURI(), (allowsMultiple|allowsEmpty) ? localName.substring(0, localName.length()-1) : localName);
BuiltInAtomicType theType = null;
for(BuiltInAtomicType type:ATOMIC_TYPES) {
if(type.getStructuredQName().equals(baseType)) {
theType = type;
break;
}
}
if(theType==null) {
throw new IllegalArgumentException("Unable to determine datatype of "+qn.getEQName());
}
final StringConverter converter = theType.getStringConverter(conversionRules);
return new Datatype() {
@Override
public boolean isAtomic() { return true; }
@Override
public boolean allowsMultiple() { return allowsMultiple; }
@Override
public boolean allowsEmpty() { return allowsEmpty; }
@Override
public XdmValue convert(String input, Configuration configuration) throws ValidationException {
if(input==null && allowsEmpty()) return XdmValue.wrap(null);
else if(input==null) throw new ValidationException(qn.toString()+" does not allow empty sequence");
if(allowsMultiple()) {
String sValue = input.trim();
if(sValue.startsWith("(") && sValue.endsWith(")")) {
sValue = sValue.substring(1, sValue.length()-1);
}
String[] values = sValue.split("[ ]*,[ ]*");
if(values.length>1) {
XdmValue xValue = null;
// certainly could be optimized, but I do not expect having 1000 values in a parameter definition...
for(String value:values) {
XdmValue ret = XdmValue.wrap(converter.convertString(value).asAtomic());
if(xValue==null) {
xValue = ret;
} else {
xValue= xValue.append(ret);
}
}
return xValue;
} else if(values.length==1) {
return XdmValue.wrap(converter.convertString(values[0]).asAtomic());
} else {
throw new ValidationException("can not cast "+input+" to "+qn);
}
} else {
return XdmValue.wrap(converter.convertString(input).asAtomic());
}
}
};
}