The Nightmare
The Nightmare

Reputation: 701

Xslt variable in apache fop embedded file declarations

I have a embedded file in my xsl file, example like this:

<xsl:template match="$pathPrefix/tns:AdditionalInfoStruct/tns:AdditionalInfo/dtsf:File">      
      <pdf:embedded-file filename="file.txt" src="data:text/html;base64,c2tsZGFsa2RhbnNrbHhuYXNrbGRrbGFzZGp3amRvcGFzZGpsc2RrYXNjbXNrbGNtYXNrbGQ7YXNz"/>
</xsl:template>

Above example works fine but when i want get filename and content in base64 from my xslt node didn't work. Not working example:

<xsl:template match="$pathPrefix/tns:AdditionalInfoStruct/tns:AdditionalInfo/dtsf:File">      
<xsl:variable name="name" select="current()/dtsf:Name"/>
<xsl:variable name="content" select="current()/dtsf:Content"/>
      <pdf:embedded-file filename="$name" src="data:text/html;base64,$content"/>
</xsl:template>

Why I can't use variables in filename and src param in pdf:embedded tag? Mayby I can add attachment programatically to my pdf in java? Anybody know how?

Upvotes: 3

Views: 776

Answers (2)

Martin Honnen
Martin Honnen

Reputation: 167716

Use attribute value templates in the form of

<pdf:embedded-file filename="{$name}" src="data:text/html;base64,{$content}"/>

if you want to compute (parts of )an attribute value of a literal result element in XSLT.

Upvotes: 1

Maurice Perry
Maurice Perry

Reputation: 9658

I would try something like so:

<pdf:embedded-file>
    <xsl:attribute name="filename"><xsl:value-of select="$name"/></xsl:attribute>
    <xsl:attribute name="src">data:text/html;base64,<xsl:value-of select="$content"/></xsl:attribute>
</pdf:embedded-file>

Upvotes: 1

Related Questions