It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Instantiate XSLT class in user macro?

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
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

327 views 9 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you