use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnBaseUri method getBaseUri.
/*
* Helper function for base-uri support
*/
public static ResultSequence getBaseUri(Item att) {
ResultBuffer rs = new ResultBuffer();
XSAnyURI baseUri = null;
if (att instanceof NodeType) {
NodeType node = (NodeType) att;
Node domNode = node.node_value();
String buri = domNode.getBaseURI();
if (buri != null) {
baseUri = new XSAnyURI(buri);
} else {
baseUri = new XSAnyURI("null");
}
}
if (baseUri != null) {
rs.add(baseUri);
}
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnLang method lang.
/**
* Language operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:lang operation.
*/
public static ResultSequence lang(Collection args, EvaluationContext ec) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get arg
Iterator citer = cargs.iterator();
ResultSequence arg1 = (ResultSequence) citer.next();
ResultSequence arg2 = null;
if (cargs.size() == 1) {
if (ec.getContextItem() == null) {
throw DynamicError.contextUndefined();
}
arg2 = (AnyType) ec.getContextItem();
} else {
arg2 = (ResultSequence) citer.next();
}
String lang = "";
if (!arg1.empty()) {
lang = ((XSString) arg1.first()).value();
}
if (!(arg2.first() instanceof NodeType)) {
throw DynamicError.invalidType();
}
NodeType an = (NodeType) arg2.first();
return new XSBoolean(test_lang(an.node_value(), lang));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnName method name.
/**
* Name operation.
*
* @param args
* Result from the expressions evaluation.
* @param context
* Dynamic context.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:name operation.
*/
public static ResultSequence name(Collection args, EvaluationContext ec) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get arg
ResultSequence arg1 = null;
if (cargs.isEmpty()) {
if (ec.getContextItem() == null)
throw DynamicError.contextUndefined();
else {
arg1 = ResultBuffer.wrap(ec.getContextItem());
}
} else {
arg1 = (ResultSequence) cargs.iterator().next();
}
if (arg1.empty()) {
return new XSString("");
}
NodeType an = (NodeType) arg1.first();
QName name = an.node_name();
String sname = "";
if (name != null)
sname = name.getStringValue();
return new XSString(sname);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnNilled method nilled.
/**
* Nilled operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:nilled operation.
*/
public static ResultSequence nilled(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return arg1;
}
NodeType nt = (NodeType) arg1.first();
return nt.nilled();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnID method id.
/**
* Insert-Before operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:insert-before operation.
*/
public static ResultSequence id(Collection args, EvaluationContext context) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultBuffer rs = new ResultBuffer();
Iterator argIt = cargs.iterator();
ResultSequence idrefRS = (ResultSequence) argIt.next();
String[] idrefst = idrefRS.first().getStringValue().split(" ");
ArrayList idrefs = createIDRefs(idrefst);
ResultSequence nodeArg = null;
NodeType nodeType = null;
if (argIt.hasNext()) {
nodeArg = (ResultSequence) argIt.next();
nodeType = (NodeType) nodeArg.first();
} else {
if (context.getContextItem() == null) {
throw DynamicError.contextUndefined();
}
if (!(context.getContextItem() instanceof NodeType)) {
throw new DynamicError(TypeError.invalid_type(null));
}
nodeType = (NodeType) context.getContextItem();
if (nodeType.node_value().getOwnerDocument() == null) {
throw DynamicError.contextUndefined();
}
}
Node node = nodeType.node_value();
if (node.getOwnerDocument() == null) {
// W3C Test suite seems to want XPDY0002
throw DynamicError.contextUndefined();
// throw DynamicError.noContextDoc();
}
if (hasIDREF(idrefs, node)) {
ElementType element = new ElementType((Element) node, context.getStaticContext().getTypeModel());
rs.add(element);
}
processAttributes(node, idrefs, rs, context);
processChildNodes(node, idrefs, rs, context);
return rs.getSequence();
}
Aggregations