static Variant HHVM_METHOD(XSLTProcessor, transformToXML, const Object& doc) { auto data = Native::data<XSLTProcessorData>(this_); if (doc.instanceof(s_DOMDocument)) { auto domdoc = Native::data<DOMNode>(doc); data->m_doc = libxml_register_node(xmlCopyDoc ((xmlDocPtr)domdoc->nodep(), /*recursive*/ 1)); xmlDocPtr res = data->apply_stylesheet(); if (res == nullptr) { return false; } xmlChar *mem; int size; if (xsltSaveResultToString(&mem, &size, res, data->m_stylesheet) < 0) { if (mem) { xmlFree(mem); } return false; } String ret = String((char*)mem, size, CopyString); xmlFree(mem); return ret; } return false; }
static Variant HHVM_METHOD(XSLTProcessor, transformToURI, const Object& doc, const String& uri) { auto data = Native::data<XSLTProcessorData>(this_); if (doc.instanceof(DOMDocument::getClass())) { DOMDocument *domdoc = Native::data<DOMDocument>(doc.get()); data->m_doc = xmlCopyDoc ((xmlDocPtr)domdoc->m_node, /*recursive*/ 1); String translated = libxml_get_valid_file_path(uri); if (translated.empty()) { raise_warning("Invalid URI"); return false; } xmlDocPtr res = data->apply_stylesheet (); if (res == nullptr) { return false; } int bytes = xsltSaveResultToFilename(translated.data(), res, data->m_stylesheet, /*compression*/ 0); xmlFreeDoc(res); if (bytes == -1) { return false; } return bytes; } return false; }
Variant c_XSLTProcessor::t_transformtoxml(const Object& doc) { if (doc.instanceof(c_DOMDocument::classof())) { c_DOMDocument *domdoc = doc.getTyped<c_DOMDocument>(); m_doc = xmlCopyDoc ((xmlDocPtr)domdoc->m_node, /*recursive*/ 1); xmlDocPtr res = apply_stylesheet(); if (res == nullptr) { return false; } xmlChar *mem; int size; if (xsltSaveResultToString(&mem, &size, res, m_stylesheet) < 0) { if (mem) { xmlFree(mem); } return false; } String ret = String((char*)mem, size, CopyString); xmlFree(mem); return ret; } return false; }
Variant c_XSLTProcessor::t_transformtouri(const Object& doc, const String& uri) { if (doc.instanceof(c_DOMDocument::classof())) { c_DOMDocument *domdoc = doc.getTyped<c_DOMDocument>(); m_doc = xmlCopyDoc ((xmlDocPtr)domdoc->m_node, /*recursive*/ 1); String translated = xslt_get_valid_file_path(uri); if (translated.empty()) { raise_warning("Invalid URI"); return false; } xmlDocPtr res = apply_stylesheet (); if (res == nullptr) { return false; } int bytes = xsltSaveResultToFilename(translated.data(), res, m_stylesheet, /*compression*/ 0); xmlFreeDoc(res); if (bytes == -1) { return false; } return bytes; } return false; }
Variant c_XSLTProcessor::t_transformtodoc(const Object& doc) { if (doc.instanceof(c_DOMNode::classof())) { c_DOMNode *domnode = doc.getTyped<c_DOMNode>(); m_doc = xmlCopyDoc((xmlDocPtr)domnode->m_node, /*recursive*/ 1); c_DOMDocument *res = NEWOBJ(c_DOMDocument)(); res->m_node = (xmlNodePtr)apply_stylesheet(); res->m_owner = true; return res; } return false; }
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; }
static Variant HHVM_METHOD(XSLTProcessor, transformToDoc, const Object& doc) { auto data = Native::data<XSLTProcessorData>(this_); if (doc.instanceof(s_DOMNode)) { auto domnode = Native::data<DOMNode>(doc); data->m_doc = libxml_register_node(xmlCopyDoc((xmlDocPtr)domnode->nodep(), /*recursive*/ 1)); auto ret = newDOMDocument(false /* construct */); DOMNode* doc_data = Native::data<DOMNode>(ret); doc_data->setNode((xmlNodePtr)data->apply_stylesheet()); return ret; } return false; }
static Variant HHVM_METHOD(XSLTProcessor, transformToURI, const Object& doc, const String& uri) { auto data = Native::data<XSLTProcessorData>(this_); if (!FileUtil::checkPathAndWarn(uri, "XSLTProcessor::transformToUri", 2)) { return false; } if (doc.instanceof(s_DOMDocument)) { auto domdoc = Native::data<DOMNode>(doc); data->m_doc = libxml_register_node(xmlCopyDoc ((xmlDocPtr)domdoc->nodep(), /*recursive*/ 1)); String translated = libxml_get_valid_file_path(uri); if (translated.empty()) { raise_warning("Invalid URI"); return false; } xmlDocPtr res = data->apply_stylesheet (); if (res == nullptr) { return false; } int bytes = xsltSaveResultToFilename(translated.data(), res, data->m_stylesheet, /*compression*/ 0); xmlFreeDoc(res); if (bytes == -1) { return false; } return bytes; } return false; }