Hi Francesco,
This is just to confirm you that replacing external entities on the
fly works. The following code is the modification to add to your
sample code:
else if (node.GetType() == wxXML_ENTITY_DECL)
{
wxXml2EntityDecl* pNode = (wxXml2EntityDecl*)&node;
toadd += wxString::Format(_T(", NodeType=%d, Name='%s',
SystemID='%s'\n"),
node.GetType(), pNode->GetSystemID() );
// insert here the referenced xml tree
// load the referebced XML file as tree of nodes
wxXml2Document oDoc;
wxString sError;
wxFileName oFN(m_sMainFilename);
oFN.SetFullName(pNode->GetSystemID());
wxString sFilename = oFN.GetFullPath();
if (!oDoc.Load(sFilename, &sError)) {
wxLogMessage(_T("Error parsing file %s\nError:%s"),
sFilename, sError);
return; // or continue?
}
//Process it recursively
wxXml2Node oRoot = oDoc.GetRoot();
wxString sChildTree;
ParseNodeAndSiblings(oRoot, sChildTree, n);
toadd += sChildTree;
}
Two important issues:
1. You will see global variable m_sMainFilename. This is needed
because the external entity URL could be relative to main file. So we
need to know the main file URL. A second issue is that in this sample
code I am assuming that the external entity URL is just
"filename.ext", so that it will be located at the same folder than
main XML file. This is a non-valid assuption and so, more code must be
inserted to compose the rigth URL.
- I did not tested this code in the sample, but in my app, so maybe
there is some bug in last line (toadd += sChildTree).
Thank you again for your help,
Regards,
Cecilio.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
wxCode-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxcode-users