|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Include a complete file in FOPHi there, I use Apache Fop to generate PDF from the file text.xml
In this file there is text, but also this element: <includeXmlFile> <path>source/xml/</path> <file>file.xml</file> </includeXmlFile> So, in PDF I want to show the complete content from file.xml, so also the elements and attributes. I use this, in xsl, to generate a .fo -file: <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> <xsl:for-each select="document($source)"> <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy> </xsl:for-each> </xsl:template> But this does not seem to work. ($source is ok, so only the copy part does not work) Anyone an idea? Thanks.. |
|
|
Re: Include a complete file in FOPjantje 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@... |
|
|
Re: Include a complete file in FOP
|
| Free Forum Powered by Nabble | Forum Help |