/* Write the file. */
bool GQCFileData::Write(const std::string &fileName)
{    
	// Initialize the XML4C2 system.
	try
	{
		XMLPlatformUtils::Initialize();
	}
	catch (const XMLException&)
	{
		return false;
	}

	// Create a DOM implementation object and create the document type for it.
	DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(ToXMLCh(L"LS"));
	DOMDocument* doc = impl->createDocument();
	//doc->setStandalone(true);

	// Create the serializer.
	DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
	DOMLSOutput     *theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
	//theSerializer->setEncoding(ToXMLCh(GENERIC_REPORT_FILE_ENCODING));
	theOutputDesc->setEncoding(ToXMLCh(GENERIC_REPORT_FILE_ENCODING));

    // Create the root element
    DOMElement *rootElement = CreateGenericReportElement(doc);

	// store the parameters
	AddNameValuePairs(ANALYSIS_PARAMETERS, analysisParameters, doc, rootElement);
	AddNameValuePairs(QC_RESULTS, qcResults, doc, rootElement);
	AddNameValuePairs(SAMPLE_SIGNATURE, sampleSignature, doc, rootElement);

    // Add an empty table (required by the DTD)
    AddBlankReportTable(doc, rootElement);

    // Store the element to the document.
    doc->appendChild(rootElement);

	// Write the file.
	bool status = false;
	XMLFormatTarget *myFormTarget = new LocalFileFormatTarget(fileName.c_str());
	theOutputDesc->setByteStream(myFormTarget);
	try
	{
		theSerializer->write(doc, theOutputDesc);
		status = true;
	}
	catch (...)
	{
		status = false;
	}

	// Clean up
	doc->release();
	theOutputDesc->release();
	theSerializer->release();
	delete myFormTarget;
	XMLPlatformUtils::Terminate();

	return status;
}
Exemple #2
0
// ------------------------------------------------------------
// DOMImplementationSource Virtual interface
// ------------------------------------------------------------
DOMImplementation* DOMImplementationImpl::getDOMImplementation(const XMLCh* features) const
{
    DOMImplementation* impl = DOMImplementation::getImplementation();

    XMLStringTokenizer tokenizer(features, XMLPlatformUtils::fgMemoryManager);
    const XMLCh* feature = 0;

    while (feature || tokenizer.hasMoreTokens()) {

        if (!feature)
            feature = tokenizer.nextToken();

        const XMLCh* version = 0;
        const XMLCh* token = tokenizer.nextToken();

        if (token && XMLString::isDigit(token[0]))
            version = token;

        if (!impl->hasFeature(feature, version))
            return 0;

        if (!version)
            feature = token;
    }
    return impl;
}
Exemple #3
0
bool           Module::WriteStaticXML (const string& xml_file) {

	DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(StrX("Core").XMLchar() );

	if (impl==NULL) return false;

	DOMDocument* doc          = impl->createDocument( 0, StrX("PARAM").XMLchar(), 0);
	DOMNode*     topnode      = doc->getFirstChild();
    Parameters*  parameters   = m_seq_tree->GetParameters();
    DOMNode*     backup_node  = parameters->GetNode();
	XMLIO*       xmlio        = new XMLIO();

    parameters->SetNode(topnode);
    parameters->AddAllDOMattributes(false);

	if ( ((DOMElement*) topnode)->getAttributeNode(StrX("Name").XMLchar()) != NULL)
		((DOMElement*) topnode)->removeAttribute (StrX("Name").XMLchar());

    parameters->SetNode(backup_node);

	//recursively add elements
	if (!StaticDOM(doc,topnode)) return false;

	xmlio->Write (impl, topnode, xml_file);

	delete doc;
	delete topnode;
	delete parameters;
	delete backup_node;
	delete xmlio; 

	return true;

}
Exemple #4
0
int main()
{
   XMLPlatformUtils::Initialize();

   // Populate vector of items
   vector<Item> items;
   items.push_back(Item(Product("Toaster", 29.95), 3));
   items.push_back(Item(Product("Hair dryer", 24.95), 1));

   // Build the DOM document
   DOMImplementation* implementation
      = DOMImplementation::getImplementation();
   DOMDocument* doc = implementation->createDocument();
   doc->setStandalone(true);

   DOMElement* root = create_item_list(doc, items);
   doc->appendChild(root);

   // Print the DOM document

   DOMWriter* writer = implementation->createDOMWriter();
   writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
   XMLFormatTarget* out = new StdOutFormatTarget();
   writer->writeNode(out, *doc);

   writer->release();
   doc->release();

   return 0;
}
Exemple #5
0
DOMDocument* Normalizer::createDocument() {
    XMLCh coreStr[100];
    XMLString::transcode("Core",coreStr,99);

    DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(coreStr);
    return impl->createDocument();
};
int _tmain(int argc, _TCHAR* argv[])
{
	try
	{
		XMLPlatformUtils::Initialize();
	}
	catch(...)
	{
		return 1;
	}

	XMLCh* Path  = NULL;
	DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(L"Core");
	XERCES_CPP_NAMESPACE::DOMDocument* doc = impl->createDocument( 0, L"directory", 0);
	
	if( argc >= 2)
		Path = argv[1];
	else
		Path = L".\\";
	SaveFileTreeToXML(Path, doc->getDocumentElement() ,doc);

	PrintXMLdoc( doc );

	doc->release();

	XMLPlatformUtils::Terminate();
	return 0;
}
Exemple #7
0
static v8::Handle<v8::Value> createHTMLDocumentCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.DOMImplementation.createHTMLDocument");
    DOMImplementation* imp = V8DOMImplementation::toNative(args.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, title, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
    return toV8(imp->createHTMLDocument(title));
}
DOMImplementation* XQillaImplementation::getDOMImplementation(const XMLCh* features) const
{
    DOMImplementation* impl = XQillaImplementation::getDOMImplementationImpl();

    XMLStringTokenizer tokenizer(features);
    const XMLCh* feature = 0;

    while (feature || tokenizer.hasMoreTokens()) {

        if (!feature)
            feature = tokenizer.nextToken();

        const XMLCh* version = 0;
        const XMLCh* token = tokenizer.nextToken();

        if (token && XMLString::isDigit(token[0]))
            version = token;

        if (!impl->hasFeature(feature, version))
            return 0;

        if (!version)
            feature = token;
    }
    return impl;
}
void XMLInitializer::initializeDOMDocumentTypeImpl()
{
    sDocumentMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager);

    static const XMLCh gCoreStr[] = { chLatin_C, chLatin_o, chLatin_r, chLatin_e, chNull };
    DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(gCoreStr);
    sDocument = impl->createDocument(); // document type object (DTD).
}
Exemple #10
0
static v8::Handle<v8::Value> hasFeatureCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.DOMImplementation.hasFeature");
    DOMImplementation* imp = V8DOMImplementation::toNative(args.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, feature, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithNullCheck>, version, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
    return v8Boolean(imp->hasFeature(feature, version));
}
Exemple #11
0
void
check_svg_pssm_logo()
{
    cout << "******* check_svg_pssm_logo()" << endl;

    XMLPlatformUtils::Initialize();

    DOMImplementation* impl
        = DOMImplementation::getImplementation();

    if (impl != NULL)
    {
        DOMDocumentType* doc_type
            = impl->createDocumentType(	XStr("svg"),
                                        NULL,
                                        XStr("svg-20000303-stylable.dtd") );
        XERCES_CPP_NAMESPACE::DOMDocument * doc = impl->createDocument(
                    0,        // root element namespace URI.
                    XStr("svg"),		// root element name
                    doc_type);			// document type object (DTD).
        doc->setEncoding(XStr("UTF-8"));

        add_logo_defs(doc);

        TableLinkVec links;
        links.push_back(TableLink(MATRIX_DATA, 37));
        links.push_back(TableLink(MATRIX_DATA, 104));
        links.push_back(TableLink(MATRIX_DATA, 236));
        links.push_back(TableLink(MATRIX_DATA, 457));

        for (TableLinkVec::const_iterator i = links.begin();
                links.end() != i;
                ++i)
        {
            const Matrix * matrix = BiobaseDb::singleton().get_matrices()[*i].get();
            const Pssm pssm = make_pssm(matrix);
            const seq_t sequence =
                (matrix->align_descs.begin() != matrix->align_descs.end())
                ? matrix->align_descs.begin()->get()->sequence
                : "";
            DOMElement * pssm_logo =
                create_svg_pssm_logo(
                    pssm,
                    doc,
                    sequence);
            set_attribute(pssm_logo, "x", 0);
            set_attribute(pssm_logo, "y", BIO_NS::float_t(200 * (i - links.begin())));
            set_attribute(pssm_logo, "height", 200);
            set_attribute(pssm_logo, "width", BIO_NS::float_t(pssm.size() * 100));
            doc->getDocumentElement()->appendChild(pssm_logo);
        }

        dom_print(doc->getDocumentElement(), "logo_test.svg");
    }

    XMLPlatformUtils::Terminate();
}
XMLParser::XMLParser() {
    using namespace xercesc;
    namespace xml = xsd::cxx::xml;
    namespace tree = xsd::cxx::tree;

    _memMgr = new MemoryManagerImpl();
    _grammarPool = new XMLGrammarPoolImpl(_memMgr);

    const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull};

    // Get an implementation of the Load-Store (LS) interface.
    //
    DOMImplementation* impl (
            DOMImplementationRegistry::getDOMImplementation (ls_id));

    // Create a DOMBuilder.
    //
    // TODO: make this a class-member and initialize just once
    parser = impl->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0, _memMgr, _grammarPool);

    // Discard comment nodes in the document.
    //
    parser->setFeature (XMLUni::fgDOMComments, false);

    // Enable datatype normalization.
    //
    parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true);

    // Do not create EntityReference nodes in the DOM tree. No
    // EntityReference nodes will be created, only the nodes
    // corresponding to their fully expanded substitution text
    // will be created.
    //
    //parser->setFeature (XMLUni::fgDOMEntities, false);
    parser->setFeature (XMLUni::fgDOMEntities, true);

    // Perform Namespace processing.
    //
    parser->setFeature (XMLUni::fgDOMNamespaces, true);

    // Do not include ignorable whitespace in the DOM tree.
    //
    parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false);

    parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false);

    // We will release the DOM document ourselves.
    //
    parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true);

    // Enable grammar caching and load known grammars
    parser->loadGrammar((INSTALL_PREFIX + std::string("/etc/xbe/schema/xbe-msg.xsd")).c_str(), Grammar::SchemaGrammarType, true);
    parser->loadGrammar((INSTALL_PREFIX + std::string("/etc/xbe/schema/dsig.xsd")).c_str(), Grammar::SchemaGrammarType, true);
    parser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);

}
Exemple #13
0
    void visitDOMWrapper(DOMDataStore* store, void* object, v8::Persistent<v8::Object> wrapper)
    {
        WrapperTypeInfo* typeInfo = V8DOMWrapper::domWrapperType(wrapper);

        if (typeInfo->isSubclass(&V8StyleSheetList::info)) {
            StyleSheetList* styleSheetList = static_cast<StyleSheetList*>(object);
            GroupId groupId(styleSheetList);
            if (Document* document = styleSheetList->document())
                groupId = GroupId(document);
            m_grouper.append(GrouperItem(groupId, wrapper));

        } else if (typeInfo->isSubclass(&V8DOMImplementation::info)) {
            DOMImplementation* domImplementation = static_cast<DOMImplementation*>(object);
            GroupId groupId(domImplementation);
            if (Document* document = domImplementation->document())
                groupId = GroupId(document);
            m_grouper.append(GrouperItem(groupId, wrapper));

        } else if (typeInfo->isSubclass(&V8StyleSheet::info) || typeInfo->isSubclass(&V8CSSRule::info)) {
            m_grouper.append(GrouperItem(calculateGroupId(static_cast<StyleBase*>(object)), wrapper));

#if 0 //CMP_ERROR_UNCLEAR CSSMutableStyleDeclaration
        } else if (typeInfo->isSubclass(&V8CSSStyleDeclaration::info)) {
            CSSStyleDeclaration* cssStyleDeclaration = static_cast<CSSStyleDeclaration*>(object);

            GroupId groupId = calculateGroupId(cssStyleDeclaration);
            m_grouper.append(GrouperItem(groupId, wrapper));

            // Keep alive "dirty" primitive values (i.e. the ones that
            // have user-added properties) by creating implicit
            // references between the style declaration and the values
            // in it.
            if (cssStyleDeclaration->isMutableStyleDeclaration()) {
                CSSMutableStyleDeclaration* cssMutableStyleDeclaration = static_cast<CSSMutableStyleDeclaration*>(cssStyleDeclaration);
                Vector<v8::Persistent<v8::Value> > values;
                values.reserveCapacity(cssMutableStyleDeclaration->length());
                CSSMutableStyleDeclaration::const_iterator end = cssMutableStyleDeclaration->end();
                for (CSSMutableStyleDeclaration::const_iterator it = cssMutableStyleDeclaration->begin(); it != end; ++it) {
                    v8::Persistent<v8::Object> value = store->domObjectMap().get(it->value());
                    if (!value.IsEmpty() && value->IsDirty())
                        values.append(value);
                }
                if (!values.isEmpty())
                    v8::V8::AddImplicitReferences(wrapper, values.data(), values.size());
            }
        } else if (typeInfo->isSubclass(&V8CSSRuleList::info)) {
            CSSRuleList* cssRuleList = static_cast<CSSRuleList*>(object);
            GroupId groupId(cssRuleList);
            StyleList* styleList = cssRuleList->styleList();
            if (styleList)
                groupId = calculateGroupId(styleList);
            m_grouper.append(GrouperItem(groupId, wrapper));
#endif
        }
    }
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      DOMImplementation docImpl;
      boolean state;
      doc = (Document) baseT::load("staff", false);
      docImpl = doc.getImplementation();
      state = docImpl.hasFeature(SA::construct_from_utf8("XML"), SA::construct_from_utf8("1.0"));
