From 25c232dabcfbaebb8295916bed92a56d9a18966f Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Wed, 13 Jun 2007 22:21:25 +0000
Subject: [PATCH] Add support for tagging managed object definitions so that similar types of managed object can be grouped together. Tagging will enable us to automatically generate more user-friendly documentation and administration tools as a result of them being easier to navigate and search. For example, an administration CLI will be able to split the available set of sub-commands into categories, thus making it easier for administrators to find the sub-command that they need.

---
 opends/resource/admin/preprocessor.xsl |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 1 deletions(-)

diff --git a/opends/resource/admin/preprocessor.xsl b/opends/resource/admin/preprocessor.xsl
index 2931923..9b14b13 100644
--- a/opends/resource/admin/preprocessor.xsl
+++ b/opends/resource/admin/preprocessor.xsl
@@ -166,12 +166,29 @@
         Pre-process this managed object's elements.
       -->
       <xsl:apply-templates
-        select="adm:TODO|adm:synopsis|adm:description|adm:profile"
+        select="adm:TODO|adm:synopsis|adm:description"
         mode="pre-process">
         <xsl:with-param name="moname" select="@name" />
         <xsl:with-param name="mopackage" select="@package" />
         <xsl:with-param name="hierarchy" select="$hierarchy" />
       </xsl:apply-templates>
+      <!--
+        Copy all inherited tags plus locally defined tags.
+      -->
+      <xsl:copy-of select="$hierarchy/adm:managed-object/adm:tag" />
+      <xsl:apply-templates select="adm:tag" mode="pre-process">
+        <xsl:with-param name="moname" select="@name" />
+        <xsl:with-param name="mopackage" select="@package" />
+        <xsl:with-param name="hierarchy" select="$hierarchy" />
+      </xsl:apply-templates>
+      <!--
+        Copy profile elements.
+      -->
+      <xsl:apply-templates select="adm:profile" mode="pre-process">
+        <xsl:with-param name="moname" select="@name" />
+        <xsl:with-param name="mopackage" select="@package" />
+        <xsl:with-param name="hierarchy" select="$hierarchy" />
+      </xsl:apply-templates>
       <!-- 
         Add a pre-processor element defining this managed object's uppermost
         definition.
@@ -249,6 +266,68 @@
     </xsl:copy>
   </xsl:template>
   <!--
+    Pre-process a tag and validate it and by adding a "preprocessor"
+    profile which contains information about where the tag was defined.
+  -->
+  <xsl:template match="adm:tag" mode="pre-process">
+    <xsl:param name="mopackage" select="/.." />
+    <xsl:param name="moname" select="/.." />
+    <xsl:param name="hierarchy" />
+    <!--
+      Make sure that this tag is not duplicated.
+    -->
+    <xsl:variable name="name" select="@name" />
+    <xsl:if test="../adm:tag[@name=$name][2]">
+      <xsl:message terminate="yes">
+        <xsl:value-of
+          select="concat('Tag ', @name, ' is already defined in this managed object')" />
+      </xsl:message>
+    </xsl:if>
+    <!--
+      Make sure that this tag does not override an existing tag.
+    -->
+    <xsl:if test="$hierarchy/adm:managed-object/adm:tag[@name=$name]">
+      <xsl:message terminate="yes">
+        <xsl:value-of
+          select="concat('Tag ', @name, ' is already defined in a parent managed object')" />
+      </xsl:message>
+    </xsl:if>
+    <!--
+      Get the referenced package.
+    -->
+    <xsl:variable name="uri">
+      <xsl:call-template name="get-managed-object-uri">
+        <xsl:with-param name="package"
+          select="'org.opends.server.admin.std'" />
+        <xsl:with-param name="name" select="'root'" />
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:if test="not(document($uri)/adm:root-managed-object)">
+      <xsl:message terminate="yes">
+        <xsl:value-of
+          select="concat('Root managed object definition not found in ', $uri, '.')" />
+      </xsl:message>
+    </xsl:if>
+    <xsl:if
+      test="not(document($uri)/adm:root-managed-object/adm:tag-definition[@name=$name])">
+      <xsl:message terminate="yes">
+        <xsl:value-of
+          select="concat('Tag &quot;', $name,
+                           '&quot; not defined in root managed object definition.')" />
+      </xsl:message>
+    </xsl:if>
+    <!--
+      Copy the tag.
+    -->
+    <xsl:element name="adm:tag">
+      <xsl:copy-of select="@*" />
+      <xsl:apply-templates mode="pre-process">
+        <xsl:with-param name="moname" select="$moname" />
+        <xsl:with-param name="mopackage" select="$mopackage" />
+      </xsl:apply-templates>
+    </xsl:element>
+  </xsl:template>
+  <!--
     Pre-process a property definition by adding a "preprocessor" profile
     which contains information about where the property was defined.
   -->

--
Gitblit v1.10.0