Xerces External Entity reference problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • punjabinezzie@gmail.com

    #1

    Xerces External Entity reference problem

    I am developing an Application which currently has two XML files. One
    XML file with some nodes and an external entity reference to another
    XML file. The source XML file is being parsed using Xerces (DOM
    Parser), upon reaching an external entity reference node the external
    file being referenced does not get parsed. Instead an empty node or the
    current node name is substituted in place and the remaining nodes
    parsed from original source file are seen in the output text file.

    Source XML File: test.xml
    <?xml version="1.0"?>
    <!DOCTYPE doc [
    <!ENTITY copyright SYSTEM "test2.xml" >
    ]>
    <doc>
    <abc>xyz</abc>
    <cop>&copyright ;</cop>
    <neha>morning </neha>
    </doc>

    External File: test2.xml
    <copied>omg</copied>

    Output:
    <doc>
    <abc>xyz</abc>
    <cop>cop</cop>
    <neha>morning </neha>
    </doc>

    Expected Output:
    <doc>
    <abc>xyz</abc>
    <cop>
    <copied>omg</copied>
    </cop>
    <neha>morning </neha>
    </doc>

    Questions:

    An entity resolver was installed but resulted in similar output as
    defined above.

    User defined Entity Resolver (follows the Redirect sample from Xerces
    documentation)

    #include <xercesc/util/XercesDefs.hpp>
    #include <xercesc/util/XMLResourceIden tifier.hpp>
    #include <xercesc/util/XMLEntityResolv er.hpp>
    #include <xercesc/framework/LocalFileInputS ource.hpp>

    Static const XMLCh module[] = {
    chLatin_t,chLat in_e,chLatin_s, chLatin_t,chDig it_2,chPeriod,c hLatin_x,chLati n_m,chLatin_l};

    class My_Resolver:pub lic xercesc_2_7::XM LEntityResolver
    {
    public:
    InputSource * resolveEntity (XMLResourceIde ntifier* xmlri)
    {
    xmlri->getSystemId( );

    return new LocalFileInputS ource(module);

    }

    };

    I have searched the API documentation and looked at the mail archive
    but not found anything. Any help toward solving this problem would be
    appreciated.
    Thanks,
    Neha.

Working...