| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.expr; |
| 9 |
|
| 10 |
import net.sf.saxon.lib.ConversionRules; |
| 11 |
import net.sf.saxon.om.NamespaceResolver; |
| 12 |
import net.sf.saxon.om.Sequence; |
| 13 |
import net.sf.saxon.om.SequenceIterator; |
| 14 |
import net.sf.saxon.om.StructuredQName; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
import net.sf.saxon.type.*; |
| 17 |
import net.sf.saxon.value.*; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public class ListCastableFunction extends ListConstructorFunction { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
public ListCastableFunction(ListType targetType, NamespaceResolver resolver, boolean allowEmpty) throws MissingComponentException { |
| 33 |
super(targetType, resolver, allowEmpty); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public FunctionItemType getFunctionItemType() { |
| 42 |
return new SpecificFunctionType( |
| 43 |
new SequenceType[]{SequenceType.ANY_SEQUENCE}, |
| 44 |
SequenceType.SINGLE_BOOLEAN); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public StructuredQName getFunctionName() { |
| 53 |
return null; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public BooleanValue call(XPathContext context, Sequence[] args) throws XPathException { |
| 66 |
SequenceIterator iter = args[0].iterate(); |
| 67 |
AtomicValue val = (AtomicValue) iter.next(); |
| 68 |
if (val == null) { |
| 69 |
return BooleanValue.get(allowEmpty); |
| 70 |
} |
| 71 |
if (iter.next() != null) { |
| 72 |
return BooleanValue.FALSE; |
| 73 |
} |
| 74 |
if (!(val instanceof StringValue) || val instanceof AnyURIValue) { |
| 75 |
return BooleanValue.FALSE; |
| 76 |
} |
| 77 |
|
| 78 |
ConversionRules rules = context.getConfiguration().getConversionRules(); |
| 79 |
CharSequence cs = val.getStringValueCS(); |
| 80 |
ValidationFailure failure = targetType.validateContent(cs, nsResolver, rules); |
| 81 |
return BooleanValue.get(failure == null); |
| 82 |
} |
| 83 |
} |
| 84 |
|