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 Mirko Braun <mi...@gmx.de> on 2009/11/09 21:39:08 UTC

SaxParser and tag without a value

Hello everybody,

i'm using the SaxParser and the BaseHandler class
to parse an xml file. In my xml file there is a tag
like <tag></tag>.
If i use the characters() method of the BaseHandler
for this tag, i would expect to get an empty string
but i get an value with some cryptical characters.

How can i get an empty string for this tag?

Thanks in advanced.

Best regards
Mirko

Re: RE: SaxParser and tag without a value

Posted by Mirko Braun <mi...@gmx.de>.
Hi John,

thank you very much for your help.
I will try it this way.

Best regards,
Mirko

-------- Original-Nachricht --------
> Datum: Thu, 12 Nov 2009 11:44:56 -0500
> Von: John Lilley <jl...@datalever.com>
> An: "c-users@xerces.apache.org" <c-...@xerces.apache.org>
> Betreff: RE: SaxParser and tag without a value

> One strategy is to keep a stack of strings in your parser subclass.  When
> an element is started, push an empty string on the stack.  When
> characters() is called, append to the string.  When the element ends, pop the stack.
> 
> john
> 
> ________________________________________
> From: Mirko Braun [mirko.braun@gmx.de]
> Sent: Wednesday, November 11, 2009 1:13 PM
> To: c-users@xerces.apache.org
> Subject: Re: SaxParser and tag without a value
> 
> Hi Boris,
> 
> thank you for your answer. I think you are right.
> This would explain why i get cryptical signs as
> a value for this tag.
> Is there any possibility to determine such tags
> as tags which has no value (with SaxParser and the
> BaseHandler)?
> 
> Best regards,
> Mirko
> 
> -------- Original-Nachricht --------
> > Datum: Wed, 11 Nov 2009 19:36:38 +0200
> > Von: Boris Kolpackov <bo...@codesynthesis.com>
> > An: c-users@xerces.apache.org
> > Betreff: Re: SaxParser and tag without a value
> 
> > Hi Mirko,
> >
> > Mirko Braun <mi...@gmx.de> writes:
> >
> > > In my xml file there is a tag like <tag></tag>.
> > > If i use the characters() method of the BaseHandler
> > > for this tag, i would expect to get an empty string
> > > but i get an value with some cryptical characters.
> >
> > This element does not contain any data so I would expect
> > the parser not to call characters() at all.
> >
> > Boris
> >
> > --
> > Boris Kolpackov, Code Synthesis
> > http://codesynthesis.com/~boris/blog
> > Open-source XML data binding for C++
> > http://codesynthesis.com/products/xsd
> > XML data binding for embedded systems
> > http://codesynthesis.com/products/xsde
> > Command line interface to C++ compiler
> > http://codesynthesis.com/projects/cli

RE: SaxParser and tag without a value

Posted by John Lilley <jl...@datalever.com>.
One strategy is to keep a stack of strings in your parser subclass.  When an element is started, push an empty string on the stack.  When characters() is called, append to the string.  When the element ends, pop the stack.

john

________________________________________
From: Mirko Braun [mirko.braun@gmx.de]
Sent: Wednesday, November 11, 2009 1:13 PM
To: c-users@xerces.apache.org
Subject: Re: SaxParser and tag without a value

Hi Boris,

thank you for your answer. I think you are right.
This would explain why i get cryptical signs as
a value for this tag.
Is there any possibility to determine such tags
as tags which has no value (with SaxParser and the
BaseHandler)?

Best regards,
Mirko

-------- Original-Nachricht --------
> Datum: Wed, 11 Nov 2009 19:36:38 +0200
> Von: Boris Kolpackov <bo...@codesynthesis.com>
> An: c-users@xerces.apache.org
> Betreff: Re: SaxParser and tag without a value

> Hi Mirko,
>
> Mirko Braun <mi...@gmx.de> writes:
>
> > In my xml file there is a tag like <tag></tag>.
> > If i use the characters() method of the BaseHandler
> > for this tag, i would expect to get an empty string
> > but i get an value with some cryptical characters.
>
> This element does not contain any data so I would expect
> the parser not to call characters() at all.
>
> Boris
>
> --
> Boris Kolpackov, Code Synthesis
> http://codesynthesis.com/~boris/blog
> Open-source XML data binding for C++
> http://codesynthesis.com/products/xsd
> XML data binding for embedded systems
> http://codesynthesis.com/products/xsde
> Command line interface to C++ compiler
> http://codesynthesis.com/projects/cli

Re: SaxParser and tag without a value

Posted by Mirko Braun <mi...@gmx.de>.
Hi Boris,

thank you for your answer. I think you are right.
This would explain why i get cryptical signs as
a value for this tag.
Is there any possibility to determine such tags
as tags which has no value (with SaxParser and the
BaseHandler)?

Best regards,
Mirko

-------- Original-Nachricht --------
> Datum: Wed, 11 Nov 2009 19:36:38 +0200
> Von: Boris Kolpackov <bo...@codesynthesis.com>
> An: c-users@xerces.apache.org
> Betreff: Re: SaxParser and tag without a value

> Hi Mirko,
> 
> Mirko Braun <mi...@gmx.de> writes:
> 
> > In my xml file there is a tag like <tag></tag>.
> > If i use the characters() method of the BaseHandler
> > for this tag, i would expect to get an empty string
> > but i get an value with some cryptical characters.
> 
> This element does not contain any data so I would expect
> the parser not to call characters() at all.
> 
> Boris
> 
> -- 
> Boris Kolpackov, Code Synthesis       
> http://codesynthesis.com/~boris/blog
> Open-source XML data binding for C++  
> http://codesynthesis.com/products/xsd
> XML data binding for embedded systems 
> http://codesynthesis.com/products/xsde
> Command line interface to C++ compiler
> http://codesynthesis.com/projects/cli

Re: SaxParser and tag without a value

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi Mirko,

Mirko Braun <mi...@gmx.de> writes:

> In my xml file there is a tag like <tag></tag>.
> If i use the characters() method of the BaseHandler
> for this tag, i would expect to get an empty string
> but i get an value with some cryptical characters.

This element does not contain any data so I would expect
the parser not to call characters() at all.

Boris

-- 
Boris Kolpackov, Code Synthesis        http://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli