|
Subject: [xsl] Applying template with a variable From: Harry Liljeström <harry.liljestrom@xxxxxxxxxxxxx> Date: Wed, 17 Jan 2007 12:49:05 +0200 (EET) |
1. The variable authobj consists of authentication-object node. 2. <xsl:apply-templates select="$authobj"/> should launch the <xsl:template match="authentication-object[type = 'plain-file']">.
<xsl:variable name="locauthobjs" select="/config/authentication-objects/authentication-object"/> <xsl:variable name="globauthobjs" select="document('../etc/policyglobal.xml')/config/authentication-objects/authentication-object"/>
<xsl:template match="//authentication/object">
<xsl:variable name="authobj">
<xsl:call-template name="authobjbyname">
<xsl:with-param name="name" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="$authobj"/><!-- [1.] -->
</xsl:template><xsl:template name="authobjbyname">
<xsl:param name="name"/>
<xsl:if test="$name !=''">
<xsl:choose>
<!-- Test if it exists in the local file? -->
<xsl:when test="$locauthobjs[@name=$name] !=''">
<xsl:value-of select="$locauthobjs[@name=$name]"/>
</xsl:when>
<xsl:otherwise>
<!-- It seems to exist in the global file!-->
<xsl:value-of select="$globauthobjs[@name=$name]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template><xsl:template name="key_file">
<xsl:param name="path"/>
<xsl:variable name="totlen">
<xsl:value-of select="string-length($path)"/>
</xsl:variable>
<xsl:if test="$totlen > 0">
<xsl:variable name="cert_pos">
<xsl:value-of select="$totlen - string-length(substring-after($path,'cert//')) + 1"/>
</xsl:variable>
<xsl:variable name="cert_len">
<xsl:value-of select="string-length(substring-before($path, ' ')) + string-length(substring-after($path,'cert//')) - $totlen"/>
</xsl:variable>
<xsl:value-of select="'key_file('"/>
<xsl:value-of select="substring($path, $cert_pos, $cert_len)"/>
<xsl:value-of select="','"/>
<xsl:value-of select="substring($path, $totlen - string-length(substring-after($path,'priv//')) + 1)"/>
<xsl:value-of select="')'"/>
</xsl:if>
</xsl:template><config>
<authentication-objects>
<authentication-object name="My_test_665_private_key">
<type>plain-file</type>
<path>cert//C:/Temp/Certs/cert1.bin priv//C:/Temp/Certs/priv-key1.prv</path>
</authentication-object>
<authentication-object name="MyTestProfileSecret">
<type>pre-shared-key</type>
<path>hoobar</path>
</authentication-object>
<authentication-object name="NewTestKey">
<type>pre-shared-key</type>
<path>funny_hey</path>
</authentication-object>
</authentication-objects>
<policy-rules>
<ipsec-rules>
<rule name="CertificateAuthentication">
<authentication>
<object>
My_test_665_private_key
</object>
</authentication>
</rule>
<!-- There exists several rules here! -->
</ipsec-rules>
</policy-rules>
</config>Desired output: <!-- Those authentication-objects with type = 'plain-file' which are used in some rule should appear here. --> <exteranal-key type="software" init-info="key_file(C:/Temp/Certs/cert1.bin,C:/Temp/Certs/priv-key1.prv)"/>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re[2]: [xsl] saxon error, Alexey Nickolaenkov | Thread | Re: [xsl] Applying template with a , Harry Liljeström |
| Re: [xsl] saxon xmlspy discrepancy , Abel Braaksma | Date | [xsl] Re: xsl-list Digest 17 Jan 20, Frank Hopper |
| Month |