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 Joe Marini <jo...@presidiosoftware.com> on 2001/10/26 02:07:45 UTC

Telling two empty tags apart

Hello all,

I'm hoping someone can help me with a basic question.

Suppose I have two tags that look like this:

<tag></tag>
<tag/>

Now, clearly, each is an empty tag. My question: is there any way within
Xerces to tell the difference between the two types of empty tags? For
example, if I wanted to modify the DOMPrint example to output these two tags
exactly as they appear in the source file, how would I do it?

Thanks,

Joe




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


Re: Telling two empty tags apart

Posted by Dean Roddey <dr...@charmedquark.com>.
Basically, you either override a method in one of the parsers, to get
limited access to the scanner output, or you write your own parser style
class and and store whatever you want, or you use the scanner directly
within your application. If you look at something like the ParserTest
program, you can see how that is done, or of course if you look at SAXParser
or DOMParser they also are examples of how to interact with the scanner.

--------------------------
Dean Roddey
The Charmed Quark Controller
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"If it don't have a control port, don't buy it!"


----- Original Message -----
From: "Jason E. Stewart" <ja...@openinformatics.com>
To: <xe...@xml.apache.org>
Sent: Saturday, October 27, 2001 7:46 AM
Subject: Re: Telling two empty tags apart


> "Dean Roddey" <dr...@charmedquark.com> writes:
>
> > Its been a long time since I did it, but I think I put in code so
> > that the underlying scanner reports the difference. But the problem
> > is that it does not propogate out through any standard APIs. If you
> > wanted to keep this info, you'd have to use the scanner directly and
> > have your own data structures to put all the data in.
>
> Hey Dean,
>
> None of this is documented in the API docs (since it's not in the API)
> how does what get ahold of the scanner? Do you have to monitor the
> scanner during operation or is the information still around after the
> parse is completed?
>
> Cheers,
> jas.
>
> ---------------------------------------------------------------------
> 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: Telling two empty tags apart

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Dean Roddey" <dr...@charmedquark.com> writes:

> Its been a long time since I did it, but I think I put in code so
> that the underlying scanner reports the difference. But the problem
> is that it does not propogate out through any standard APIs. If you
> wanted to keep this info, you'd have to use the scanner directly and
> have your own data structures to put all the data in.

Hey Dean,

None of this is documented in the API docs (since it's not in the API)
how does what get ahold of the scanner? Do you have to monitor the
scanner during operation or is the information still around after the
parse is completed?

Cheers,
jas.

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


Re: Telling two empty tags apart

Posted by Dean Roddey <dr...@charmedquark.com>.
Its been a long time since I did it, but I think I put in code so that the
underlying scanner reports the difference. But the problem is that it does
not propogate out through any standard APIs. If you wanted to keep this
info, you'd have to use the scanner directly and have your own data
structures to put all the data in.

--------------------------
Dean Roddey
The Charmed Quark Controller
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"If it don't have a control port, don't buy it!"


----- Original Message -----
From: "Jason E. Stewart" <ja...@openinformatics.com>
To: <xe...@xml.apache.org>
Sent: Friday, October 26, 2001 7:48 AM
Subject: Re: Telling two empty tags apart


> "Joe Marini" <jo...@presidiosoftware.com> writes:
>
> > Hello all,
> >
> > I'm hoping someone can help me with a basic question.
> >
> > Suppose I have two tags that look like this:
> >
> > <tag></tag>
> > <tag/>
> >
> > Now, clearly, each is an empty tag. My question: is there any way within
> > Xerces to tell the difference between the two types of empty tags? For
> > example, if I wanted to modify the DOMPrint example to output these two
tags
> > exactly as they appear in the source file, how would I do it?
>
> My understanding of the spec is that the two types of tags are
> interchangeable and it is up to each parser to implement them as it
> sees fit. So you can't do this in a reliable manner. I went digging
> through the spec but couldn't find the section that says this, so I
> could be wrong.
>
> jas.
>
> ---------------------------------------------------------------------
> 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: Telling two empty tags apart

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Joe Marini" <jo...@presidiosoftware.com> writes:

> Hello all,
> 
> I'm hoping someone can help me with a basic question.
> 
> Suppose I have two tags that look like this:
> 
> <tag></tag>
> <tag/>
> 
> Now, clearly, each is an empty tag. My question: is there any way within
> Xerces to tell the difference between the two types of empty tags? For
> example, if I wanted to modify the DOMPrint example to output these two tags
> exactly as they appear in the source file, how would I do it?

My understanding of the spec is that the two types of tags are
interchangeable and it is up to each parser to implement them as it
sees fit. So you can't do this in a reliable manner. I went digging
through the spec but couldn't find the section that says this, so I
could be wrong.

jas.

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


Re: Telling two empty tags apart

Posted by Joe Marini <jo...@presidiosoftware.com>.
Thanks for all your help everyone.

Joe

----- Original Message -----
From: "Dean Roddey" <dr...@charmedquark.com>
To: <xe...@xml.apache.org>
Sent: Friday, October 26, 2001 8:14 PM
Subject: Re: Telling two empty tags apart


> Yes, as I said in an earlier message, if you use the scanner directly, you
> can get this info. As you point out, you can override just the start
element
> and avoid writing your own parser, but you must store this information
> yourself.
>
> --------------------------
> Dean Roddey
> The Charmed Quark Controller
> Charmed Quark Software
> droddey@charmedquark.com
> http://www.charmedquark.com
>
> "If it don't have a control port, don't buy it!"
>
>
> ----- Original Message -----
> From: "Peter A. Volchek" <Pe...@ti.com.od.ua>
> To: <xe...@xml.apache.org>
> Sent: Friday, October 26, 2001 9:02 AM
> Subject: Re: Telling two empty tags apart
>
>
> > ----- Original Message -----
> > From: "Dean Roddey" <dr...@charmedquark.com>
> > To: <xe...@xml.apache.org>
> > Sent: Friday, October 26, 2001 11:01
> > Subject: Re: Telling two empty tags apart
> >
> >
> > > They are completely identical from XML's point of view, therefore they
> are
> > > from the parser's point of view. If what you are looking for is to
print
> > > them back out the same as how they were seen originally, you couldn't
do
> > > that.
> >
> > What about to provide own parser class with overridden method
> startElement()
> > ?
> > It has an argument "const bool   isEmpty" which set to true when <A/> is
> > parsed,
> > meaning than there would be no endElement() call.
> > So, the user may store such an elements in his own pool, and then, when
> > printing DOM tree, prints the element from pool as <A/> and others as
> > usually <A></A>
> > Thoughts ?
> >
> > Peter A. Volchek
> > Software Engineer
> > Metis International, Inc.
> > PeterV@ti.com.od.ua
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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: Telling two empty tags apart

Posted by Dean Roddey <dr...@charmedquark.com>.
Yes, as I said in an earlier message, if you use the scanner directly, you
can get this info. As you point out, you can override just the start element
and avoid writing your own parser, but you must store this information
yourself.

--------------------------
Dean Roddey
The Charmed Quark Controller
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"If it don't have a control port, don't buy it!"


----- Original Message -----
From: "Peter A. Volchek" <Pe...@ti.com.od.ua>
To: <xe...@xml.apache.org>
Sent: Friday, October 26, 2001 9:02 AM
Subject: Re: Telling two empty tags apart


> ----- Original Message -----
> From: "Dean Roddey" <dr...@charmedquark.com>
> To: <xe...@xml.apache.org>
> Sent: Friday, October 26, 2001 11:01
> Subject: Re: Telling two empty tags apart
>
>
> > They are completely identical from XML's point of view, therefore they
are
> > from the parser's point of view. If what you are looking for is to print
> > them back out the same as how they were seen originally, you couldn't do
> > that.
>
> What about to provide own parser class with overridden method
startElement()
> ?
> It has an argument "const bool   isEmpty" which set to true when <A/> is
> parsed,
> meaning than there would be no endElement() call.
> So, the user may store such an elements in his own pool, and then, when
> printing DOM tree, prints the element from pool as <A/> and others as
> usually <A></A>
> Thoughts ?
>
> Peter A. Volchek
> Software Engineer
> Metis International, Inc.
> PeterV@ti.com.od.ua
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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: Telling two empty tags apart

Posted by "Peter A. Volchek" <Pe...@ti.com.od.ua>.
----- Original Message -----
From: "Dean Roddey" <dr...@charmedquark.com>
To: <xe...@xml.apache.org>
Sent: Friday, October 26, 2001 11:01
Subject: Re: Telling two empty tags apart


> They are completely identical from XML's point of view, therefore they are
> from the parser's point of view. If what you are looking for is to print
> them back out the same as how they were seen originally, you couldn't do
> that.

What about to provide own parser class with overridden method startElement()
?
It has an argument "const bool   isEmpty" which set to true when <A/> is
parsed,
meaning than there would be no endElement() call.
So, the user may store such an elements in his own pool, and then, when
printing DOM tree, prints the element from pool as <A/> and others as
usually <A></A>
Thoughts ?

Peter A. Volchek
Software Engineer
Metis International, Inc.
PeterV@ti.com.od.ua






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


Re: Telling two empty tags apart

Posted by Dean Roddey <dr...@charmedquark.com>.
They are completely identical from XML's point of view, therefore they are
from the parser's point of view. If what you are looking for is to print
them back out the same as how they were seen originally, you couldn't do
that. Given that there is no difference, you should just give your users a
choice of how they want to have them show up when printed back out, and put
them all back out that way.

--------------------------
Dean Roddey
The Charmed Quark Controller
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"If it don't have a control port, don't buy it!"


----- Original Message -----
From: "Joe Marini" <jo...@presidiosoftware.com>
To: <xe...@xml.apache.org>
Sent: Thursday, October 25, 2001 5:07 PM
Subject: Telling two empty tags apart


> Hello all,
>
> I'm hoping someone can help me with a basic question.
>
> Suppose I have two tags that look like this:
>
> <tag></tag>
> <tag/>
>
> Now, clearly, each is an empty tag. My question: is there any way within
> Xerces to tell the difference between the two types of empty tags? For
> example, if I wanted to modify the DOMPrint example to output these two
tags
> exactly as they appear in the source file, how would I do it?
>
> Thanks,
>
> Joe
>
>
>
>
> ---------------------------------------------------------------------
> 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: Telling two empty tags apart

Posted by Joe Marini <jo...@presidiosoftware.com>.
Yeah, that's what I figured, though I was hoping that Xerces kept some kind
of text buffer that represented the input that I could examine.

Thanks,

Joe

----- Original Message -----
From: "Juergen Hermann" <jh...@web.de>
To: "Joe Marini" <jo...@presidiosoftware.com>; <xe...@xml.apache.org>
Sent: Friday, October 26, 2001 4:20 AM
Subject: Re: Telling two empty tags apart


On Thu, 25 Oct 2001 17:07:45 -0700, Joe Marini wrote:

>example, if I wanted to modify the DOMPrint example to output these two
tags
>exactly as they appear in the source file, how would I do it?

Not at all, since they're equal. What you want is text procesing, not XML
processing.



Ciao, Jürgen

--
Jürgen Hermann, Developer (jhe@webde-ag.de)
WEB.DE AG, http://webde-ag.de/





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


Re: Telling two empty tags apart

Posted by Juergen Hermann <jh...@web.de>.
On Thu, 25 Oct 2001 17:07:45 -0700, Joe Marini wrote:

>example, if I wanted to modify the DOMPrint example to output these two tags
>exactly as they appear in the source file, how would I do it?

Not at all, since they're equal. What you want is text procesing, not XML 
processing.



Ciao, Jürgen

--
Jürgen Hermann, Developer (jhe@webde-ag.de)
WEB.DE AG, http://webde-ag.de/



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