simple xslt (with embeded usage info) for extracting perms from the IDL permacrud...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 May 2008 18:01:23 +0000 (18:01 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 May 2008 18:01:23 +0000 (18:01 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9641 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/extract-IDL-permissions.xsl [new file with mode: 0644]

diff --git a/Open-ILS/examples/extract-IDL-permissions.xsl b/Open-ILS/examples/extract-IDL-permissions.xsl
new file mode 100644 (file)
index 0000000..65fbb97
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+       <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
+
+<!--
+       USAGE:
+               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
+-->
+
+       <xsl:template match="//permacrud:actions/*">
+               <xsl:if test="@permission">
+                       <xsl:call-template name="output-tokens">
+                               <xsl:with-param name="list"><xsl:value-of select="@permission"/></xsl:with-param>
+                       </xsl:call-template>
+               </xsl:if>
+       </xsl:template>
+
+       <xsl:template name="output-tokens">
+               <xsl:param name="list" />
+               <xsl:variable name="newlist" select="normalize-space($list)" />
+               <xsl:variable name="first" select="substring-before($newlist, '|')" />
+               <xsl:variable name="remaining" select="substring-after($list, '|')" />
+               <xsl:choose test="$first">
+                       <xsl:when test="$first">
+                               <xsl:value-of select="$first" /><xsl:text>
+</xsl:text>
+                               <xsl:if test="$remaining">
+                                       <xsl:call-template name="output-tokens">
+                                               <xsl:with-param name="list" select="$remaining" />
+                                       </xsl:call-template>
+                               </xsl:if>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:value-of select="$list" />
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+
+</xsl:stylesheet>