DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9611>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9611 IXMLDOMDocument::createElement erroneously succeeds Summary: IXMLDOMDocument::createElement erroneously succeeds Product: Xerces-C++ Version: 1.7.0 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Major Priority: Other Component: DOM AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Regarding IXMLDOMDocument... A call to the createElement method succeeds when passing in a tag name that is not valid XML! For instance, this method will succeed when passing in "Test~Root" as the tag name. The tilde is invalid XML, for the name of an element, and should invalidate this call; but it doesn't! It succeeds instead. sample code... CXML_Element_Ptr CXML_Document_Adapter_Xerces_DOM::createRootElement( const std::string& r_tag, bool overwrite_existing /* = true */) { // IXML_Element is our base class, but really irrelevant for this example IXML_Element* p_new_xml_element_i_f = 0; // a pessimist // _p_actual_document is of type ptr to IXMLDOMDocument // proceed only if we have an actual document if (_p_actual_document != 0) { // proceed only if // a. the intent is to not overwrite an existing root element and there exists no // root element // ...OR... // b. the intent is to overwrite an existing root element if (((overwrite_existing == false) && (rootElementExists() == false)) || overwrite_existing == true) { // derive a temporary tag string, in the form of a wrapped b- string, from our // source _bstr_t tag_wrapped_bstr(r_tag.c_str()); // now, from the temporary tag string in wrapped b-string format, derive a // tag string in raw b-string format, to be sent across COM i/f BSTR tag_raw_bstr = tag_wrapped_bstr.copy(); // attempt to create a new actual element CXML_Element_Adapter_Xerces_DOM::ACTUAL_ELEM_PTR p_new_actual_element = 0; // **** this call succeeds with an invalid XML tag name!!! HRESULT result_create_element = _p_actual_document->createElement( tag_raw_bstr, &p_new_actual_element); // de-allocate temporary tag string of raw b-string format ::SysFreeString(tag_raw_bstr); // proceed only if the new actual element was created successfully #if 0 if (result_create_element == S_OK) #else if (SUCCEEDED(result_create_element)) #endif { // ensure that the new actual element exists assert(p_new_actual_element != 0); // attempt to designate this new actual element to be our new root element HRESULT result_put_root_element = _p_actual_document->putref_documentElement (p_new_actual_element); // proceed only if the new actual element was designated our new root // element successfully #if 0 if (result_put_root_element == S_OK) #else if (SUCCEEDED(result_put_root_element)) #endif { // allocate a new instance of our type, to represent our APPENDED new // element CXML_Element_Adapter_Xerces_DOM* p_new_element_adapter_root = new CXML_Element_Adapter_Xerces_DOM (p_new_actual_element); // indicate success p_new_xml_element_i_f = static_cast<IXML_Element*>(p_new_element_adapter_root); } // indicate to the new actual element that it has one less reference p_new_actual_element->Release(); } } } return CXML_Element_Ptr(p_new_xml_element_i_f); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
