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 "Raj Devanesan (JIRA)" <xe...@xml.apache.org> on 2005/03/27 11:52:16 UTC

[jira] Created: (XERCESC-1387) Unable to parse XML files using SAX2 is not recursive

Unable to parse XML files using SAX2 is not recursive
-----------------------------------------------------

         Key: XERCESC-1387
         URL: http://issues.apache.org/jira/browse/XERCESC-1387
     Project: Xerces-C++
        Type: Bug
  Components: SAX/SAX2  
    Versions: 2.6.0    
 Environment: LINUX
    Reporter: Raj Devanesan


Hi,

I have upgraded my application to use xerces 2_6_0 from 2_2. My application recursively evaluates XML files. Following is the code extract

Get()
{
 MsgXmlReader* xmlReader = new MsgXmlReader();
 MsgConfigProcessorSimple processorSimple( config );
 processorSimple.init( file, path );
 xmlReader->addProcessor( &processorSimple );
 xmlReader->process( file );
 delete xmlReader;
}

The process method of XML Reader

//=============================================================================
// process
//=============================================================================
void MsgXmlReader::process( string file ) throw (MsgException)
{
  SAX2XMLReader* parser = NULL;

  try
  {
    XMLPlatformUtils::Initialize();

    parser = XMLReaderFactory::createXMLReader();

    parser->setContentHandler( this );
    parser->setErrorHandler( this );
  
    parser->parse( file.c_str() );

    delete parser;
    parser = NULL;
    
    XMLPlatformUtils::Terminate();
  }
  catch( const XMLException& ex )
  {
    if( parser )
    {
      delete parser;
    }

    THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
  }
  catch( const SAXException& ex )
  {
    if( parser )
    {
      delete parser;
    }

    THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
  }
}

I have added a feture to parse any files include by using a include tag
 <include file="xyz.xml/>

When I try to parse the included file the application hangs. 

 MsgXmlReader* xmlReader = new MsgXmlReader();

The above line could not create a new MsgXmlReader. 

Do you know the reason. I tried the samples to do recursive evaluation and it works. If you have seen such problem please let me know


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


[jira] Commented: (XERCESC-1387) Unable to parse XML files using SAX2 is not recursive

Posted by "Alberto Massari (JIRA)" <xe...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XERCESC-1387?page=comments#action_61618 ]
     
Alberto Massari commented on XERCESC-1387:
------------------------------------------

I don't think it's a problem caused by Initialize/Terminate; if he is
starting a new parsing while the main one is still running, there should
be no risk that Terminate does anything bad.
The thing I notice is that you say the hang occurs in the line

  MsgXmlReader* xmlReader = new MsgXmlReader();

We don't have the code for that constructor, but the fact that the code
interacting with Xerces is only inside the process() method make me
think that the error is in your code.

Please post the code for that constructor and let us know if we should
close the bug.

Alberto

> Unable to parse XML files using SAX2 is not recursive
> -----------------------------------------------------
>
>          Key: XERCESC-1387
>          URL: http://issues.apache.org/jira/browse/XERCESC-1387
>      Project: Xerces-C++
>         Type: Bug
>   Components: SAX/SAX2
>     Versions: 2.6.0
>  Environment: LINUX
>     Reporter: Raj Devanesan

>
> Hi,
> I have upgraded my application to use xerces 2_6_0 from 2_2. My application recursively evaluates XML files. Following is the code extract
> Get()
> {
>  MsgXmlReader* xmlReader = new MsgXmlReader();
>  MsgConfigProcessorSimple processorSimple( config );
>  processorSimple.init( file, path );
>  xmlReader->addProcessor( &processorSimple );
>  xmlReader->process( file );
>  delete xmlReader;
> }
> The process method of XML Reader
> //=============================================================================
> // process
> //=============================================================================
> void MsgXmlReader::process( string file ) throw (MsgException)
> {
>   SAX2XMLReader* parser = NULL;
>   try
>   {
>     XMLPlatformUtils::Initialize();
>     parser = XMLReaderFactory::createXMLReader();
>     parser->setContentHandler( this );
>     parser->setErrorHandler( this );
>   
>     parser->parse( file.c_str() );
>     delete parser;
>     parser = NULL;
>     
>     XMLPlatformUtils::Terminate();
>   }
>   catch( const XMLException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
>   catch( const SAXException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
> }
> I have added a feture to parse any files include by using a include tag
>  <include file="xyz.xml/>
> When I try to parse the included file the application hangs. 
>  MsgXmlReader* xmlReader = new MsgXmlReader();
> The above line could not create a new MsgXmlReader. 
> Do you know the reason. I tried the samples to do recursive evaluation and it works. If you have seen such problem please let me know

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


[jira] Commented: (XERCESC-1387) Unable to parse XML files using SAX2 is not recursive

Posted by "Raj Devanesan (JIRA)" <xe...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XERCESC-1387?page=comments#action_61621 ]
     
Raj Devanesan commented on XERCESC-1387:
----------------------------------------

All,

Thanks for your help. I have identified the issue. I am doing a delete of the char* returned by XMLString::transcode(). This was necessary when I used the DOMString class. Once I removed the delete it works OK. Appreciate you help. In fact I am very surprised to see such a quck followup. 

Thanks Everyone.

Raj.

> Unable to parse XML files using SAX2 is not recursive
> -----------------------------------------------------
>
>          Key: XERCESC-1387
>          URL: http://issues.apache.org/jira/browse/XERCESC-1387
>      Project: Xerces-C++
>         Type: Bug
>   Components: SAX/SAX2
>     Versions: 2.6.0
>  Environment: LINUX
>     Reporter: Raj Devanesan

>
> Hi,
> I have upgraded my application to use xerces 2_6_0 from 2_2. My application recursively evaluates XML files. Following is the code extract
> Get()
> {
>  MsgXmlReader* xmlReader = new MsgXmlReader();
>  MsgConfigProcessorSimple processorSimple( config );
>  processorSimple.init( file, path );
>  xmlReader->addProcessor( &processorSimple );
>  xmlReader->process( file );
>  delete xmlReader;
> }
> The process method of XML Reader
> //=============================================================================
> // process
> //=============================================================================
> void MsgXmlReader::process( string file ) throw (MsgException)
> {
>   SAX2XMLReader* parser = NULL;
>   try
>   {
>     XMLPlatformUtils::Initialize();
>     parser = XMLReaderFactory::createXMLReader();
>     parser->setContentHandler( this );
>     parser->setErrorHandler( this );
>   
>     parser->parse( file.c_str() );
>     delete parser;
>     parser = NULL;
>     
>     XMLPlatformUtils::Terminate();
>   }
>   catch( const XMLException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
>   catch( const SAXException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
> }
> I have added a feture to parse any files include by using a include tag
>  <include file="xyz.xml/>
> When I try to parse the included file the application hangs. 
>  MsgXmlReader* xmlReader = new MsgXmlReader();
> The above line could not create a new MsgXmlReader. 
> Do you know the reason. I tried the samples to do recursive evaluation and it works. If you have seen such problem please let me know

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


[jira] Commented: (XERCESC-1387) Unable to parse XML files using SAX2 is not recursive

Posted by "David Bertoni (JIRA)" <xe...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XERCESC-1387?page=comments#action_61589 ]
     
David Bertoni commented on XERCESC-1387:
----------------------------------------

You should not call XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate() in your process() member function.  Call Initialize() one when your application starts and call Terminate() when your application exits.

> Unable to parse XML files using SAX2 is not recursive
> -----------------------------------------------------
>
>          Key: XERCESC-1387
>          URL: http://issues.apache.org/jira/browse/XERCESC-1387
>      Project: Xerces-C++
>         Type: Bug
>   Components: SAX/SAX2
>     Versions: 2.6.0
>  Environment: LINUX
>     Reporter: Raj Devanesan

>
> Hi,
> I have upgraded my application to use xerces 2_6_0 from 2_2. My application recursively evaluates XML files. Following is the code extract
> Get()
> {
>  MsgXmlReader* xmlReader = new MsgXmlReader();
>  MsgConfigProcessorSimple processorSimple( config );
>  processorSimple.init( file, path );
>  xmlReader->addProcessor( &processorSimple );
>  xmlReader->process( file );
>  delete xmlReader;
> }
> The process method of XML Reader
> //=============================================================================
> // process
> //=============================================================================
> void MsgXmlReader::process( string file ) throw (MsgException)
> {
>   SAX2XMLReader* parser = NULL;
>   try
>   {
>     XMLPlatformUtils::Initialize();
>     parser = XMLReaderFactory::createXMLReader();
>     parser->setContentHandler( this );
>     parser->setErrorHandler( this );
>   
>     parser->parse( file.c_str() );
>     delete parser;
>     parser = NULL;
>     
>     XMLPlatformUtils::Terminate();
>   }
>   catch( const XMLException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
>   catch( const SAXException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
> }
> I have added a feture to parse any files include by using a include tag
>  <include file="xyz.xml/>
> When I try to parse the included file the application hangs. 
>  MsgXmlReader* xmlReader = new MsgXmlReader();
> The above line could not create a new MsgXmlReader. 
> Do you know the reason. I tried the samples to do recursive evaluation and it works. If you have seen such problem please let me know

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


[jira] Closed: (XERCESC-1387) Unable to parse XML files using SAX2 is not recursive

Posted by "Alberto Massari (JIRA)" <xe...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XERCESC-1387?page=history ]
     
Alberto Massari closed XERCESC-1387:
------------------------------------

    Resolution: Invalid

> Unable to parse XML files using SAX2 is not recursive
> -----------------------------------------------------
>
>          Key: XERCESC-1387
>          URL: http://issues.apache.org/jira/browse/XERCESC-1387
>      Project: Xerces-C++
>         Type: Bug
>   Components: SAX/SAX2
>     Versions: 2.6.0
>  Environment: LINUX
>     Reporter: Raj Devanesan

>
> Hi,
> I have upgraded my application to use xerces 2_6_0 from 2_2. My application recursively evaluates XML files. Following is the code extract
> Get()
> {
>  MsgXmlReader* xmlReader = new MsgXmlReader();
>  MsgConfigProcessorSimple processorSimple( config );
>  processorSimple.init( file, path );
>  xmlReader->addProcessor( &processorSimple );
>  xmlReader->process( file );
>  delete xmlReader;
> }
> The process method of XML Reader
> //=============================================================================
> // process
> //=============================================================================
> void MsgXmlReader::process( string file ) throw (MsgException)
> {
>   SAX2XMLReader* parser = NULL;
>   try
>   {
>     XMLPlatformUtils::Initialize();
>     parser = XMLReaderFactory::createXMLReader();
>     parser->setContentHandler( this );
>     parser->setErrorHandler( this );
>   
>     parser->parse( file.c_str() );
>     delete parser;
>     parser = NULL;
>     
>     XMLPlatformUtils::Terminate();
>   }
>   catch( const XMLException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
>   catch( const SAXException& ex )
>   {
>     if( parser )
>     {
>       delete parser;
>     }
>     THROW( "Failed to parse " << file << ": " << StrX(ex.getMessage()) );
>   }
> }
> I have added a feture to parse any files include by using a include tag
>  <include file="xyz.xml/>
> When I try to parse the included file the application hangs. 
>  MsgXmlReader* xmlReader = new MsgXmlReader();
> The above line could not create a new MsgXmlReader. 
> Do you know the reason. I tried the samples to do recursive evaluation and it works. If you have seen such problem please let me know

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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