Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

saveXML does not apply XSL transform

Avatar

Level 7

I have an XSL that I want to use to populate a 2d barcode. I've set the data connection like so:

681817_pastedImage_0.png

However, when I call


  this.rawValue = xfa.record.saveXML();


it does not apply the XSL transform. What do I need to do to force the transform? If I do a Export Data operation from Acrobat, the resulting XML file is transformed, so I know my transform works.

1 Accepted Solution

Avatar

Correct answer by
Level 7

OK. I think I have a solution. The stylesheet nodes are of packet className, so by using the code below:


var oStyleSheets = xfa.resolveNodes("stylesheet[*]")


for (var i = 0; i < oStyleSheets.length; i++) {


    if (oStyleSheets.item(i).getAttribute("id") == "XFADataInputXSL")


        console.println("got input XSL");


    else if (oStyleSheets.item(i).getAttribute("id") == "XFADataOutputXSL")


        console.println("got output XSL");


}


I can then pull out the right stylesheet for the job.

View solution in original post

2 Replies

Avatar

Level 7

Well I'm a bit closer. I can do the transform now, as I've found that the stylesheets are located at xfa.stylesheet. Then I can do something like this:


  this.rawValue = xfa.record.applyXSL(xfa.stylesheet.saveXML());


However, what if I have an outgoing and incoming transform stylesheet? How can I differentiate them? It looks like the incoming stylesheet has an  id="XFADataInputXSL" and the outgoing an id="XFADataOutputXSL".

But I can't write a script that will pick the right one!


var outgoingXSL = xfa.resolveNode("stylesheet.[id == \"XFADataOutputXSL\"]");


I'm not sure why this isn't working.

Avatar

Correct answer by
Level 7

OK. I think I have a solution. The stylesheet nodes are of packet className, so by using the code below:


var oStyleSheets = xfa.resolveNodes("stylesheet[*]")


for (var i = 0; i < oStyleSheets.length; i++) {


    if (oStyleSheets.item(i).getAttribute("id") == "XFADataInputXSL")


        console.println("got input XSL");


    else if (oStyleSheets.item(i).getAttribute("id") == "XFADataOutputXSL")


        console.println("got output XSL");


}


I can then pull out the right stylesheet for the job.