You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Daniel Burrell <da...@gmail.com> on 2008/07/21 06:03:53 UTC

access dtd settings

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>

RE: Xerces and QProgressDialog

Posted by Jesse Pelton <js...@PKC.com>.
I'm not sure how you're communicating between your input stream class and the progress dialog.  I'd think you'd want the input stream to notify the dialog as it supplies data to the parser.  (I'd probably have it send notifications when certain milestones are reached, such as another percent complete, rather than every time it supplies a chunk of data.)  If you're implementing the input source and its associated input stream, you're responsible for keeping track of the position.  Maybe you're deriving from BinFileInputStream and calling its curPos() and/or getSize() members?

I think you'll need to provide a little more detail.  Small, reasonably complete code samples are often helpful.

-----Original Message-----
From: Dennis Endt [mailto:dennis.endt@googlemail.com] 
Sent: Thursday, July 24, 2008 3:05 PM
To: c-users@xerces.apache.org
Subject: Re: Xerces and QProgressDialog

Hi,

I used your Proposal to implement my QFile Object over which I tried to 
read out the actual Position in File.

So I connected my XML Class with my Main Class in the hope, to figure 
out the data.

But unfortunately the pos is always 0, regardless of which part of my 
code I set the signal call.

Is there an extra postion where the Xerces DomBuilder and the Xerces 
SaxParser read out the file?

Jesse Pelton schrieb:
> You could try implementing an InputSource.  It should be able to keep track of how much data it has provided to the parser.  Assuming it knows the total amount of data available, you can make a rough estimate of processing progress.  I'm not sure what size chunks of data the parser will request, but if your files are big enough that a progress dialog is useful, the chunk size will probably be small enough relative to the total size that progress will be reasonably smooth.  If not, I think InputSources can safely return fewer bytes than are requested.  This may impose a small performance penalty, but you may think it worth the tradeoff for a better user experience.
>
>
> -----Original Message-----
> From: Dennis Endt [mailto:dennis.endt@googlemail.com]
> Sent: Wed 7/23/2008 9:18 AM
> To: c-users@xerces.apache.org
> Subject: Xerces and QProgressDialog
>  
> Hi,
>
> I`m using Xerces and QT and now I´m trying to implement a 
> QProgressdialog to display the progress of reading a xml file.
>
> Has anyone an idea how to get the progress for updating the progress bar 
> and how to set the maximum value?
>
> I`m looking for a solution for a SAX and a DOMBuilder parser.
>
> Greets,
> Dennis
>   


Re: Xerces and QProgressDialog

Posted by Dennis Endt <de...@googlemail.com>.
Hi,

I used your Proposal to implement my QFile Object over which I tried to 
read out the actual Position in File.

So I connected my XML Class with my Main Class in the hope, to figure 
out the data.

But unfortunately the pos is always 0, regardless of which part of my 
code I set the signal call.

Is there an extra postion where the Xerces DomBuilder and the Xerces 
SaxParser read out the file?

Jesse Pelton schrieb:
> You could try implementing an InputSource.  It should be able to keep track of how much data it has provided to the parser.  Assuming it knows the total amount of data available, you can make a rough estimate of processing progress.  I'm not sure what size chunks of data the parser will request, but if your files are big enough that a progress dialog is useful, the chunk size will probably be small enough relative to the total size that progress will be reasonably smooth.  If not, I think InputSources can safely return fewer bytes than are requested.  This may impose a small performance penalty, but you may think it worth the tradeoff for a better user experience.
>
>
> -----Original Message-----
> From: Dennis Endt [mailto:dennis.endt@googlemail.com]
> Sent: Wed 7/23/2008 9:18 AM
> To: c-users@xerces.apache.org
> Subject: Xerces and QProgressDialog
>  
> Hi,
>
> I`m using Xerces and QT and now I´m trying to implement a 
> QProgressdialog to display the progress of reading a xml file.
>
> Has anyone an idea how to get the progress for updating the progress bar 
> and how to set the maximum value?
>
> I`m looking for a solution for a SAX and a DOMBuilder parser.
>
> Greets,
> Dennis
>   


RE: Xerces and QProgressDialog

Posted by Jesse Pelton <js...@PKC.com>.
You could try implementing an InputSource.  It should be able to keep track of how much data it has provided to the parser.  Assuming it knows the total amount of data available, you can make a rough estimate of processing progress.  I'm not sure what size chunks of data the parser will request, but if your files are big enough that a progress dialog is useful, the chunk size will probably be small enough relative to the total size that progress will be reasonably smooth.  If not, I think InputSources can safely return fewer bytes than are requested.  This may impose a small performance penalty, but you may think it worth the tradeoff for a better user experience.


-----Original Message-----
From: Dennis Endt [mailto:dennis.endt@googlemail.com]
Sent: Wed 7/23/2008 9:18 AM
To: c-users@xerces.apache.org
Subject: Xerces and QProgressDialog
 
Hi,

I`m using Xerces and QT and now I´m trying to implement a 
QProgressdialog to display the progress of reading a xml file.

Has anyone an idea how to get the progress for updating the progress bar 
and how to set the maximum value?

I`m looking for a solution for a SAX and a DOMBuilder parser.

Greets,
Dennis

Xerces and QProgressDialog

Posted by Dennis Endt <de...@googlemail.com>.
Hi,

I`m using Xerces and QT and now I´m trying to implement a 
QProgressdialog to display the progress of reading a xml file.

Has anyone an idea how to get the progress for updating the progress bar 
and how to set the maximum value?

I`m looking for a solution for a SAX and a DOMBuilder parser.

Greets,
Dennis

Re: access dtd settings

Posted by Daniel Burrell <da...@gmail.com>.
My apologies,
That works now.
Thank you for your time.


On Tue, Jul 22, 2008 at 8:11 AM, Alberto Massari <am...@datadirect.com>
wrote:

> 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>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>

Re: access dtd settings

Posted by Alberto Massari <am...@datadirect.com>.
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 <am...@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>
>>>
>>>
>>>
>>>       
>>     
>
>   


Re: access dtd settings

Posted by Daniel Burrell <da...@gmail.com>.
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 <am...@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>
>>
>>
>>
>
>

Re: access dtd settings

Posted by Alberto Massari <am...@datadirect.com>.
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>
>
>