use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnCollection method collection.
/**
* Doc operation.
*
* @param args
* Result from the expressions evaluation.
* @param dc
* Result of dynamic context operation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:doc operation.
*/
public static ResultSequence collection(Collection args, EvaluationContext ec) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get args
Iterator argiter = cargs.iterator();
ResultSequence arg1 = null;
String uri = DEFAULT_COLLECTION_URI;
if (argiter.hasNext()) {
arg1 = (ResultSequence) argiter.next();
uri = ((XSString) arg1.first()).value();
}
try {
new URI(uri);
} catch (URISyntaxException ex) {
throw DynamicError.doc_not_found(null);
}
if (uri.indexOf(":") < 0) {
throw DynamicError.invalidCollectionArgument();
}
URI resolved = ec.getDynamicContext().resolveUri(uri);
if (resolved == null)
throw DynamicError.invalid_doc(null);
ResultSequence rs = getCollection(uri, ec);
if (rs.empty())
throw DynamicError.doc_not_found(null);
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnCollection method expected_args.
/**
* Obtain a list of expected arguments.
*
* @return Result of operation.
*/
public static synchronized Collection expected_args() {
if (_expected_args == null) {
_expected_args = new ArrayList();
SeqType arg = new SeqType(new XSString(), SeqType.OCC_QMARK);
_expected_args.add(arg);
}
return _expected_args;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnConcat method concat.
/**
* Concatenate the arguments.
*
* @param args
* are concatenated.
* @throws DynamicError
* Dynamic error.
* @return The result of the concatenation of the arguments.
*/
public static ResultSequence concat(Collection args) throws DynamicError {
// sanity check
if (args.size() < 2)
DynamicError.throw_type_error();
ResultBuffer rs = new ResultBuffer();
String result = "";
// go through args
StringBuffer buf = new StringBuffer();
for (Iterator argi = args.iterator(); argi.hasNext(); ) {
ResultSequence arg = (ResultSequence) argi.next();
int size = arg.size();
// sanity check
if (size > 1)
DynamicError.throw_type_error();
if (size == 0) {
continue;
}
Item at = arg.first();
buf.append(at.getStringValue());
}
result = buf.toString();
rs.add(new XSString(result));
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnDoc method doc.
/**
* Doc operation.
*
* @param args
* Result from the expressions evaluation.
* @param dc
* Result of dynamic context operation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:doc operation.
*/
public static ResultSequence doc(Collection args, EvaluationContext ec) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get args
Iterator argiter = cargs.iterator();
ResultSequence arg1 = (ResultSequence) argiter.next();
if (arg1.empty())
return ResultSequenceFactory.create_new();
String uri = ((XSString) arg1.item(0)).value();
DynamicContext dc = ec.getDynamicContext();
URI resolved = dc.resolveUri(uri);
if (resolved == null)
throw DynamicError.invalid_doc(null);
Document doc = dc.getDocument(resolved);
if (doc == null)
throw DynamicError.doc_not_found(null);
return new DocType(doc, ec.getStaticContext().getTypeModel());
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSString in project webtools.sourceediting by eclipse.
the class FnDoc method expected_args.
/**
* Obtain a list of expected arguments.
*
* @return Result of operation.
*/
public static synchronized Collection expected_args() {
if (_expected_args == null) {
_expected_args = new ArrayList();
SeqType arg = new SeqType(new XSString(), SeqType.OCC_QMARK);
_expected_args.add(arg);
}
return _expected_args;
}
Aggregations