Re: [xml] Xinclude w/DTD segs

On Tue, Jun 19, 2001 at 11:19:26AM -0400, Bruce Miller wrote:
Daniel Veillard wrote:
As far as xmllint is concerned,
  xmllint --xinclude --postvalid --noout file.xml
seems to do what I want: parse, do inclusions, and _then_ validate.
But, perhaps, this approach isn't really, um, ... valid :>

  Of course in practice people want to validate after parsing, so
I have added APIs to validate an already parsed document or validate
a document against a given DTD. I think all toolkits offers this but
this is not the canonical way of doing things.

[Apologies if this is getting too far from libxml specifically,
I'll _try_ to be brief... ]

I'm still having some problems here.  Maybe I was hoping for a
"magic bullet" and am creating a "catch 22" (mixed usa-centric 
metaphors?) and I'm having a hard time finding information about 
how to use Xinclude.

  Well I think the best is to read the (short) introduction of
the XInclude spec:

Both entities & xinclude seem to be useful for different purposes,
eg entities provided by the DTD are like a database; xinclude
allows explicit composition of a document.
There's a trivial example of what I think I want at the bottom.

For a document using _both_

xmllint --xinclude --valid --noent test.xml
  complains about the xinclude tags not being defined in the 
  dtd, which is true.

  Right in this case the validation happens first and this breaks
because of the xinclude elements

xmllint --xinclude --postvalidate --noent test.xml
  complains about the entities not being defined (during 
  xinclude expansion?)

  Well actually the complaint come from somewhere else. By default
libxml parser won't fetch the external DTD. So when you parse test.xml
without any other flags you will get that warning:

orchis:~/XML -> ./xmllint --noout test.xml
test.xml:5: warning: Entity 'default.thing' not defined
orchis:~/XML ->

  You get the same message in this case

orchis:~/XML -> /usr/bin/xmllint --xinclude --postvalid --noent test.xml
test.xml:5: warning: Entity 'default.thing' not defined
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE things SYSTEM "test.dtd">
<thing>An Explicit Thing</thing>

<thing>An x-included thing</thing>
orchis:~/XML -> 

   because in this case test.xml is first loaded without doing
validation you see this message. however the output it sorrect
(you added --noent so the entity content got substitued too).

   I have added an extra flag --loaddtd to force loading external DTD

  and activated it by default when --postvalid is used:

orchis:~/XML -> xmllint --xinclude --postvalid --noent test.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE things SYSTEM "test.dtd">
<thing>An Explicit Thing</thing>
<thing>Default Thing</thing>
<thing>An x-included thing</thing>
orchis:~/XML ->

I suppose I'd want to process the dtd to get access to the
entities, but not validate till later.
Is this possible with xmllint?  Have I not tried the right 
combination of options?

  Well rather that all options of the parser were not available
on the command line interface.

Or, must I explicitly declare xinclude in the dtd (and all the
places I'll allow <xi:xinclude> to appear?

  Well depends what you want. If you want to validate the input document
then yes, you should. If you want to validate the result, then no.

  Admitted, it becomes rather complex when one start to stack multiple
layers of optional processing. This is an actual open issue within
W3C itself :-)


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine
Sep 17-18 2001 Brussels Red Hat TechWorld

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]