Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How to embed XSLT

Avatar

Level 4

I have a data connection with an XML file. Before using it in the pdf I have to convert it first with an xslt.

Problem is:

I would like to embed the XSLT in the pdf and distribute it all as one pdf file. How do I do that?

Besides: Testing would be easier, if the XSLT could be specified with a relative path - I only managed to do it with a full path :-(

3 Replies

Avatar

Level 10

Hi,

Maybe the easiest, though a bit laborious is just as a JavaScript string;

var xslt = '<?xml version="1.0" encoding="UTF-8"?>' +

' <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">'

+

' <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>'

.

.

.

Or maybe as an attachment and use the getDataObjectContents method to read the contents.

Bruce

Avatar

Level 4

Hi Bruce,

I am afraid that doen't help at all (or I miss the idea of your reply).

Try this: Add a data connection to a form.

Now right click on the data connection and choose "Connection Properties". There you can click on "Transform Incoming Data" and pick an XSLT file.

I am talking about this XSLT file.

I don't see how access to some XSLT in a variable or attachment could help me. It is the Adobe Reader that populates the fields connected to my XML file. Therefore the Adobe Reader has to access the XSLT file and perform the transformations.

The strange thing is that I can embed my XML schema. Why is it that I cannot embed the XSLT files? The reason for embedding the XSD is that we want to distribute only one PDF and nothing else.

I do wonder how  this "transformation of incoming data" can be used in real life at all!

Ulrich

Avatar

Level 10

Hi Ulrich,

I can see now how my suggestion doesn't help, I have not used the xslt transformation of incoming data this way and looking at it now don't see a way of embedding it, which seems strange as the breaks the portable part of PDF.

There is a applyXSL method on the node object, which is what I've used in the past ... with an xslt stored in a JavaScript variable, and maybe you could also if your non transformed data is XML you could load it as normal and apply the xslt once it is in the data dom, then you would have to somehow load the true xml.  Sounds a bit messy but could be done.

Good luck

Bruce