use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.
the class Function method fnNilled.
/**
* <p>
* fn:nilled($arg as node()?) as xs:boolean?
* </p>
* <p>
* Returns an xs:boolean indicating whether the argument node is "nilled". If the argument is not
* an element node, returns the empty sequence. If the argument is the empty sequence, returns the
* empty sequence.
* </p>
*
* @param rtx the transaction to operate on
* @param axis The sequence containing the node to test its nilled property
* @return true, if current item is a node that has the nilled property (only elements)
*/
public static boolean fnNilled(final XdmNodeReadTrx rtx, final AbstractAxis axis) {
if (axis.hasNext() && rtx.getKind() == Kind.ELEMENT) {
// TODO how is the nilled property
final boolean nilled = false;
// defined?
final int itemKey = rtx.getItemList().addItem(new AtomicValue(nilled));
rtx.moveTo(itemKey);
return true;
}
// empty sequence
return false;
}
use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.
the class Function method zeroOrOne.
public static boolean zeroOrOne(final XdmNodeReadTrx rtx, final AbstractAxis axis) throws SirixXPathException {
final boolean result = true;
if (axis.hasNext() && axis.hasNext()) {
// more than one result
throw EXPathError.FORG0003.getEncapsulatedException();
}
final int itemKey = rtx.getItemList().addItem(new AtomicValue(result));
rtx.moveTo(itemKey);
return true;
}
use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.
the class Function method fnnot.
public static boolean fnnot(final XdmNodeReadTrx rtx, final AbstractAxis axis) {
if (axis.hasNext()) {
axis.next();
final AtomicValue item = new AtomicValue(rtx.getRawValue()[0] == 0);
final int itemKey = rtx.getItemList().addItem(item);
rtx.moveTo(itemKey);
return true;
} else {
return false;
}
}
use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.
the class CastableExpr method evaluate.
/**
* {@inheritDoc}
*/
@Override
public void evaluate() throws SirixXPathException {
// defines if current item is castable to the target type, or not
boolean isCastable;
// atomic type must not be xs:anyAtomicType or xs:NOTATION
if (mTargetType == Type.ANY_ATOMIC_TYPE || mTargetType == Type.NOTATION) {
throw new XPathError(ErrorType.XPST0080);
}
if (mSourceExpr.hasNext()) {
// result sequence > 0
mKey = mSourceExpr.next();
final Type sourceType = Type.getType(getTrx().getTypeKey());
final String sourceValue = getTrx().getValue();
// determine castability
isCastable = sourceType.isCastableTo(mTargetType, sourceValue);
// item, a type error is raised.
if (mSourceExpr.hasNext()) {
// result sequence > 1
throw new XPathError(ErrorType.XPTY0004);
}
} else {
// result sequence = 0 (empty sequence)
// empty sequence is allowed.
isCastable = mPermitEmptySeq;
}
// create result item and move transaction to it.
final int mItemKey = getTrx().getItemList().addItem(new AtomicValue(TypedValue.getBytes(Boolean.toString(isCastable)), getTrx().keyForName("xs:boolean")));
mKey = mItemKey;
}
use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.
the class EveryExpr method evaluate.
/**
* {@inheritDoc}
*/
@Override
public void evaluate() {
boolean satisfiesCond = true;
for (final Axis axis : mVars) {
while (axis.hasNext()) {
axis.next();
if (!mSatisfy.hasNext()) {
// condition is not satisfied for this item -> expression is
// false
satisfiesCond = false;
break;
}
}
}
final int mItemKey = getTrx().getItemList().addItem(new AtomicValue(TypedValue.getBytes(Boolean.toString(satisfiesCond)), getTrx().keyForName("xs:boolean")));
mKey = mItemKey;
}
Aggregations