You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by yr...@daimlerchrysler.com on 2003/05/08 03:47:16 UTC

PLS HELP: URGENT - INTERMITTENT PROBLEMS IF I USe DOM TO PARSE XML

I am using DOM to parse the XML. The problem is that the program is not
able to retrieve the data after it has processed certain number of XML
files. The XML file we are using is some what larger (The XML file is
attached to this email).
(See attached file: data.xml)
The last statement that is being executed is the "Element input =
docIn.getDocumentElement();". After that statement, its not going to any of
the if-else blocks. The same code started working after I have restarted
the AppServer JVM. This is the second time that happened during the last 3
months. We are using Xerces 1.2.

Its not throwing any exception either.

I appreciate if anyone can help me to resolve this issue as this is
happening on the production environment.

THANKS IN ADVANCE.

CODE:

public class XMLBean
{
      public static void xmlParser(InputStream inStream)
      {
            try
            {
                  org.apache.xerces.parsers.DOMParser parser = new
org.apache.xerces.parsers.DOMParser();
                  parser.parse(new InputSource(inStream));
                  Document docIn = parser.getDocument();

                  Element input = docIn.getDocumentElement();

                  try
                  {
                        NodeList nlTrans = null;

                        if ((nlTrans = input.getElementsByTagName
("aceAPPL")).getLength() == 1)
                        {
                              remoteAppID =
getRemoteAppID(nlTrans.item(0));
                              dealerCode=getDealerCode(nlTrans.item(0));
                              Element el=(Element)nlTrans.item(0);
                              NodeList nlTemp = el.getElementsByTagName
("aceHeader");
                              Element elHeader = (Element)nlTemp.item(0);
                              NamedNodeMap nnmHeader =
elHeader.getAttributes();
                              sourceSystemQ = nnmHeader.getNamedItem
("sourceSystem").getNodeValue();

                              ApplTrans appl = new ApplTrans();
                              msgForACE =
appl.formatMessage(nlTrans.item(0));
                        }
                        else if ((nlTrans = input.getElementsByTagName
("aceMPPL")).getLength() == 1)
                        {
                              sourceSystem =
getSourceSystem(nlTrans.item(0));
                              dealerCode=getDealerCode(nlTrans.item(0));

                              Element el=(Element) nlTrans.item(0);
                              NodeList nlTemp = el.getElementsByTagName
("aceHeader");
                              Element elHeader = (Element)nlTemp.item(0);
                              NamedNodeMap nnmHeader =
elHeader.getAttributes();
                              sourceSystemQ = nnmHeader.getNamedItem
("sourceSystem").getNodeValue();
                              remoteAppID =
getRemoteAppID(nlTrans.item(0));
                              MpplTrans mppl = new MpplTrans();
                              trans = mppl.getTransType(nlTrans.item(0));

                              if (trans.equals("MPPL"))
                              {
                                          strApp =
getAppFromSource(mppl.validate(nlTrans.item(0)));
                                          msgForACE =
mppl.formatMessage(nlTrans.item(0));
                              }
                              else if (trans.equals("MUSN"))
                              {
                                          MusnTrans musn = new MusnTrans();
                                          strApp =
getAppFromSource(musn.validate(nlTrans.item(0)));

logger.debug(this,"doPost","Before formatMessage");
                                          msgForACE =
musn.formatMessage(nlTrans.item(0));
                                    }
                              }
                        }
                        catch (FormatException ex)
                        {
                              ex.printStackTrace();
                        }
                        catch (ValidationException ex)
                        {
                              ex.printStackTrace();
                        }
                        catch (XMLGeneralException ex)
                        {
                              ex.printStackTrace();
                        }
                  }
                  catch (SAXNotRecognizedException ex)
                  {
                        ex.printStackTrace();
                  }
                  catch (SAXNotSupportedException ex)
                  {
                        ex.printStackTrace();
                  }
                  catch (SAXException ex)
                  {
                        ex.printStackTrace();
                  }
                  catch (Exception ex)
                  {
                        ex.printStackTrace();
                  }
      }
}

Sincerely,
Yarram Reddy
WebACE
Tie/L:870-5968
OutsideLine:(248) 427-5968
Email:YR11@daimlerchrysler.com
Pager: 313 714 5169 or YR11-page@dcx.com