[Expat-discuss] Handling include statements in XML files

Nick MacDonald nickmacd at gmail.com
Thu Apr 19 21:12:25 CEST 2007


Jeffrey:

I think you need to supply some sample XML here to make it clear what
you're trying to do.  If I understand you properly, you have some sort
of embedded XML tag that you want to process to get another XML file
that should be considered part of the original file?

Like so?

<MyXML>
  <include file="someXMLfileToInclude.xml" />
</MyXML>

If this is the case, then you really want to just create a new parser
to start parsing the included file right at the point that you get the
call back for the <include> end tag.  You would then read that file
for the duration of the file, and then when it concludes successfully,
you would return to parsing the original file.  The only downside of
this approach, is that the included XML file would need to be valid,
it couldn't be a partial file.  If you needed to handle partial files,
you'd probably need to generate an interim file which would include
the content from all the files included, and then you would process
that interim file and then presumably delete it as part of the clean
up.

Thus, in that case, you would have two steps:
  1. copy the input file to a new file
      while include statements found in new file
        parse the new file for includes
        when include statement is found merge the two files into one new file
      end
  2. parse the final new file

Good luck with your project...
  Nick

On 4/19/07, Jeffrey Holle <jeffreyholle at bellsouth.net> wrote:
> The XML files which I am attempting to parse with expat 2.0.0 have
> include statements which I presently can handle.
>
> I've attempted to create a new parser via the
> XML_ExternalEntityParserCreate function, but I am not sure what the
> "context" parameter needs to be.  What should it be?
>
> The include XML file is of the same type as the original, so I want all
> exiting handlers to work with the included file.
>
> _______________________________________________
> Expat-discuss mailing list
> Expat-discuss at libexpat.org
> http://mail.libexpat.org/mailman/listinfo/expat-discuss
>


-- 
Nick MacDonald
NickMacD at gmail.com


More information about the Expat-discuss mailing list