assertTrue(state);
      
   }
JSValue* jsDOMImplementationPrototypeFunctionCreateHTMLDocument(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSDOMImplementation::s_info))
        return throwError(exec, TypeError);
    JSDOMImplementation* castedThisObj = static_cast<JSDOMImplementation*>(thisValue);
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThisObj->impl());
    const UString& title = args.at(exec, 0)->toString(exec);


    JSC::JSValue* result = toJS(exec, WTF::getPtr(imp->createHTMLDocument(title)));
    return result;
}
JSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionCreateHTMLDocument(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSDOMImplementation::s_info))
        return throwError(exec, TypeError);
    JSDOMImplementation* castedThisObj = static_cast<JSDOMImplementation*>(asObject(thisValue));
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThisObj->impl());
    const UString& title = args.at(0).toString(exec);


    JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->createHTMLDocument(title)));
    return result;
}
JSValue* jsDOMImplementationPrototypeFunctionHasFeature(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSDOMImplementation::s_info))
        return throwError(exec, TypeError);
    JSDOMImplementation* castedThisObj = static_cast<JSDOMImplementation*>(thisValue);
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThisObj->impl());
    const UString& feature = args.at(exec, 0)->toString(exec);
    const UString& version = valueToStringWithNullCheck(exec, args.at(exec, 1));


    JSC::JSValue* result = jsBoolean(imp->hasFeature(feature, version));
    return result;
}
EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionCreateHTMLDocument(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDOMImplementation::s_info))
        return throwVMTypeError(exec);
    JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue));
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl());
    const String& title = ustringToString(exec->argument(0).toString(exec));


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createHTMLDocument(title)));
    return JSValue::encode(result);
}
Exemple #19
0
void DeltaApplyEngine::ApplyDelta(XID_DOMDocument *IncDeltaDoc, int backwardNumber) {
    
	DOMNode* deltaRoot = IncDeltaDoc->getDocumentElement();  // <delta_unit>
	DOMNode* deltaElement ;
		for ( deltaElement = deltaRoot->getLastChild(); backwardNumber > 0;  deltaElement = deltaElement->getPreviousSibling(), backwardNumber-- ) {
                  DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(gLS);
                  DOMDocument* backwardDeltaDoc = impl->createDocument(0, XMLString::transcode(""),0);
                
                  //DOMDocument* backwardDeltaDoc = DOMDocument::createDocument();
                  DOMNode* backwardDeltaElement = XyDelta::ReverseDelta(backwardDeltaDoc, deltaElement);			
			ApplyDeltaElement(backwardDeltaElement);
		}
	
}
Exemple #20
0
int main(int argc, char *argv[]) {
  // Initialise Xerces-C and XQilla using XQillaPlatformUtils
  XQillaPlatformUtils::initialize();

  // Get the XQilla DOMImplementation object
  DOMImplementation *xqillaImplementation =
    DOMImplementationRegistry::getDOMImplementation(X("XPath2 3.0"));

  try {
    // Create a DOMLSParser object
    AutoRelease<DOMLSParser> parser(xqillaImplementation->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0));
    parser->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, true);
    parser->getDomConfig()->setParameter(XMLUni::fgXercesSchema, true);
    parser->getDomConfig()->setParameter(XMLUni::fgDOMValidateIfSchema, true);

    // Parse a DOMDocument
    DOMDocument *document = parser->parseURI("foo.xml");
    if(document == 0) {
      std::cerr << "Document not found." << std::endl;
      return 1;
    }

    // Parse an XPath 2 expression
    AutoRelease<DOMXPathExpression> expression(document->createExpression(X("foo/bar/@baz"), 0));

    // Execute the query
    AutoRelease<DOMXPathResult> result(expression->evaluate(document, DOMXPathResult::ITERATOR_RESULT_TYPE, 0));

    // Create a DOMLSSerializer to output the nodes
    AutoRelease<DOMLSSerializer> serializer(xqillaImplementation->createLSSerializer());
    AutoRelease<DOMLSOutput> output(xqillaImplementation->createLSOutput());
    StdOutFormatTarget target;
    output->setByteStream(&target);

    // Iterate over the results, printing them
    while(result->iterateNext()) {
      serializer->write(result->getNodeValue(), output);
      std::cout << std::endl;
    }
  }
  catch(XQillaException &e) {
    std::cerr << "XQillaException: " << UTF8(e.getString()) << std::endl;
    return 1;
  }

  // Terminate Xerces-C and XQilla using XQillaPlatformUtils
  XQillaPlatformUtils::terminate();

  return 0;
}
EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionHasFeature(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDOMImplementation::s_info))
        return throwVMTypeError(exec);
    JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue));
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl());
    const String& feature = ustringToString(exec->argument(0).toString(exec));
    const String& version = valueToStringWithNullCheck(exec, exec->argument(1));


    JSC::JSValue result = jsBoolean(imp->hasFeature(feature, version));
    return JSValue::encode(result);
}
JSValue* jsDOMImplementationPrototypeFunctionCreateCSSStyleSheet(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSDOMImplementation::s_info))
        return throwError(exec, TypeError);
    JSDOMImplementation* castedThisObj = static_cast<JSDOMImplementation*>(thisValue);
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    const UString& title = args.at(exec, 0)->toString(exec);
    const UString& media = args.at(exec, 1)->toString(exec);


    JSC::JSValue* result = toJS(exec, WTF::getPtr(imp->createCSSStyleSheet(title, media, ec)));
    setDOMException(exec, ec);
    return result;
}
Exemple #23
0
 /// Dump DOM tree using XercesC handles
 void dumpTree(DOMNode* doc, ostream& os) {
   if ( doc )  {
     DOMImplementation  *imp = DOMImplementationRegistry::getDOMImplementation(Strng_t("LS"));
     MemBufFormatTarget *tar = new MemBufFormatTarget();
     DOMLSOutput        *out = imp->createLSOutput();
     DOMLSSerializer    *wrt = imp->createLSSerializer();
     out->setByteStream(tar);
     wrt->getDomConfig()->setParameter(Strng_t("format-pretty-print"), true);
     wrt->write(doc, out);
     os << tar->getRawBuffer() << endl << flush;
     out->release();
     wrt->release();
     return;
   }
   printout(ERROR,"dumpTree","+++ Cannot dump invalid document.");
 }
