Xerces External Entity reference problem

Discussion in 'XML' started by punjabinezzie@gmail.com, Aug 2, 2006.

  1. Guest

    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/XMLResourceIdentifier.hpp>
    #include <xercesc/util/XMLEntityResolver.hpp>
    #include <xercesc/framework/LocalFileInputSource.hpp>

    Static const XMLCh module[] = {
    chLatin_t,chLatin_e,chLatin_s,chLatin_t,chDigit_2,chPeriod,chLatin_x,chLatin_m,chLatin_l};

    class My_Resolver:public xercesc_2_7::XMLEntityResolver
    {
    public:
    InputSource * resolveEntity (XMLResourceIdentifier* xmlri)
    {
    xmlri->getSystemId();

    return new LocalFileInputSource(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.
     
    , Aug 2, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. peter greaves
    Replies:
    0
    Views:
    2,388
    peter greaves
    Jun 25, 2003
  2. cvissy
    Replies:
    0
    Views:
    838
    cvissy
    Nov 16, 2004
  3. __PPS__
    Replies:
    2
    Views:
    635
    __PPS__
    Sep 27, 2005
  4. David Dorward
    Replies:
    2
    Views:
    900
    Uche Ogbuji
    Feb 28, 2004
  5. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    2,479
    Jukka K. Korpela
    Feb 24, 2007
  6. markla
    Replies:
    1
    Views:
    805
    Steven Cheng
    Oct 6, 2008
  7. ThatsIT.net.au

    Entity, problem with entity key

    ThatsIT.net.au, Sep 6, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    1,514
    ThatsIT.net.au
    Sep 7, 2009
  8. Replies:
    1
    Views:
    314
    Öö Tiib
    May 30, 2014
Loading...