XML documents can have macros (called entities), which are defined in the DTD and their occurrences are expanded according to the definition. XML specification allows entities to refer to an external document. When this happens, the libwww package must issue a subrequest to fetch the document containing the macro expansion. Such a subrequest can fail for a variety of reasons (usually network related). Status code of each subrequest is recorded in the third argument of the corresponding request term (that is passed to libwww_request/1), as shown in an earlier example. If the status indicates an error, the corresponding place in the request result (the fourth argument) will contain a term of the form unexpanded_entity(Url,Status). For instance:
?- libwww_request([xml('http://localhost/simple.xml', [if_modified_since('Tue, 21 Sep 1999 14:46:36 GMT')], P,R,S)]). P = [subrequest(http://localhost/001.ent,-404), subrequest(http://localhost/sub/001.ent,200), header(Content-Type,text/xml),header(Content-Length,505), header(Accept-Ranges,bytes),header(ETag,"5089-1f9-38f012dc), header(Last-Modified,Sun, 09 Apr 2000 05:19:24 GMT), header(Server,Apache/1.3.9 (Unix) (Red Hat/Linux)), header(Date,Tue, 11 Apr 2000 05:01:55 GMT)] R = [elt(doc,[],[elt(foo,[attval(att1,123),attval(att2,abc)], [elt(pcdata,[],test), unexpanded_entity(http://localhost/001.ent,-404), elt(pcdata,[], Test1 ), elt(pcdata,[], Test2 )]), elt(pcdata,[], )])] S = 200
Another observation is that due to a bug in the Libwww library, requests to fetch local files (documents with URLs of the form file://abc) may take a long time or even abort, if the request requires spawning subrequests to fetch other local files (for instance, a request to parse a local XML document that contains external references to local files). However, this is not a serious problem in practice, since the Web interface is rarely used to access local files.