xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@datadirect.com>
Subject Re: access dtd settings
Date Tue, 22 Jul 2008 07:11:59 GMT
The definition for replaceChild is

    virtual DOMNode  *replaceChild(DOMNode *newChild,
                                     DOMNode *oldChild) = 0;

You are providing the arguments in the opposite order.

Alberto


Daniel Burrell wrote:
> Hi,
>
> Still having trouble with this,
> I have created an itterator, and it seems to find the node I need it to find
> (that is to say it exits the while loop searching for it).
> But I'm not sure how to perform the 'replacement'.
> Here is my code so far (taken partly from the sample iterator):
>
>
> //doc is the (pointer to) document we're searching through
>     DOMNode*    root = doc;
>
>     unsigned long       whatToShow = DOMNodeFilter::SHOW_ALL;
>     MyFilter* filter = new MyFilter(0);
>
>     DOMNodeIterator*  iter =
> ((DOMDocumentTraversal*)doc)->createNodeIterator(root, whatToShow,  filter,
> true);
>     TASSERT(iter->getWhatToShow() == 65535);
>     TASSERT(iter->getExpandEntityReferences() == 1);
>
>
>     DOMNode*  nd;
>     nd = iter->nextNode();
>     cout << "entering while";
>     while (nd->getNodeType() != DOMDocumentType::DOCUMENT_TYPE_NODE){
>         cout << "nope";
>         nd = iter->nextNode();
>     }
>    cout << "got it";
>
>     //This next line seems to be the problem. How do I change out the node I
> found for a new dtd info header
>     doc->replaceChild(nd,doc->createDocumentType(XMLString::transcode(
> "newDoc" ),0, XMLString::transcode( "newdtd.dtd" )));
>
>
>
>
>
> On Mon, Jul 21, 2008 at 9:28 AM, Alberto Massari <amassari@datadirect.com>
> wrote:
>
>   
>> Iterate over the children of the DOMDocument object, you will find a
>> DOMDocumentType (getNodeType()==DOCUMENT_TYPE_NODE) and replace it with a
>> new one created using DOMDocument::createDocumentType("collection","",
>> "newdtd.dtd")
>>
>> Alberto
>>
>>
>> Daniel Burrell wrote:
>>
>>     
>>> I have parsed a document into dom form and retrieved it using
>>> doc = parser->getDocument();
>>>
>>> How can I access the
>>> <!DOCTYPE collection SYSTEM "dtd.dtd">
>>> specifically I want to be able to change "dtd.dtd" to something else.
>>>
>>> in the following xml file?
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE collection SYSTEM "dtd.dtd">
>>> <collection>
>>>  <description>
>>>     Some recipes used for the XML tutorial.
>>>  </description>
>>>  <recipe>
>>>    <title>Beef Parmesan with Garlic Angel Hair Pasta</title>
>>>    <ingredient name="beef cube steak" amount="1.5" unit="pound"/>
>>>    <preparation>
>>>      <step>
>>>        Preheat oven to 350 degrees F (175 degrees C).
>>>      </step>
>>>    </preparation>
>>>    <comment>
>>>      Make the meat ahead of time, and refrigerate over night, the acid in
>>> the
>>>      tomato sauce will tenderize the meat even more. If you do this, save
>>> the
>>>      mozzarella till the last minute.
>>>    </comment>
>>>    <nutrition calories="1167" fat="23" carbohydrates="45" protein="32"/>
>>>  </recipe>
>>> </collection>
>>>
>>>
>>>
>>>       
>>     
>
>   


Mime
View raw message