6.6 パスワードの変更: 作成ポリシーの例

次のスタイルシートは、作成ポリシーで使用できます。これはユーザを作成し、そのユーザのSurnameとCNの属性からパスワードを生成して、中断と変換を試行しているイベントを除き、ドキュメント内のすべてを通過する識別情報の変換を実行します。このスタイルシートを表示するには、Create_Password.xslを参照してください。

<?xml version="1.0" encoding="ISO-8859-1"?>

<!--   This stylesheet has an example of how to replace a create rule with 
        an XSLT stylesheet and supply an initial password for "User" objects. -->

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform  
     	"version="1.0">

<!-- ensure we have required NDS attributes -->
<xsl:template match="add">
   <xsl:if test="add-attr[@attr-name=’Surname’] and
                 add-attr[@attr-name=’CN’]">
      <!-- copy the add through -->
      <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
         <!-- add a <password> element -->
         <xsl:call-template name="create-password"/>
      </xsl:copy>
   </xsl:if>

<!-- if the xsl:if fails, we don’t have all the required attributes
      so we won’t copy the add through, and the create rule will veto the add -->

</xsl:template>

<xsl:template name="create-password">
   <password>
      <xsl:value-of select="concat(add-attr[@attr-name=’Surname’]/value,
           ’-’,add-attr[@attr-name=’CN’]/value)"/>
   </password>
</xsl:template>

<!-- identity transform for everything we don’t want to change -->

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>        
</xsl:template>
   
</xsl:transform>