Re: [xslt] double parse xincludes?



On Wed, Jan 16, 2002 at 01:45:13PM -0500, Daniel Veillard wrote:
> 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.

OK, thanks for clarifying that.
 
> > 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.

In general, processing of the included content with
xsltproc works very well.  The one feature that does not
work is ID/IDREF between xincluded content.  Now, I
personally don't think it is a good idea to create
ID/IDREFs between separate XML documents, because then the
individual documents don't validate.  But some people
set up their modular content that way.  The
ID/IDREFs do work when system entities are used instead
of Xincludes to assemble a larger logical document.

BTW, I'm testing all this with the DocBook XSL 1.48
stylesheets, using <link linkend="foo">bar</link>, where
'foo' is an id value on an element in another included
file.  The error message reported from the stylesheet is
"Error: no ID for constraint linkend: foo".

I wonder if the stylesheet used a <xsl:key> defined
for the id attributes instead of the id() function
if it would find its match in the included content when
run in xsltproc.

> 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.

That's nice, the ID/IDREFs between xincludes are validated
when the master file is processed in this manner.
Now if I could just get a --postvalid option on xsltproc.  8^)

-- 

Bob Stayton                                 400 Encinal Street
Publications Architect                      Santa Cruz, CA  95060
Technical Publications                      voice: (831) 427-7796
Caldera International, Inc.                 fax:   (831) 429-1887
                                            email: bobs@caldera.com



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