« Return to Thread: Include a complete file in FOP

Re: Include a complete file in FOP

by J.Pietschmann :: Rate this Message:

Reply to Author | View in Thread

jantje wrote:
> So, in PDF I want to show the complete content from file.xml, so also the
> elements and attributes.

I suppose you want to have the content of file.xml rendered as
kind of "XML source code". Well....

 > But this does not seem to work.

The standard answer to this phrase is: What do you mean by
"does not work"? Did you get an error message, and if so,
what did it say?
In your specific case, there are multiple probles in your XSLT:

>    <xsl:template match="includeXmlFile">
>      <xsl:variable name="source">
>        <xsl:value-of select="string('../../../')"/>
>        <xsl:value-of select="path"/>
>        <xsl:value-of select="file"/>
>      </xsl:variable>
It is better to write this as
  <xsl:variable name="source" select="concat('../../../',path,file)" />

>      <xsl:for-each select="document($source)">
The document() function returns a single node, the root node
of the document, therefore the for-each doesn't do much (except
context switching).

>          <xsl:copy>
This copies the document root node, which isn't very useful.

> <xsl:apply-templates select="node()|@*"/>
This starts traversal of the XML tree read from file. I guess
you just got the text from the file in the PDF, without the
tags, which is the result of recursively applying the default
template.

If you want to get the file content as "XML source", you have to
render it yourself as text. If you use an XSLT 1.0 processor, you
can search the XSLT FAQ or the XSL list archives for code doing
this (there were multiple publications in the past). This wont
give you an exact copy of the sourec XML, because some information
is lost during XML parsing. If you can preprocess the XML file using
another tool, you can enclose the content in a CDATA section. An
XSLT 2.0 processor has the capability to read text files unparsed,
which is another possibility.

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...

 « Return to Thread: Include a complete file in FOP

LightInTheBox - Buy quality products at wholesale price!