Update version of release notes in 2.5 docs
[working/Evergreen.git] / Open-ILS / examples / extract-IDL-permissions.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://opensrf.org/spec/IDL/base/v1" xmlns:oils_persist="http://open-ils.org/spec/opensrf/IDL/persistence/v1" xmlns:oils_obj="http://open-ils.org/spec/opensrf/IDL/objects/v1" xmlns:reporter="http://open-ils.org/spec/opensrf/IDL/reporter/v1" xmlns:permacrud="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
3         <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
4
5 <!--
6         USAGE:
7                 xsltproc extract-IDL-permissions.xsl fm_IDL.xml|perl -e 'while(<>){s/^\s+(.*)\s+$/$1/o;print("$1\n")unless(/^\s*$/ || /\s+/)}'|sort -u|less
8 -->
9
10         <xsl:template match="//permacrud:actions/*">
11                 <xsl:if test="@permission">
12                         <xsl:call-template name="output-tokens">
13                                 <xsl:with-param name="list"><xsl:value-of select="@permission"/></xsl:with-param>
14                         </xsl:call-template>
15                 </xsl:if>
16         </xsl:template>
17
18         <xsl:template name="output-tokens">
19                 <xsl:param name="list" />
20                 <xsl:variable name="newlist" select="normalize-space($list)" />
21                 <xsl:variable name="first" select="substring-before($newlist, ' ')" />
22                 <xsl:variable name="remaining" select="substring-after($list, ' ')" />
23                 <xsl:choose test="$first">
24                         <xsl:when test="$first">
25                                 <xsl:value-of select="$first" /><xsl:text>
26 </xsl:text>
27                                 <xsl:if test="$remaining">
28                                         <xsl:call-template name="output-tokens">
29                                                 <xsl:with-param name="list" select="$remaining" />
30                                         </xsl:call-template>
31                                 </xsl:if>
32                         </xsl:when>
33                         <xsl:otherwise>
34                                 <xsl:value-of select="$list" />
35                         </xsl:otherwise>
36                 </xsl:choose>
37         </xsl:template>
38
39 </xsl:stylesheet>