Exemplo n.º 1
0
bool
ZorbaValidateInPlaceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  store::Item_t node;

  PlanIteratorState* state;
  store::PUL_t pul;

  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (consumeNext(node, theChild.getp(), planState))
  {
    // verify that if the element being revalidated is an element it is the root
    if (node->getNodeKind()==store::StoreConsts::elementNode &&
        node->getParent() &&
        node->getParent()->getNodeKind()!=store::StoreConsts::documentNode)
      throw XQUERY_EXCEPTION( zerr::ZAPI0090_CANNOT_VALIDATE_NON_ROOT, ERROR_LOC( loc ) );

    pul = GENV_ITEMFACTORY->createPendingUpdateList();

    pul->addRevalidate(&loc,node);

    result.transfer(pul);
    STACK_PUSH(true, state);
  }

  STACK_END(state);
}
Exemplo n.º 2
0
/*******************************************************************************
  declare updating function
  remove($uri as xs:string) as empty-sequence()
********************************************************************************/
bool RemoveDocumentIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  zstring       lRetrievedUriString;
  zstring       lResolvedUriString;
  store::Item_t lUri;
  store::Item_t lResolvedUriItem;
  store::PUL_t lPul;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);

  consumeNext(lUri, theChildren[0].getp(), aPlanState);

  // absolutize retrieved uri
  try
  {
    lUri->getStringValue2(lRetrievedUriString);
    lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
  }
  catch (ZorbaException const&)
  {
    RAISE_ERROR(err::FODC0004, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
  }

  // check if document exists in the store
  if (GENV_STORE.getDocument(lResolvedUriString) == NULL)
  {
    RAISE_ERROR(zerr::ZXQD0002_DOCUMENT_NOT_VALID, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoURIInStore)));
  }

  // create the pul and add the primitive
  GENV_ITEMFACTORY->createAnyURI(lResolvedUriItem, lResolvedUriString);

  lPul = GENV_ITEMFACTORY->createPendingUpdateList();

  lPul->addDeleteDocument(&loc, lResolvedUriItem);

  result.transfer(lPul);
  STACK_PUSH(result != NULL, state);

  STACK_END(state);
}