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 "Ing. Hans Pesata" <hp...@chello.at> on 2002/04/20 17:41:40 UTC

tree-parsing with SAX2 ???

Hi !

I am currently writing an XML-parser using XERCES 1.7.0 with VC++ 6.0.

We are replacing an old proprietary file-format with XML and therefore we
have to
write a new parser too. We decided to use SAX2 because it fits best within
our apps design.

My SAX2-based parser overrides the startElement() member to build its
data-structures.

I have a problem with a tree-structure which looks like this in XML:

.
.
.
	<!-- Block -->
	<block id="_1" name="Block1"
		<signal id="_2" name="Msg1"/>

		<!-- Sub-block -->
		<block id="_3" name="SubBlock1">
			<signal id="_4" name="SubMsg_1"/>

			<!-- Sub-Sub-block -->
			<block id="_5" name="SubSubBlock1">
				<signal id="_6" name="SubSubMsg_1"/>
			</block>
		</block>
	</block>

	<!-- Block -->
	<block id="_7" name="Block2"
		<signal id="_8" name="Msg2"/>
	</block>

.
.
.

I need to get the level-information from the SAX2-parser, if the block I am
processing within startElement()
is a block at the root-level or a sub-block of another block.

how can I accomplish this ?

Thanx in advance!

Regards,
Hans Pesata



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


Re: tree-parsing with SAX2 ???

Posted by Radovan Chytracek <Ra...@cern.ch>.
Hi,

        install your own stack keeping the track of the nesting levels.
Neither one provides this info via standard SAX or SAX2 APIs.

Cheers
              Radovan

> Hi !
>
> I am currently writing an XML-parser using XERCES 1.7.0 with VC++ 6.0.
>
> We are replacing an old proprietary file-format with XML and therefore we
> have to
> write a new parser too. We decided to use SAX2 because it fits best within
> our apps design.
>
> My SAX2-based parser overrides the startElement() member to build its
> data-structures.
>
> I have a problem with a tree-structure which looks like this in XML:
>
> .
> .
> .
> <!-- Block -->
> <block id="_1" name="Block1"
> <signal id="_2" name="Msg1"/>
>
> <!-- Sub-block -->
> <block id="_3" name="SubBlock1">
> <signal id="_4" name="SubMsg_1"/>
>
> <!-- Sub-Sub-block -->
> <block id="_5" name="SubSubBlock1">
> <signal id="_6" name="SubSubMsg_1"/>
> </block>
> </block>
> </block>
>
> <!-- Block -->
> <block id="_7" name="Block2"
> <signal id="_8" name="Msg2"/>
> </block>
>
> .
> .
> .
>
> I need to get the level-information from the SAX2-parser, if the block I am
> processing within startElement()
> is a block at the root-level or a sub-block of another block.
>
> how can I accomplish this ?
>
> Thanx in advance!
>
> Regards,
> Hans Pesata
>
>
>
> ---------------------------------------------------------------------
> 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


AW: tree-parsing with SAX2 ???

Posted by "Ing. Hans Pesata" <hp...@chello.at>.
Hi !

// You keep up with the level. When you get a start element, push the new
// element onto the stack, when you get an end element, pop the top level
off.
// That way, the one on the top of the stack is always the one that the
current
// incoming content is for.

ok, I understand.

Thanx for the information !

Regards,
Hans Pesata



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


Re: tree-parsing with SAX2 ???

Posted by Dean Roddey <dr...@charmedquark.com>.
You keep up with the level. When you get a start element, push the new
element onto the stack, when you get an end element, pop the top level off.
That way, the one on the top of the stack is always the one that the current
incoming content is for.

--------------------------
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: "Ing. Hans Pesata" <hp...@chello.at>
To: <xe...@xml.apache.org>
Sent: Saturday, April 20, 2002 8:54 AM
Subject: AW: tree-parsing with SAX2 ???


> Hi !
>
> // install your own stack keeping the track of the nesting levels.
> // Neither one provides this info via standard SAX or SAX2 APIs.
> // Cheers
> //              Radovan
>
> Thanx for your reply !
>
> where do I get the information about the current level from ?
>
> startElement() just gives me the element and its attributes.
> at this point I dont know about the level I am currently in.
>
> Regards,
> Hans Pesata
>
>
>
> ---------------------------------------------------------------------
> 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


AW: tree-parsing with SAX2 ???

Posted by "Ing. Hans Pesata" <hp...@chello.at>.
Hi !

// install your own stack keeping the track of the nesting levels.
// Neither one provides this info via standard SAX or SAX2 APIs.
// Cheers
//              Radovan

Thanx for your reply !

where do I get the information about the current level from ?

startElement() just gives me the element and its attributes.
at this point I dont know about the level I am currently in.

Regards,
Hans Pesata



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