Created
May 30, 2011 20:23
-
-
Save chids/999412 to your computer and use it in GitHub Desktop.
Confluence Macro - Render XML response from HTTP service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set($path=$param0.replace("::", "=")) | |
#set($space=$renderContext.getOriginalContext().getSpaceKey()) | |
#if($space.equals("PRIVATE")) | |
#set($domain="http://your.internal.url") | |
#else | |
#set($domain="http://your.public.url") | |
#end | |
#set($url="${domain}${path}") | |
[$url] | |
#set($helper=$action.getHelper()) | |
#set($xml=$helper.renderConfluenceMacro("{xslt:source=#$url|output=wiki|style=path.to.xslt.here}{xslt}")) | |
#set($xml=$xml.replace("<p>", "")) | |
#set($xml=$xml.replace("</p>", "")) | |
#set($xml=$xml.replace("<br/>", "")) | |
#set($xml=$xml.replace("<", "<")) | |
#set($xml=$xml.replace(">", ">")) | |
{code:xml} | |
$xml | |
{code} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{render-xml:/some/service/endpoint?a-query-param::and-its-value} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- (c) John Mongan, copied from: http://www.dpawson.co.uk/xsl/sect2/pretty.html --> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="xml"/> | |
<xsl:param name="indent-increment" select="' '" /> | |
<xsl:template match="*"> | |
<xsl:param name="indent" select="'
'"/> | |
<xsl:value-of select="$indent"/> | |
<xsl:copy> | |
<xsl:copy-of select="@*" /> | |
<xsl:apply-templates> | |
<xsl:with-param name="indent" select="concat($indent, $indent-increment)"/> | |
</xsl:apply-templates> | |
<xsl:if test="*"> | |
<xsl:value-of select="$indent"/> | |
</xsl:if> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="comment()|processing-instruction()"> | |
<xsl:copy /> | |
</xsl:template> | |
<!-- WARNING: this is dangerous. Handle with care --> | |
<xsl:template match="text()[normalize-space(.)='']"/> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment