Well, seems like you've got lots of options on getting the error message
you need as long as you know its ID.

1) Because every MESSAGE element has a unique ID attribute, you can use
the method:

DOMElement* DOMDocument::getElementById (const XMLCh * elementId) const 

Which will return you the MESSAGE element matching your error ID. 

2) You could use XPATH (provided by Xalan) to lookup the right node, but
that's a whole other kettle of fish.

3) You could laboriously iterate over every MESSAGE element in the
document and check its ID.

4) You could use SAX instead and place all the error messages and steps
into a hash table to be accessed by ID.

...

There's lots more ways to do this, the first is by far the easiest but
you may have additional requirements that change that.

Once you have the MESSAGE element, use a combination of getNextChild(),
getSibling() & getNodeValue() to move to the sub elements such as TITLE
or STEP.

Regards,
Scot Nielsen


-----Original Message-----
From: Sarah Leitner [mailto:[EMAIL PROTECTED]] 
Sent: 17 December 2002 14:54
To: [EMAIL PROTECTED]
Subject: RE: sample code?

To all,
Here is a general idea of the XML code that I need to parse in. Please
see
the messages below if you need more details.

Thanks.

Sarah Leitner


<?xml version="1.0"?>
<!DOCTYPE CPDD SYSTEM "cpdd_ver2.dtd">
<!-- other stuff goes here, lots of other tags, particularly help info
and
points of contact for if the user has a problem. So this all needs to be
parsed and either thrown out or put into a structure for use in help
later.
But I assume once I understand the error message part, I can do this
part
pretty easily -->

                                <MESSAGES id="err_001">
                                        <DESCINFO>This message is thrown
if...</DESCINFO>
                                        <PROCEDURE>
                                                <TITLE>An error has
occurred and no description is available...
</TITLE>
                                                <STEP>
        
<STEP_CONTENT>Contact your local system administrator for assistance
or re-install.</STEP_CONTENT>
                                                </STEP>
                                        </PROCEDURE>
                                </MESSAGES>
                                <MESSAGES id="err_002">
                                        <DESCINFO>This message is thrown
if the AutoUpdate component is unable
to reach any of the servers...</DESCINFO>
                                        <PROCEDURE>
                                                <TITLE>No update servers
are available at this time, please try again
later.</TITLE>
                                                <STEP>
        
<STEP_CONTENT>The following actions may correct this condition:
                                                                <LIST>
        
<LI>Check and ensure you have an operable network connection.</LI>
        
<LI>Check for updates to the server address list.</LI>
                                                                </LIST>
                                                        </STEP_CONTENT>
                                                </STEP>
                                        </PROCEDURE>
                                </MESSAGES>
<!-- after this there is ending body, etc. that's it -->

-----Original Message-----
From: Scot Nielsen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 17, 2002 4:45 AM
To: [EMAIL PROTECTED]
Subject: RE: sample code?


I took a look at the replies to your previous question and they seem to
me the right way to go, but that is only if we understand your
requirements.

What we've been assuming is that at the point at which you need to
display an error message, you will be given a code identifying said
error. With this code you then need to lookup the actual error message
in the xml document and display it somehow.

Before we discuss how you'd do just that (as there are many ways), is
this what you want to do or have I made other assumptions? Could you
attach a snippet of XML showing the error code and message structure? We
can then look at how you'd extract it at runtime.

[Pass on the DOMBuilder / XercesDOMParser question.]

Regards, Scot


-----Original Message-----
From: Sarah Leitner [mailto:[EMAIL PROTECTED]]
Sent: 16 December 2002 14:49
To: [EMAIL PROTECTED]
Subject: RE: sample code?

OK, I will tell you what I am doing. I've already had some instructions
from
people in the group, but I don't understand Xerces well enough to really
implement them.  And the project seems to have grown more complex since
then.

What it is is the following: we have a huge DTD for our project that is
given to us by an outside group. In this DTD is all the help for the
project
as well as all of the error messages that the program will use. Help
will be
displayed in a browser, but error messages will need to be parsed to be
displayed when an error occurs. Each will have an error message code and
a
message and an action to go with it. So how do I get the code?

I would also like to know precisely what is the difference between a
XercesDOMParser and a DOMBuilder. Is the difference simply that the
parser
parses the XML document while the DOMBuilder can take input from several
sources and make it into one document?

Thanks much.

Sarah Leitner

-----Original Message-----
From: Scot Nielsen [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 13, 2002 5:44 PM
To: [EMAIL PROTECTED]
Subject: Re: sample code?


Hello Sarah, can you tell us exactly what you're
trying to do, what you need Xerces to do for you?

Xerces is quite a beast [I hope the contributors don't
mind me saying that] and coming to it fresh I can
certainly see how you might find it a daunting
prospect - I did. But nevertheless, regardless of its
status as an open source development, its level of
software quality is extremely high - its in its nature
to be so if _it_ wishes to succeed.

>From personal experience, I was quite surprised at how
low-level the applications' programmer finds themself
to the xml. However, when you consider the effort that
goes into parsing an xml document the learning curve
seems to dwindle in the light of the XML standard
implemented in Xerces.

Regards, Scot.


 --- "Leitner, Sarah M. [Contractor]"
<[EMAIL PROTECTED]> wrote: > To all,
>
> I am still kind of lost on using Xerces for parsing.
> Does anyone have any
> extra documentation or sample kind they can send my
> way? I've ordered the
> book that was recommended to me by someone (Erick?)
> but it hasn't arrived
> yet. I really think that the documentation and
> sample code needs to be
> improved. Although I hate to say that, because I
> have a two year old so I
> know I won't have time to help! Thanks in advance.
>
> Sarah
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to