You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by maxmus <ar...@web.de> on 2008/05/21 15:45:17 UTC

output xml structure with xsl?

Hallo,
I am looking for a way to translate an xml-file 1:1 to pdf,
i.e. 
the xml-file
"<?xml version="1.0" encoding="UTF-8"?>
<f>
 <x c="d">e</x>
</f>"
should have exactly the same pdf output:
"<?xml version="1.0" encoding="UTF-8"?>
<f>
 <x c="d">e</x>
</f>".
In other words, I want to look at my input file.
But the only thing I can manipulate is the XSL file,
as the FOP runs on a server.
In addition, I don't know the exact structure of the XML-file.

is it possibly to write an xsl that has that output?

regards,
maxmus





-- 
View this message in context: http://www.nabble.com/output-xml-structure-with-xsl--tp17364239p17364239.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: output xml structure with xsl?

Posted by "J.Pietschmann" <j3...@yahoo.de>.
maxmus wrote:
> I am looking for a way to translate an xml-file 1:1 to pdf,

In general, there is no way to do this with XSLT, because
the XSLT processor doesn't get all the lexical structure.
For example, the XSLT processor doesn't know about the
sequence of XML attributes, or the number of whitespaces
between attributes, or whether a particular attribute
was delimited by single or double quotes.
If you can live with a kind of canonicalized rendering of
the XML, you can write yourself a text renderer in XSLT,
roughly like

<xsl:template match="*">
   <xsl:text>&lt;</xsl:text>
   <xsl:value-of select="name()">
   <xsl:if test="@*">
     <xsl:text> </xsl:text>
     <xsl:apply-templates select="@*"/>
   </xsl:if>
   <xsl:text>&gt;</xsl:text>
   <xsl:apply-templates/>
   <xsl:text>&lt;/</xsl:text>
   <xsl:value-of select="name()">
   <xsl:text>&gt;</xsl:text>
</xsl:template>

(complete it with templates for attributes, text, processing
instructions and XML comments)

If you can use other tools to manipulate the XML file, use
a stream edit to wrap your XML in a CDATA construct (a proper
implementation would also escape any "]]>" string in your XML,
but doing this properly becomes somewhat messy).

J.Pietschmann

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