Exemple #24
0
void  ParameterManager::CreateDocument(void)
{
    // creating a document from screatch
    DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(XStr("Core").unicodeForm());
    delete _pDocument;
    _pDocument = impl->createDocument(
                     0,                                          // root element namespace URI.
                     XStr("FCParameters").unicodeForm(),         // root element name
                     0);                                         // document type object (DTD).

    // creating the node for the root group
    DOMElement* rootElem = _pDocument->getDocumentElement();
    _pGroupNode = _pDocument->createElement(XStr("FCParamGroup").unicodeForm());
    ((DOMElement*)_pGroupNode)->setAttribute(XStr("Name").unicodeForm(), XStr("Root").unicodeForm());
    rootElem->appendChild(_pGroupNode);
}
Exemple #25
0
//
// ILI2Handler
// 
ILI2Handler::ILI2Handler( ILI2Reader *poReader ) {
  m_poReader = poReader;
  
  XMLCh *tmpCh = XMLString::transcode("CORE");
  DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tmpCh);
  XMLString::release(&tmpCh);

  // the root element
  tmpCh = XMLString::transcode("ROOT");
  dom_doc = impl->createDocument(0,tmpCh,0);
  XMLString::release(&tmpCh);

  // the first element is root
  dom_elem = dom_doc->getDocumentElement();

}
JSValue* jsDOMImplementationPrototypeFunctionCreateDocument(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSDOMImplementation::s_info))
        return throwError(exec, TypeError);
    JSDOMImplementation* castedThisObj = static_cast<JSDOMImplementation*>(thisValue);
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    const UString& namespaceURI = valueToStringWithNullCheck(exec, args.at(exec, 0));
    const UString& qualifiedName = valueToStringWithNullCheck(exec, args.at(exec, 1));
    DocumentType* doctype = toDocumentType(args.at(exec, 2));


    JSC::JSValue* result = toJS(exec, WTF::getPtr(imp->createDocument(namespaceURI, qualifiedName, doctype, ec)));
    setDOMException(exec, ec);
    return result;
}
XERCES_CPP_NAMESPACE_BEGIN

