471,073 Members | 1,167 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

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/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 '06 #1
0 1205

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Douglas Reith | last post: by
3 posts views Thread by indo3 | last post: by
4 posts views Thread by SL | last post: by
2 posts views Thread by __PPS__ | last post: by
4 posts views Thread by Sanjay Kumar | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.