/** * Cast a string value to a list type * * @param value the input string value * @param targetType the target list type * @param nsResolver the namespace context, needed if the type is namespace-sensitive * @param rules the conversion rules * @return the sequence of atomic values that results from the conversion * @throws XPathException if the conversion fails */ public static AtomicSequence cast(CharSequence value, ListType targetType, final NamespaceResolver nsResolver, final ConversionRules rules) throws XPathException { ValidationFailure failure = targetType.validateContent(value, nsResolver, rules); if (failure != null) { throw failure.makeException(); } return targetType.getTypedValue(value, nsResolver, rules); }
/** * Invoke the function * * @param context the XPath dynamic evaluation context * @param args the actual arguments to be supplied * @return the result of invoking the function * @throws net.sf.saxon.trans.XPathException * if a dynamic error occurs within the function */ public BooleanValue call(XPathContext context, Sequence[] args) throws XPathException { SequenceIterator iter = args[0].iterate(); AtomicValue val = (AtomicValue) iter.next(); if (val == null) { return BooleanValue.get(allowEmpty); } if (iter.next() != null) { return BooleanValue.FALSE; } if (!(val instanceof StringValue) || val instanceof AnyURIValue) { return BooleanValue.FALSE; } ConversionRules rules = context.getConfiguration().getConversionRules(); CharSequence cs = val.getStringValueCS(); ValidationFailure failure = targetType.validateContent(cs, nsResolver, rules); return BooleanValue.get(failure == null); } }
/** * Invoke the function * * @param context the XPath dynamic evaluation context * @param args the actual arguments to be supplied * @return the result of invoking the function * @throws net.sf.saxon.trans.XPathException * if a dynamic error occurs within the function */ public BooleanValue call(XPathContext context, Sequence[] args) throws XPathException { SequenceIterator iter = args[0].iterate(); AtomicValue val = (AtomicValue) iter.next(); if (val == null) { return BooleanValue.get(allowEmpty); } if (iter.next() != null) { return BooleanValue.FALSE; } if (!(val instanceof StringValue) || val instanceof AnyURIValue) { return BooleanValue.FALSE; } ConversionRules rules = context.getConfiguration().getConversionRules(); CharSequence cs = val.getStringValueCS(); ValidationFailure failure = targetType.validateContent(cs, nsResolver, rules); return BooleanValue.get(failure == null); } }
ValidationFailure failure = targetType.validateContent(cs, nsResolver, rules); if (failure != null) { throw failure.makeException();
ValidationFailure failure = targetType.validateContent(cs, nsResolver, rules); if (failure != null) { throw failure.makeException();