Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Instantiate XSLT class in user macro?

Robin Buck August 9, 2019

I'd like to do a XSLT transformation inside a user macro. (i know, there is a plugin, but i dont want to use this)

 

I tried the following:

#set($XslTransClass = $content.class.forName('com.atlassian.confluence.xml.XslTransformer'))
#set($XalanXslTransformer = $XslTransClass.transform($xsl, $xml, $out))

i tried as well this:

#set($XslTransClass = $content.class.forName('com.atlassian.confluence.xml.XslTransformer'))
#set($getInstanceMethod = $XslTransClass.getDeclaredMethod('getInstance',null))
#set($XslTrans = $getInstanceMethod.invoke(null,null))

What am i doing wrong?

How, can i instantiate the class?

 

Here the full macro:

## WSDL Transformation into HTML
## @param WSDLFile:title=WSDL File|type=attachment|required=false
## @param XSLFile:title=XSL File|type=attachment|required=false
################################################################################################

#set($AttachmentWField = "WSDLFile") ## for paramTheAttachment
#set($AttachmentWFieldValue = "$!{paramWSDLFile}") ## for paramTheAttachment value
#set($AttachmentXField = "XSLFile") ## for paramTheAttachment
#set($AttachmentXFieldValue = "$!{paramXSLFile}") ## for paramTheAttachment value

#set($optionsW = [""])
#set($optionsX = [""])

#foreach($Attachment in $attachmentManager.getLatestVersionsOfAttachments($content) )
#set($AttachmentName = $Attachment.getFileName() )
#if($AttachmentName.matches('(.*.WSDL\z)|(.*.wsdl\z)'))
#set($dummy = $optionsW.add($AttachmentName) ) ## for all attachemnts; use this
#elseif($AttachmentName.matches('(.*.XSL\z)|(.*.xsl\z)')) ## if only images are needed; use this
#set($dummy = $optionsX.add($AttachmentName) ) ## for all attachemnts; use this
#end ## if only images are needed; use this
#end

#if ($req.getRequestURI().contains("tinymce")) ## displayed only in user macro edit mode
<script>
var theMacroFeldW = window.parent.document.getElementById("macro-param-${AttachmentWField}");
theMacroFeldW.innerHTML = '';
#foreach($woption in $optionsW)
nodew = document.createElement("option");
nodew.text = "${woption}";
nodew.value = "${woption}";
theMacroFeldW.appendChild(nodew);
#end

theMacroFeldW.value = "$!{AttachmentWFieldValue}";


var theMacroFeldX = window.parent.document.getElementById("macro-param-${AttachmentXField}");
theMacroFeldX.innerHTML = '';
#foreach($xoption in $optionsX)
nodex = document.createElement("option");
nodex.text = "${xoption}";
nodex.value = "${xoption}";
theMacroFeldX.appendChild(nodex);
#end

theMacroFeldX.value = "$!{AttachmentXFieldValue}";

</script>
#end

#set($xml = $attachmentManager.getAttachmentData($attachmentManager.getAttachment($content, $!{AttachmentWFieldValue} )))
#set($xsl = $attachmentManager.getAttachmentData($attachmentManager.getAttachment($content, $!{AttachmentXFieldValue} )))

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events