Пример #1
0
Variant HHVM_METHOD(XMLReader, expand,
                    const Variant& basenode /* = null */) {
  auto* data = Native::data<XMLReader>(this_);
  Object doc;
  xmlDocPtr docp = nullptr;
  SYNC_VM_REGS_SCOPED();

  if (!basenode.isNull()) {
    DOMNode *dombasenode = toDOMNode(basenode.toObject().get());
    doc = dombasenode->doc();
    docp = (xmlDocPtr) toDOMNode(doc.get())->m_node;
    if (docp == nullptr) {
      raise_warning("Invalid State Error");
      return false;
    }
  } else {
    doc = DOMDocument::newInstance();
  }

  if (data->m_ptr) {
    xmlNodePtr node = xmlTextReaderExpand(data->m_ptr);
    if (node == nullptr) {
      raise_warning("An Error Occurred while expanding");
      return false;
    } else {
      xmlNodePtr nodec = xmlDocCopyNode(node, docp, 1);
      if (nodec == nullptr) {
        raise_notice("Cannot expand this node type");
        return false;
      } else {
        return php_dom_create_object(nodec, doc, false);
      }
    }
  }

  raise_warning("Load Data before trying to read");
  return false;
}
Пример #2
0
static Variant HHVM_METHOD(XSLTProcessor, transformToDoc,
                           const Object& doc) {
  auto data = Native::data<XSLTProcessorData>(this_);

  if (doc.instanceof(DOMNode::getClass())) {
    DOMNode *domnode = toDOMNode(doc.get());
    data->m_doc = xmlCopyDoc((xmlDocPtr)domnode->m_node, /*recursive*/ 1);

    ObjectData* ret = ObjectData::newInstance(DOMDocument::c_Class);
    DOMDocument* doc_data = Native::data<DOMDocument>(ret);
    doc_data->m_node = (xmlNodePtr)data->apply_stylesheet();
    doc_data->m_owner = true;

    return Object(ret);
  }

  return false;
}