This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dynamic DOCTYPE inclusion applying XSLT on doc hierarchy


Yves Forkl wrote:
> I have a set of XML files organized in a book-chapter-section document
> hierarchy. Each file is processed individually (but may include
> another one of these files) using the same XSLT stylesheet to produce a
> separate output file for each input file, running Xalan-J.
> 
> Consequently, I need to dynamically include the top-level file's
> DOCTYPE declaration when processing each input file, as I'm defining
> the entities required for file inclusion in the internal DTD subset.
> (Besides that, my stylesheet seems to make Xalan-J require a DOCTYPE
> declaration.)

DOCTYPE declarations are not in the XPath/XSLT tree model
(see the XPath spec). They are information for the XML parser
only. The application doesn't need to know about them, so
you don't have access to them.

> I tried using the document() function inside the template that is
> reading the input file's document element node, in order to include an
> extra input file that only contained that DOCTYPE declaration and
> entity definitions:
> 
> <xsl:apply-templates
> select="document('toplevel-file-doctype_and_entities.xml')"/>
> 
> The problem, however, is that this makes XSLT processing start again
> with the XSLT document root node ("/"), leading to an infinite loop.

That shouldn't have happened. Processing should have aborted because
the XML was not well-formed. (You can't declare a DOCTYPE and then 
not have a document element). Apparently when this error was encountered,
your XSLT processor kept on going as if you had done document(''), which
means to use the stylesheet as the argument.

> Is there a way to read a DOCTYPE declaration from an extra input file
> without moving back to the top of the source tree?

There's no way to read a DOCTYPE from within XSLT.


   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]