use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI in project webtools.sourceediting by eclipse.
the class FnDocumentUri method document_uri.
/**
* Document-Uri operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:document-uri operation.
*/
public static ResultSequence document_uri(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty())
return ResultBuffer.EMPTY;
NodeType nt = (NodeType) arg1.first();
if (!(nt instanceof DocType))
return ResultBuffer.EMPTY;
DocType dt = (DocType) nt;
String documentURI = dt.value().getDocumentURI();
if (documentURI != null) {
XSAnyURI docUri = new XSAnyURI(documentURI);
return docUri;
}
return ResultBuffer.EMPTY;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI in project webtools.sourceediting by eclipse.
the class FnNamespaceUri method namespace_uri.
/**
* Namespace-Uri operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:namespace-uri operation.
*/
public static ResultSequence namespace_uri(Collection args, EvaluationContext context) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = null;
if (cargs.isEmpty()) {
if (context.getContextItem() == null) {
throw DynamicError.contextUndefined();
}
arg1 = (AnyType) context.getContextItem();
} else {
// get arg
arg1 = (ResultSequence) cargs.iterator().next();
}
if (arg1.empty()) {
return new XSAnyURI("");
}
NodeType an = (NodeType) arg1.first();
QName name = an.node_name();
String sname = "";
if (name != null)
sname = name.namespace();
return new XSAnyURI(sname);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI in project webtools.sourceediting by eclipse.
the class XSDouble method constructor.
/**
* Creates a new result sequence consisting of the retrievable double number
* in the supplied result sequence
*
* @param arg
* The result sequence from which to extract the double number.
* @throws DynamicError
* @return A new result sequence consisting of the double number supplied.
*/
public ResultSequence constructor(ResultSequence arg) throws DynamicError {
if (arg.empty())
return ResultBuffer.EMPTY;
Item aat = arg.first();
if (aat instanceof XSDuration || aat instanceof CalendarType || aat instanceof XSBase64Binary || aat instanceof XSHexBinary || aat instanceof XSAnyURI) {
throw DynamicError.invalidType();
}
if (!isCastable(aat)) {
throw DynamicError.cant_cast(null);
}
XSDouble d = castDouble(aat);
if (d == null)
throw DynamicError.cant_cast(null);
return d;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI in project webtools.sourceediting by eclipse.
the class XSBoolean method constructor.
/**
* Creates a new result sequence consisting of the retrievable boolean value
* in the supplied result sequence
*
* @param arg
* The result sequence from which to extract the boolean value.
* @throws DynamicError
* @return A new result sequence consisting of the boolean value supplied.
*/
public ResultSequence constructor(ResultSequence arg) throws DynamicError {
if (arg.empty())
return ResultBuffer.EMPTY;
Item anyType = arg.first();
if (anyType instanceof XSDuration || anyType instanceof CalendarType || anyType instanceof XSBase64Binary || anyType instanceof XSHexBinary || anyType instanceof XSAnyURI) {
throw DynamicError.invalidType();
}
String str_value = anyType.getStringValue();
if (!(isCastable(anyType, str_value))) {
throw DynamicError.cant_cast(null);
}
return XSBoolean.valueOf(!isFalse(str_value));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI in project webtools.sourceediting by eclipse.
the class DocumentURIFuncTest method test_fn_document_uri_17.
// Evaluates the "document-uri" function as argument to fn:lower-case function.
public void test_fn_document_uri_17() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Functions/AccessorFunc/DocumentURIFunc/fn-document-uri-17.xq";
String resultFile = "/ExpectedTestResults/Functions/AccessorFunc/DocumentURIFunc/fn-document-uri-17.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
setVariable("input-context1", new XSAnyURI(inputFile));
String xpath = extractXPathExpression(xqFile, inputFile);
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = buildResultString(rs);
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
} catch (DynamicError ex) {
actual = ex.code();
}
assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Aggregations