Hi Cecilio, sorry again for the delay... cecilio ha scritto: > This is just to confirm you that replacing external entities on the > fly works. very good!
> 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; > } great - nice addition to the sample; could you submit it as a patch? It's much easier to apply in that form (just do a "cvs diff -bu2 >sample.patch" in wxXml2\sample). > > 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. aren't these two issues the same ? I'd simply write: wxFileName oFN(pNode->GetSystemID()); if (oFN.IsRelative()) oFN.MakeAbsolute(wxPathOnly(m_sMainFilename)); > - I did not tested this code in the sample, but in my app, so maybe > there is some bug in last line (toadd += sChildTree). I'll look at it.... Thanks, Francesco ------------------------------------------------------------------------- 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 wxCode-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxcode-users