[xep-support] Re: How to include the xml source in the target pdf?

Kevin Brown kevin at renderx.com
Mon Feb 25 09:37:40 PST 2013


Friedrich:

Well, you cannot store XML inside (as XML) as that would not be valid. See
attached XSL which takes as input the XML and returns a string. We use this
inside of our forms processing software where we store the XML in hidden
form fields in the same way you are doing here.

So in your XSL at the top ...

<xsl:import href="xml-to-string.xsl"/>

And somewhere in your XSL:

    <xsl:template name="load-xml">
        <xsl:variable name="xmltext">
            <xsl:call-template name="xml-to-string">
                <xsl:with-param name="node-set" select="/"/>
            </xsl:call-template>
        </xsl:variable>
	<xsl:value-of select="$xmltext"/>
    </xsl:template>

Then just:

<rx:pdf-comment title="My XML">
   <xsl:attribute name="content">
     <xsl:call-template name="load-xml"/>
   </xsl:attribute>
</rx:pdf-comment>

One note, it is unclear if Adobe has any limits on the length of field.
There IS with form fields so I assume there may be also with comments. You
could:

1) Use JSON instead, there are XSLs that will JSONify XML I believe
2) Split the string into multiple chunks (we do this in the form submittal)
using instead the below, you can modify to insert multiple comments instead
of multiple fields:

<xsl:template name="load-xml">
        <xsl:variable name="xmltext">
            <xsl:call-template name="xml-to-string">
                <xsl:with-param name="node-set" select="/"/>
            </xsl:call-template>
        </xsl:variable>
        <!-- xmltext contains the XML file. Adobe software only allows a
certain number of characters in a field so we need to chop this apart and
place in multiple fields -->
        <xsl:call-template name="span-string-to-hidden">
            <xsl:with-param name="index">1</xsl:with-param>
            <xsl:with-param name="splitlength">10000</xsl:with-param>
            <xsl:with-param name="string" select="$xmltext"/>
        </xsl:call-template>
    </xsl:template>

<xsl:template name="span-string-to-hidden">
        <xsl:param name="string"/>
        <xsl:param name="index"/>
        <xsl:param name="splitlength"/>
        <xsl:choose>
            <xsl:when test="number(string-length($string)) > 0">
                <xsl:call-template name="create-span-hidden-field">
                    <xsl:with-param name="text" select="substring($string,
$index, $splitlength)"/>
                    <xsl:with-param name="index" select="$index"/>
                    <xsl:with-param
name="name-prefix">span-</xsl:with-param>
                    <xsl:with-param name="name">currentXML</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="span-string-to-hidden">
                    <xsl:with-param name="string"
                        select="substring($string, $splitlength,
number(string-length($string)))"/>
                    <xsl:with-param name="index" select="$index + 1"/>
                    <xsl:with-param name="splitlength"
select="$splitlength"/>
                </xsl:call-template>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="create-span-hidden-field">
        <xsl:param name="text"/>
        <xsl:param name="index"/>
        <xsl:param name="name-prefix" />
        <xsl:param name="name"/>
        <xsl:param name="seperator">
            <xsl:text>_</xsl:text>
        </xsl:param>
        <fo:block-container>
            <rx:pdf-form-field hidden="true">
                <xsl:attribute name="name">
                    <xsl:value-of select="concat($name-prefix, $name,
$seperator, $index)"/>
                </xsl:attribute>
                <rx:pdf-form-field-text>
                    <xsl:attribute name="text">
                        <xsl:value-of select="$text"/>
                    </xsl:attribute>
                </rx:pdf-form-field-text>
            </rx:pdf-form-field>
        </fo:block-container>
    </xsl:template>

Kevin Brown
RenderX


-----Original Message-----
From: xep-support-bounces at renderx.com
[mailto:xep-support-bounces at renderx.com] On Behalf Of Kirch Fritz
Sent: Monday, February 25, 2013 7:08 AM
To: support at renderx.com; RenderX Community Support List
Subject: [xep-support] How to include the xml source in the target pdf?

Hello,

I want to include my xml source in the target pdf by using a
<rx:pdf-comment> in my XSLT.

<rx:pdf-comment title="My XML">
   <xsl:attribute name="content">
     ???????     <----- What code ??????
   </xsl:attribute>
</rx:pdf-comment>

Can anybody help me with this XSLT code snippet?

Kind regards

Friedrich Kirch
IT2media GmbH & Co. KG

**********************************************************************
Diese E-Mail wurde auf Viren ueberprueft.
mailsweeper at it2media.de
**********************************************************************

!DSPAM:87,512b7e649851523820406!


_______________________________________________
(*) To unsubscribe, please visit
http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service
http://w ww.renderx.com/terms-of-service.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xml-to-string.xsl
Type: text/xml
Size: 12943 bytes
Desc: not available
URL: <http://lists.renderx.com/pipermail/xep-support/attachments/20130225/0c1f353b/attachment.xml>


More information about the Xep-support mailing list