Include multiple XHTML pages
Hi,
is it possible to "include" multiple XHTML documents by one "master file" for processing by Prince? And what sample code could be used to provide this? (I tried XInclude and external entities, but was unable to get it right; I don't know enough about this area and it seems that I'm a little bit impatient ...).
Cheers
Christian
I think you can use objects for these purpose.
Or CSS
body {content: url(first.xhtml) url(second.xhtml) url(third.xhtml)}
/* At the moment I am traveling and can't check it with Prince but I think it should work. */
I'm afraid that Prince can only include images with that method, not other XML/XHTML files.
However, Prince does support external entities, which allow you to combine multiple XML files into one, like this:
<!DOCTYPE html [
<!ENTITY chap1 SYSTEM "chapter1.xml">
<!ENTITY chap2 SYSTEM "chapter2.xml">
]>
<html>
<body>
&chap1;
&chap2;
</body>
</html>
Alternatively, you can use XInclude with an external processor such as
xmllint, like this:
<html xmlns:xi="http://www.w3.org/2001/XInclude">
<body>
<xi:include href="chapter1.xml"/>
<xi:include href="chapter2.xml"/>
</body>
</html>
...
$ xmllint --xinclude foo.xml > output.xml
(In the future we might add XInclude support to Prince to remove the need for an external processing step).
Hi Michael,
I've tried the entity-way (and it looks that I've done it just the way you proposed), but trying to include complete XHTML files isn't possible because they choke the parsing process (I'm not shure about the reasons):
prince: loading input: test.html
prince: htdocs/basiselemente/basiselemente_de.html:2: error: StartTag: invalid element name
prince: htdocs/basiselemente/basiselemente_de.html:25: error: Entity 'nbsp' not defined
prince: htdocs/basiselemente/basiselemente_de.html:85: error: Entity 'nbsp' not defined
prince: test.html:8: error: Entity 'basiselemente' not defined
prince: test.html: error: could not load input file
I don't know if it is theoretically possible to include complete XHTML files as entities into other XML or XHMTL files (handling simple XML files is rather straightforward, but including files with their own doctype declarations looks complicating).
Okay, then I have to pre-process the data to merge the pages into one single file ...
Cheers
That is true, XML external entities cannot have their own DOCTYPE declarations, which makes it impossible to include multiple valid XHTML documents.
(I suspect that a simple XSLT transform would do what you need, using the document() function to load up each document and include it in the resulting XML tree).
Oh, I fear it is not as simple as it looks at first sight. From time to time we do some very page specific things (individual stylesheet additions, absolute positioned parts etc.) which have to be handled appropriately ... I have to think about it :?
For the record, Prince 5.0 beta 4 added support for XML Inclusions (XInclude).
(Apologies for the duplicated post).
Given the number of views of this topic, a lot of us seem to have this need...
I have a large help system, hundreds of topics as individual XHTML files. I would like to create a PDF manual based on this content, with page numbers, links between topics, and so on.
This content used to be in FrameMaker but was migrated to XHTML when Adobe dropped Frame for the Mac.
The problem is that I don't have the skill set (yet) or the time before shipping my product this summer to convert my files to XML. It's on my list, but...
Has anybody sucessfully used Prince for this type of situation. Ideally I would like a "master book file" listing the XHTML files in sequence, but apparently that doesn't work. Any suggestions? If we could work out a way to do this, it might help a lot of former Frame users...
Hi Leigh,
Using entities or XInclude as described earlier in this thread is one way to link multiple files together into one file that can be processed into a single PDF file with Prince.
However, this method does have a couple of limitations: styles defined in each sub-document will not be applied correctly, and links between different documents will not work.
Another option would be to write an XSLT transform or simple script to take the multiple documents and stitch them up into one document, which could then be processed with Prince. This method is a bit more involved but offers more control; for example, IDs could be rewritten so that links between different documents would still work.
The
ideal situation would be for Prince to do all the work itself!
![:D](/forum/static/smiley/bigsmileface.png)
We are definitely planning on adding support for multiple documents to a future release of Prince, so expect to see this feature show up in one of the upcoming alpha versions.
Best regards,
Michael