Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet version="2.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:cs="http://www.censhare.com/xml/3.0.0/xpath-functions"
- xmlns:corpus="http://www.censhare.com/xml/3.0.0/corpus"
- exclude-result-prefixes="cs">
- <!-- Transformation that creates new asset from body XML of REST post method -->
- <!-- output -->
- <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
- <!-- parameters -->
- <xsl:param name="data"/>
- <!-- variables -->
- <xsl:variable name="vfs">
- <cs:command name="com.censhare.api.io.CreateVirtualFileSystem"/>
- </xsl:variable>
- <!-- root match -->
- <xsl:template match="/">
- <result>
- <xsl:choose>
- <!-- create new asset -->
- <xsl:when test="$data and name($data)='asset'">
- <cs:command name="com.censhare.api.assetmanagement.CheckInNew" returning="newAssetXml">
- <cs:param name="source">
- <xsl:apply-templates select="$data" mode="asset"/>
- </cs:param>
- </cs:command>
- <xsl:copy-of select="$newAssetXml"/>
- </xsl:when>
- <!-- no asset element in $data - return error -->
- <xsl:otherwise>
- <error message="No asset XML given">
- <xsl:copy-of select="$data"/>
- </error>
- </xsl:otherwise>
- </xsl:choose>
- </result>
- </xsl:template>
- <!-- storage_item match -->
- <xsl:template match="storage_item" priority="2" mode="asset">
- <storage_item>
- <xsl:copy-of select="@*"/>
- <xsl:if test="@url">
- <xsl:variable name="resultFile" select="concat($vfs, 'result.pdf')"/>
- <cs:command name="com.censhare.api.io.Copy">
- <cs:param name="source" select="@url"/>
- <cs:param name="dest" select="$resultFile"/>
- </cs:command>
- <xsl:attribute name="corpus:asset-temp-file-url" select="$resultFile"/>
- </xsl:if>
- </storage_item>
- </xsl:template>
- <!-- copy all other elements -->
- <xsl:template match="@*|node()" mode="asset">
- <xsl:copy><xsl:apply-templates select="@*|node()" mode="asset"/></xsl:copy>
- </xsl:template>
- </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement