SHARE
TWEET

Untitled

a guest Apr 19th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="2.0"
  3.  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4.  xmlns:cs="http://www.censhare.com/xml/3.0.0/xpath-functions"
  5.  xmlns:corpus="http://www.censhare.com/xml/3.0.0/corpus"
  6.  exclude-result-prefixes="cs">
  7.  
  8.   <!-- Transformation that creates new asset from body XML of REST post method -->
  9.  
  10.   <!-- output -->
  11.   <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
  12.  
  13.   <!-- parameters -->
  14.   <xsl:param name="data"/>
  15.  
  16.   <!-- variables -->
  17.   <xsl:variable name="vfs">
  18.     <cs:command name="com.censhare.api.io.CreateVirtualFileSystem"/>
  19.   </xsl:variable>
  20.  
  21.   <!-- root match -->
  22.   <xsl:template match="/">
  23.     <result>
  24.       <xsl:choose>
  25.         <!-- create new asset -->
  26.         <xsl:when test="$data and name($data)='asset'">
  27.           <cs:command name="com.censhare.api.assetmanagement.CheckInNew" returning="newAssetXml">
  28.             <cs:param name="source">
  29.               <xsl:apply-templates select="$data" mode="asset"/>
  30.             </cs:param>
  31.           </cs:command>
  32.           <xsl:copy-of select="$newAssetXml"/>
  33.         </xsl:when>
  34.         <!-- no asset element in $data - return error -->
  35.         <xsl:otherwise>
  36.           <error message="No asset XML given">
  37.             <xsl:copy-of select="$data"/>
  38.           </error>
  39.         </xsl:otherwise>
  40.       </xsl:choose>
  41.     </result>
  42.   </xsl:template>
  43.  
  44.   <!-- storage_item match -->
  45.   <xsl:template match="storage_item" priority="2" mode="asset">
  46.     <storage_item>
  47.       <xsl:copy-of select="@*"/>
  48.       <xsl:if test="@url">
  49.         <xsl:variable name="resultFile" select="concat($vfs, 'result.pdf')"/>
  50.         <cs:command name="com.censhare.api.io.Copy">
  51.           <cs:param name="source" select="@url"/>
  52.           <cs:param name="dest" select="$resultFile"/>
  53.         </cs:command>
  54.         <xsl:attribute name="corpus:asset-temp-file-url" select="$resultFile"/>
  55.       </xsl:if>
  56.     </storage_item>
  57.   </xsl:template>
  58.  
  59.   <!-- copy all other elements -->
  60.   <xsl:template match="@*|node()" mode="asset">
  61.     <xsl:copy><xsl:apply-templates select="@*|node()" mode="asset"/></xsl:copy>
  62.   </xsl:template>
  63.              
  64. </xsl:stylesheet>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top