Search in sources :

Example 1 with XSNCName

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSNCName in project webtools.sourceediting by eclipse.

the class FnLocalNameFromQName method local_name.

/**
 * Local-Name-from-QName operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:local-name-from-QName operation.
 */
public static ResultSequence local_name(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    // get arg
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty())
        return ResultBuffer.EMPTY;
    QName qname = (QName) arg1.first();
    return new XSNCName(qname.local());
}
Also used : XSNCName(org.eclipse.wst.xml.xpath2.processor.internal.types.XSNCName) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) Collection(java.util.Collection)

Example 2 with XSNCName

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSNCName in project webtools.sourceediting by eclipse.

the class FnPrefixFromQName method prefix.

/**
 * Prefix-from-QName operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:prefix-from-QName operation.
 */
public static ResultSequence prefix(Collection args, StaticContext sc) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    // get arg
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty())
        return ResultBuffer.EMPTY;
    QName qname = (QName) arg1.first();
    String prefix = qname.prefix();
    if (prefix != null) {
        if (!XMLConstants.NULL_NS_URI.equals(sc.getNamespaceContext().getNamespaceURI(prefix))) {
            return new XSNCName(prefix);
        } else {
            throw DynamicError.invalidPrefix();
        }
    }
    return ResultBuffer.EMPTY;
}
Also used : XSNCName(org.eclipse.wst.xml.xpath2.processor.internal.types.XSNCName) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) Collection(java.util.Collection)

Aggregations

Collection (java.util.Collection)2 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)2 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)2 XSNCName (org.eclipse.wst.xml.xpath2.processor.internal.types.XSNCName)2