XSLT Macro
Helps to transform XML document with XSLT style sheet |
Type | XAR |
Category | |
Developed by | Arnaud |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
XSLT Macro helps to transform XML document with XSLT style sheet.
Macro is able to retrieve XML document or style sheet from attachment or URL
XML document or else style sheet could be the content of the macro.
Parameter | Description | Possible values | Default value |
---|---|---|---|
xsl | XSLT style sheet to apply to XML | http:somewhere/style.xsl | none |
xml | XML document to process | http:somewhere/document.xml | none |
params | Comma separated list of parameters name, value pair | name1=value1[,name2=value2[,...]] | none |
Samples
xml and xsl parameters
xsl parameter and content as xml document
<persons>
<person username="JS1">
<name>John</name>
<family_name>Smith</family_name>
</person>
<person username="ND1">
<name>Nancy</name>
<family_name>Davolio</family_name>
</person>
</persons>
{{/xslt}}
xml parameter and content as xsl style sheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>
|=Family name|=Name
</xsl:text>
<xsl:apply-templates select="//person">
<xsl:sort select="family_name" />
</xsl:apply-templates>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="person">
<xsl:text>|</xsl:text>
<xsl:value-of select="family_name"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>{{/xslt}}
xml parameter, content as xsl style sheet and params parameter
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:param name="user"/>
<xsl:template match="/">
<xsl:text>
|=Family name|=Name
</xsl:text>
<xsl:apply-templates select="//person[@username=$user]">
<xsl:sort select="family_name" />
</xsl:apply-templates>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="person">
<xsl:text>|</xsl:text>
<xsl:value-of select="family_name"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>{{/xslt}}
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:
- Log in the wiki with a user having Administration rights
- Go to the Administration page and select the Import category
- Follow the on-screen instructions to upload the downloaded XAR
- Click on the uploaded XAR and follow the instructions
- You'll also need to install all dependent Extensions that are not already installed in your wiki
Import the XAR and visit page Macros.xslt
Release Notes
v1.1
Add params macro's parameter to give <xsl:params/> to the style-sheet
v1.0
Initial version