You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Caignart Olivier <ca...@multitel.be> on 2004/06/24 10:02:10 UTC

Creating a XML document from SAX

Hello to XML-c-dev mailing list !

I've tried to use a sample code found here  (below you could find the
original thread :
http://www.mail-archive.com/xerces-c-dev@xml.apache.org/msg08148.html
)to do the same thing as Thomas wanted to do in this thread.
Unfortunately i cannot make it work and i get this answer.

Here's the answer of my compiler (gcc-3.3) :
/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:
In
   constructor `SAXPrintHandlers::SAXPrintHandlers(const char*,
   xercesc_2_5::XMLFormatter::UnRepFlags)':
/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:189: error: no
   base or member initializers given following ':'
/home/.../src/xerces-c-src_2_5_0/include/xercesc/framework/XMLFormatter.hpp:449: error: `
   xercesc_2_5::XMLFormatter::XMLFormatter()' is private
/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:189: error: within
   this context
/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:190: error: parse
   error before `(' token
/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:198: error: no
   match for call to `(xercesc_2_5::XMLFormatter) (const char* const&,
   xercesc_2_5::XMLFormatTarget*&,
xercesc_2_5::XMLFormatter::EscapeFlags,
   const xercesc_2_5::XMLFormatter::UnRepFlags&)'
/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:199: error: parse
   error before `:' token
make: ***
[/home/.../src/xerces-c-src_2_5_0/bin/obj/SAXPrint/SAXPrintHandlers.o]
Error 1


Could you tell me what's wrong? I'm neither a good programmer nor good
in Xerces as well so I'll try to understand your answer.


If you know any other method to write in a XML file from SAX please tell
me !!

Regards, 
Olivier Caignart





---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Creating a XML document from SAX

Posted by Caignart Olivier <ca...@multitel.be>.
Hi Alberto !

Thank you so much  for your answer. I think i can now go on in my work
with this sample.

Greetings, have a good day

Olivier

On Fri, 2004-06-25 at 11:47, Alberto Massari wrote:
> Hi Olivier,
> I made a mistake in writing the code (well, it happens, when you don't test 
> the code before suggesting it! ;-) )
> The order of the initialization methods after the ":" is derived from the 
> order of declaration of the variables; so fTarget was still 0 when given to 
> the constructor of XMLFormatter. You need to change the header to say
> 
>        LocalFileFormatTarget*  fTarget;
>        XMLFormatter    fFormatter;
> 
> Alberto
> 
> 
> At 17.25 24/06/2004 +0200, Caignart Olivier wrote:
> >Thanks a lot Alberto !
> >
> >It was a typo as you said.
> >
> >Unfortunalty my trouble go a little further.
> >I've tried this sample :
> >
> >SAXPrintHandlers::SAXPrintHandlers( const   char* const encodingName,
> >const XMLFormatter::UnRepFlags unRepFlags)
> > 
> >: fTarget(new LocalFileFormatTarget(goutputfile)) ,
> >fFormatter(encodingName, fTarget, XMLFormatter::NoEscapes, unRepFlags )
> >{
> >}
> >SAXPrintHandlers::~SAXPrintHandlers()
> >{
> >         delete fTarget;
> >}
> >
> >with static char* goutputFile = "/home/[...]/output.xml" ;
> >
> >but it doesn't work. I got a segmentation fault ! Anyway outputfile is
> >created but not filled.
> >
> >Any idea?
> >
> >Olivier
> >
> >On Thu, 2004-06-24 at 13:35, Alberto Massari wrote:
> > > Hi Olivier,
> > > reading the message in the archive I would say it has a typo. The correct
> > > code would be
> > >
> > > SAXPrintHandlers.hpp:
> > >
> > > class SAXPrintHandlers : public HandlerBase, private XMLFormatTarget
> > > {
> > > [...]
> > >      XMLFormatter    fFormatter;
> > >      LocalFileFormatTarget*  fTarget;
> > > };
> > >
> > > ---SAXPrintHandlers.cpp:
> > >
> > > SAXPrintHandlers::SAXPrintHandlers( const   char* const encodingName
> > >                                   , const XMLFormatter::UnRepFlags
> > > unRepFlags) :  fTarget(new LocalFileFormatTarget(goutputfile)),
> > >     fFormatter
> > >     (
> > >          encodingName
> > >          , fTarget
> > >          , XMLFormatter::NoEscapes
> > >          , unRepFlags
> > >     )
> > > {
> > > }
> > >
> > > SAXPrintHandlers::~SAXPrintHandlers()
> > > {
> > >      delete fTarget;
> > > }
> > >
> > > Alberto
> > >
> > > At 10.02 24/06/2004 +0200, Caignart Olivier wrote:
> > > >Hello to XML-c-dev mailing list !
> > > >
> > > >I've tried to use a sample code found here  (below you could find the
> > > >original thread :
> > > >http://www.mail-archive.com/xerces-c-dev@xml.apache.org/msg08148.html
> > > >)to do the same thing as Thomas wanted to do in this thread.
> > > >Unfortunately i cannot make it work and i get this answer.
> > > >
> > > >Here's the answer of my compiler (gcc-3.3) :
> > > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:
> > > >In
> > > >    constructor `SAXPrintHandlers::SAXPrintHandlers(const char*,
> > > >    xercesc_2_5::XMLFormatter::UnRepFlags)':
> > > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> > 189:
> > > >error: no
> > > >    base or member initializers given following ':'
> > > >/home/.../src/xerces-c-src_2_5_0/include/xercesc/framework/XMLFormatter 
> > .hpp:449:
> > > >error: `
> > > >    xercesc_2_5::XMLFormatter::XMLFormatter()' is private
> > > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> > 189:
> > > >error: within
> > > >    this context
> > > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> > 190:
> > > >error: parse
> > > >    error before `(' token
> > > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> > 198:
> > > >error: no
> > > >    match for call to `(xercesc_2_5::XMLFormatter) (const char* const&,
> > > >    xercesc_2_5::XMLFormatTarget*&,
> > > >xercesc_2_5::XMLFormatter::EscapeFlags,
> > > >    const xercesc_2_5::XMLFormatter::UnRepFlags&)'
> > > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> > 199:
> > > >error: parse
> > > >    error before `:' token
> > > >make: ***
> > > >[/home/.../src/xerces-c-src_2_5_0/bin/obj/SAXPrint/SAXPrintHandlers.o]
> > > >Error 1
> > > >
> > > >
> > > >Could you tell me what's wrong? I'm neither a good programmer nor good
> > > >in Xerces as well so I'll try to understand your answer.
> > > >
> > > >
> > > >If you know any other method to write in a XML file from SAX please tell
> > > >me !!
> > > >
> > > >Regards,
> > > >Olivier Caignart
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> > >
> > >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Creating a XML document from SAX

Posted by Alberto Massari <am...@progress.com>.
Hi Olivier,
I made a mistake in writing the code (well, it happens, when you don't test 
the code before suggesting it! ;-) )
The order of the initialization methods after the ":" is derived from the 
order of declaration of the variables; so fTarget was still 0 when given to 
the constructor of XMLFormatter. You need to change the header to say

       LocalFileFormatTarget*  fTarget;
       XMLFormatter    fFormatter;

