use of org.eclipse.wst.xml.xpath2.api.ResultBuffer in project webtools.sourceediting by eclipse.
the class FnCodepointEqual method codepoint_equals.
/**
* Compare the arguments as codepoints
*
* @param args
* are compared.
* @param dynamicContext
* The current dynamic context
* @throws DynamicError
* Dynamic error.
* @return The result of the comparison of the arguments.
*/
public static ResultSequence codepoint_equals(Collection args, DynamicContext dynamicContext) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultBuffer rs = new ResultBuffer();
Iterator argiter = cargs.iterator();
ResultSequence arg1 = (ResultSequence) argiter.next();
XSString xstr1 = arg1.empty() ? null : (XSString) arg1.first();
ResultSequence arg2 = (ResultSequence) argiter.next();
XSString xstr2 = arg2.empty() ? null : (XSString) arg2.first();
// This delegates to FnCompare
BigInteger result = FnCompare.compare_string(CollationProvider.CODEPOINT_COLLATION, xstr1, xstr2, dynamicContext);
if (result != null)
rs.add(new XSBoolean(BigInteger.ZERO.equals(result)));
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.api.ResultBuffer 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.api.ResultBuffer in project webtools.sourceediting by eclipse.
the class FnID method processAttributes.
private static void processAttributes(Node node, List idrefs, ResultBuffer rs, EvaluationContext context) {
if (!node.hasAttributes()) {
return;
}
NamedNodeMap attributeList = node.getAttributes();
for (int atsub = 0; atsub < attributeList.getLength(); atsub++) {
Attr atNode = (Attr) attributeList.item(atsub);
NodeType atType = new AttrType(atNode, context.getStaticContext().getTypeModel());
if (atType.isID()) {
if (hasIDREF(idrefs, atNode)) {
if (!isDuplicate(node, rs)) {
ElementType element = new ElementType((Element) node, context.getStaticContext().getTypeModel());
rs.add(element);
}
}
}
}
}
use of org.eclipse.wst.xml.xpath2.api.ResultBuffer in project webtools.sourceediting by eclipse.
the class NodeType method addAtomicListItemsToResultSet.
// getTypedValueForSimpleContent
/*
* If the variety of simpleType was 'list', add the typed "list item" values to the parent result set.
*/
private void addAtomicListItemsToResultSet(SimpleTypeDefinition simpType, List itemValueTypes, ResultBuffer rs) {
// tokenize the string value by a 'longest sequence' of white-spaces. this gives us the list items as string values.
String[] listItemsStrValues = getStringValue().split("\\s+");
SimpleTypeDefinition itemType = (SimpleTypeDefinition) simpType.getItemType();
if (itemType.getVariety() == SimpleTypeDefinition.VARIETY_ATOMIC) {
for (int listItemIdx = 0; listItemIdx < listItemsStrValues.length; listItemIdx++) {
// add an atomic typed value (whose type is the "item type" of the list, and "string value" is the "string
// value of the list item") to the "result sequence".
rs.add(SchemaTypeValueFactory.newSchemaTypeValue(PsychoPathTypeHelper.getXSDTypeShortCode(itemType), listItemsStrValues[listItemIdx]));
}
} else if (itemType.getVariety() == SimpleTypeDefinition.VARIETY_UNION) {
// here the list items may have different atomic types
for (int listItemIdx = 0; listItemIdx < listItemsStrValues.length; listItemIdx++) {
String listItem = listItemsStrValues[listItemIdx];
rs.add(SchemaTypeValueFactory.newSchemaTypeValue(((Short) itemValueTypes.get(listItemIdx)).shortValue(), listItem));
}
}
}
use of org.eclipse.wst.xml.xpath2.api.ResultBuffer in project webtools.sourceediting by eclipse.
the class NodeType method linarize.
public static ResultBuffer linarize(ResultBuffer rs) {
TreeSet all = new TreeSet(NODE_COMPARATOR);
all.addAll(rs.getCollection());
return new ResultBuffer().concat(all);
}
Aggregations