DOMDocument *
XIncludeDOMDocumentProcessor::doXIncludeDOMProcess(const DOMDocument * const source, XMLErrorReporter *errorHandler, XMLEntityHandler* entityResolver /*=NULL*/){
    XIncludeUtils xiu(errorHandler);

    DOMImplementation* impl = source->getImplementation();
    DOMDocument *xincludedDocument = impl->createDocument();
    
    try
    {
        /* set up the declaration etc of the output document to match the source */
        xincludedDocument->setDocumentURI( source->getDocumentURI());
        xincludedDocument->setXmlStandalone( source->getXmlStandalone());
        xincludedDocument->setXmlVersion( source->getXmlVersion());

        /* copy entire source document into the xincluded document. Xincluded document can
           then be modified in place */
        DOMNode *child = source->getFirstChild();
        for (; child != NULL; child = child->getNextSibling()){
            if (child->getNodeType() == DOMNode::DOCUMENT_TYPE_NODE){
                /* I am simply ignoring these at the moment */
                continue;
            }
            DOMNode *newNode = xincludedDocument->importNode(child, true);
            xincludedDocument->appendChild(newNode);
        }

        DOMNode *docNode = xincludedDocument->getDocumentElement();
        /* parse and include the document node */
        xiu.parseDOMNodeDoingXInclude(docNode, xincludedDocument, entityResolver);

        xincludedDocument->normalizeDocument();
    }
    catch(const XMLErrs::Codes)
    {
        xincludedDocument->release();
        return NULL;
    }
    catch(...)
    {
        xincludedDocument->release();
        throw;
    }

    return xincludedDocument;
}
EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionCreateDocument(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDOMImplementation::s_info))
        return throwVMTypeError(exec);
    JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue));
    DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl());
    ExceptionCode ec = 0;
    const String& namespaceURI = valueToStringWithNullCheck(exec, exec->argument(0));
    const String& qualifiedName = valueToStringWithNullCheck(exec, exec->argument(1));
    DocumentType* doctype = toDocumentType(exec->argument(2));


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createDocument(namespaceURI, qualifiedName, doctype, ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
    //-----------------------------------------------------------------------
    void XercesWriter::writeXMLFile(const XMLNode* root, const Ogre::String& filename)
    {
        XERCES_CPP_NAMESPACE_USE;

        DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(L"Core");
        DOMDocumentType* docType = NULL;
        DOMDocument* doc = impl->createDocument(NULL, transcode(root->getName()).c_str(), docType);

        populateDOMElement(root, doc->getDocumentElement());

        LocalFileFormatTarget destination(filename.c_str());
        DOMWriter* writer = impl->createDOMWriter();
        writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
        writer->writeNode(&destination, *doc);
        writer->release();
        doc->release();
    }
Exemple #30
0
static v8::Handle<v8::Value> createCSSStyleSheetCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.DOMImplementation.createCSSStyleSheet");
    DOMImplementation* imp = V8DOMImplementation::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, title, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, media, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
    RefPtr<CSSStyleSheet> result = imp->createCSSStyleSheet(title, media, ec);
    if (UNLIKELY(ec))
        goto fail;
    return toV8(result.release());
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}