Re: [xslt] double parse xincludes?



On Wed, Jan 16, 2002 at 09:37:59AM -0800, Bob Stayton wrote:
> It is nice that xsltproc handles XIncludes.
> But I understand the inclusion takes place *after*
> the including document has been validated, no?

   Hum, no ... First libxslt doesn't do validation,
it parses the files activating the loading of DTD and defaulting
of attributes but doesn't validate.

> That means the included content is not validated.
> How hard would it be to add an option to xsltproc
> to reparse after the inclusions?  

  XInclude is defined in terms of Infoset manipulations,
i.e. after parsing the contents are merged accordingly
to the spec. So the result really is a non-serialized form.

> This would be useful where XInclude is used to break up
> large XML documents into modular components, as say,
> chapter files for a book.  That can be done with system
> entities, but a system entity is not a valid document on
> its own since it cannot have a <DOCTYPE> declaration.  An
> XInclude'd document can have a <DOCTYPE> and be validated
> as a module.  But I would also like to validate the
> including document (the book) when it is processed.

  Unless you have troubles with the defaulting of attributes
(but I don't think this should happen) the XSLT processing
should work fine with XInclude even if there isn't a validation
phase.
  If you really want to validate something with libxml2/libxslt
you should use xmllint. More precisely 
   xmllint --valid --noout document.xml

will run the parser in validating mode.
If you want to to validate the result of an XInclude processing
you need to ask it to validate on the parsed form

   xmllint --postvalid --xinclude --noout document.xml

I checked the postvalidation should occurs after the XInclude
processing and provide you with the expected errors if the 
result ain't kosher per the DOCTYPE of document.xml.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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