Alberto


At 17.25 24/06/2004 +0200, Caignart Olivier wrote:
>Thanks a lot Alberto !
>
>It was a typo as you said.
>
>Unfortunalty my trouble go a little further.
>I've tried this sample :
>
>SAXPrintHandlers::SAXPrintHandlers( const   char* const encodingName,
>const XMLFormatter::UnRepFlags unRepFlags)
> 
>: fTarget(new LocalFileFormatTarget(goutputfile)) ,
>fFormatter(encodingName, fTarget, XMLFormatter::NoEscapes, unRepFlags )
>{
>}
>SAXPrintHandlers::~SAXPrintHandlers()
>{
>         delete fTarget;
>}
>
>with static char* goutputFile = "/home/[...]/output.xml" ;
>
>but it doesn't work. I got a segmentation fault ! Anyway outputfile is
>created but not filled.
>
>Any idea?
>
>Olivier
>
>On Thu, 2004-06-24 at 13:35, Alberto Massari wrote:
> > Hi Olivier,
> > reading the message in the archive I would say it has a typo. The correct
> > code would be
> >
> > SAXPrintHandlers.hpp:
> >
> > class SAXPrintHandlers : public HandlerBase, private XMLFormatTarget
> > {
> > [...]
> >      XMLFormatter    fFormatter;
> >      LocalFileFormatTarget*  fTarget;
> > };
> >
> > ---SAXPrintHandlers.cpp:
> >
> > SAXPrintHandlers::SAXPrintHandlers( const   char* const encodingName
> >                                   , const XMLFormatter::UnRepFlags
> > unRepFlags) :  fTarget(new LocalFileFormatTarget(goutputfile)),
> >     fFormatter
> >     (
> >          encodingName
> >          , fTarget
> >          , XMLFormatter::NoEscapes
> >          , unRepFlags
> >     )
> > {
> > }
> >
> > SAXPrintHandlers::~SAXPrintHandlers()
> > {
> >      delete fTarget;
> > }
> >
> > Alberto
> >
> > At 10.02 24/06/2004 +0200, Caignart Olivier wrote:
> > >Hello to XML-c-dev mailing list !
> > >
> > >I've tried to use a sample code found here  (below you could find the
> > >original thread :
> > >http://www.mail-archive.com/xerces-c-dev@xml.apache.org/msg08148.html
> > >)to do the same thing as Thomas wanted to do in this thread.
> > >Unfortunately i cannot make it work and i get this answer.
> > >
> > >Here's the answer of my compiler (gcc-3.3) :
> > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:
> > >In
> > >    constructor `SAXPrintHandlers::SAXPrintHandlers(const char*,
> > >    xercesc_2_5::XMLFormatter::UnRepFlags)':
> > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> 189:
> > >error: no
> > >    base or member initializers given following ':'
> > >/home/.../src/xerces-c-src_2_5_0/include/xercesc/framework/XMLFormatter 
> .hpp:449:
> > >error: `
> > >    xercesc_2_5::XMLFormatter::XMLFormatter()' is private
> > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> 189:
> > >error: within
> > >    this context
> > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> 190:
> > >error: parse
> > >    error before `(' token
> > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> 198:
> > >error: no
> > >    match for call to `(xercesc_2_5::XMLFormatter) (const char* const&,
> > >    xercesc_2_5::XMLFormatTarget*&,
> > >xercesc_2_5::XMLFormatter::EscapeFlags,
> > >    const xercesc_2_5::XMLFormatter::UnRepFlags&)'
> > >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp: 
> 199:
> > >error: parse
> > >    error before `:' token
> > >make: ***
> > >[/home/.../src/xerces-c-src_2_5_0/bin/obj/SAXPrint/SAXPrintHandlers.o]
> > >Error 1
> > >
> > >
> > >Could you tell me what's wrong? I'm neither a good programmer nor good
> > >in Xerces as well so I'll try to understand your answer.
> > >
> > >
> > >If you know any other method to write in a XML file from SAX please tell
> > >me !!
> > >
> > >Regards,
> > >Olivier Caignart
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> >
> >
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Creating a XML document from SAX

Posted by Caignart Olivier <ca...@multitel.be>.
Thanks a lot Alberto !

It was a typo as you said.

Unfortunalty my trouble go a little further. 
I've tried this sample :

SAXPrintHandlers::SAXPrintHandlers( const   char* const encodingName,
const XMLFormatter::UnRepFlags unRepFlags)
															: fTarget(new LocalFileFormatTarget(goutputfile)) ,
fFormatter(encodingName, fTarget, XMLFormatter::NoEscapes, unRepFlags )
{
}
SAXPrintHandlers::~SAXPrintHandlers()
{
	delete fTarget;
}

with static char* goutputFile = "/home/[...]/output.xml" ;

but it doesn't work. I got a segmentation fault ! Anyway outputfile is
created but not filled.

Any idea? 

Olivier

On Thu, 2004-06-24 at 13:35, Alberto Massari wrote:
> Hi Olivier,
> reading the message in the archive I would say it has a typo. The correct 
> code would be
> 
> SAXPrintHandlers.hpp:
> 
> class SAXPrintHandlers : public HandlerBase, private XMLFormatTarget
> {
> [...]
>      XMLFormatter    fFormatter;
>      LocalFileFormatTarget*  fTarget;
> };
> 
> ---SAXPrintHandlers.cpp:
> 
> SAXPrintHandlers::SAXPrintHandlers( const   char* const encodingName
>                                   , const XMLFormatter::UnRepFlags 
> unRepFlags) :  fTarget(new LocalFileFormatTarget(goutputfile)),
>     fFormatter
>     (
>          encodingName
>          , fTarget
>          , XMLFormatter::NoEscapes
>          , unRepFlags
>     )
> {
> }
> 
> SAXPrintHandlers::~SAXPrintHandlers()
> {
>      delete fTarget;
> }
> 
> Alberto
> 
> At 10.02 24/06/2004 +0200, Caignart Olivier wrote:
> >Hello to XML-c-dev mailing list !
> >
> >I've tried to use a sample code found here  (below you could find the
> >original thread :
> >http://www.mail-archive.com/xerces-c-dev@xml.apache.org/msg08148.html
> >)to do the same thing as Thomas wanted to do in this thread.
> >Unfortunately i cannot make it work and i get this answer.
> >
> >Here's the answer of my compiler (gcc-3.3) :
> >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:
> >In
> >    constructor `SAXPrintHandlers::SAXPrintHandlers(const char*,
> >    xercesc_2_5::XMLFormatter::UnRepFlags)':
> >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:189: 
> >error: no
> >    base or member initializers given following ':'
> >/home/.../src/xerces-c-src_2_5_0/include/xercesc/framework/XMLFormatter.hpp:449: 
> >error: `
> >    xercesc_2_5::XMLFormatter::XMLFormatter()' is private
> >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:189: 
> >error: within
> >    this context
> >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:190: 
> >error: parse
> >    error before `(' token
> >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:198: 
> >error: no
> >    match for call to `(xercesc_2_5::XMLFormatter) (const char* const&,
> >    xercesc_2_5::XMLFormatTarget*&,
> >xercesc_2_5::XMLFormatter::EscapeFlags,
> >    const xercesc_2_5::XMLFormatter::UnRepFlags&)'
> >/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:199: 
> >error: parse
> >    error before `:' token
> >make: ***
> >[/home/.../src/xerces-c-src_2_5_0/bin/obj/SAXPrint/SAXPrintHandlers.o]
> >Error 1
> >
> >
> >Could you tell me what's wrong? I'm neither a good programmer nor good
> >in Xerces as well so I'll try to understand your answer.
> >
> >
> >If you know any other method to write in a XML file from SAX please tell
> >me !!
> >
> >Regards,
> >Olivier Caignart
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Creating a XML document from SAX

Posted by Alberto Massari <am...@progress.com>.
Hi Olivier,
reading the message in the archive I would say it has a typo. The correct 
code would be

SAXPrintHandlers.hpp:

class SAXPrintHandlers : public HandlerBase, private XMLFormatTarget
{
[...]
     XMLFormatter    fFormatter;
     LocalFileFormatTarget*  fTarget;
};

---SAXPrintHandlers.cpp:

SAXPrintHandlers::SAXPrintHandlers( const   char* const encodingName
                                  , const XMLFormatter::UnRepFlags 
unRepFlags) :  fTarget(new LocalFileFormatTarget(goutputfile)),
    fFormatter
    (
         encodingName
         , fTarget
         , XMLFormatter::NoEscapes
         , unRepFlags
    )
{
}

SAXPrintHandlers::~SAXPrintHandlers()
{
     delete fTarget;
}

Alberto

At 10.02 24/06/2004 +0200, Caignart Olivier wrote:
>Hello to XML-c-dev mailing list !
>
>I've tried to use a sample code found here  (below you could find the
>original thread :
>http://www.mail-archive.com/xerces-c-dev@xml.apache.org/msg08148.html
>)to do the same thing as Thomas wanted to do in this thread.
>Unfortunately i cannot make it work and i get this answer.
>
>Here's the answer of my compiler (gcc-3.3) :
>/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:
>In
>    constructor `SAXPrintHandlers::SAXPrintHandlers(const char*,
>    xercesc_2_5::XMLFormatter::UnRepFlags)':
>/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:189: 
>error: no
>    base or member initializers given following ':'
>/home/.../src/xerces-c-src_2_5_0/include/xercesc/framework/XMLFormatter.hpp:449: 
>error: `
>    xercesc_2_5::XMLFormatter::XMLFormatter()' is private
>/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:189: 
>error: within
>    this context
>/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:190: 
>error: parse
>    error before `(' token
>/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:198: 
>error: no
>    match for call to `(xercesc_2_5::XMLFormatter) (const char* const&,
>    xercesc_2_5::XMLFormatTarget*&,
>xercesc_2_5::XMLFormatter::EscapeFlags,
>    const xercesc_2_5::XMLFormatter::UnRepFlags&)'
>/home/.../src/xerces-c-src_2_5_0/samples/SAXPrint/SAXPrintHandlers.cpp:199: 
>error: parse
>    error before `:' token
>make: ***
>[/home/.../src/xerces-c-src_2_5_0/bin/obj/SAXPrint/SAXPrintHandlers.o]
>Error 1
>
>
>Could you tell me what's wrong? I'm neither a good programmer nor good
>in Xerces as well so I'll try to understand your answer.
>
>
>If you know any other method to write in a XML file from SAX please tell
>me !!
>
>Regards,
>Olivier Caignart



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org