Add cache method to find but not remove sessions by name.
[shibboleth/sp.git] / schemas / trust_v13_to_v12.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3
4         v13_to_v12_trust.xsl
5         
6         XSL stylesheet converting a SAML 2 metadata file describing a Shibboleth
7         1.3 federation into the equivalent Shibboleth 1.2 trust file.
8         
9         Author: Ian A. Young <ian@iay.org.uk>
10
11         $Id$
12 -->
13 <xsl:stylesheet version="1.0"
14         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15         xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
16         xmlns:shibmeta="urn:mace:shibboleth:metadata:1.0"
17         xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
18         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19         xmlns="urn:mace:shibboleth:trust:1.0"
20         exclude-result-prefixes="shibmeta md">
21
22         <!--
23                 Version information for this file.  Remember to peel off the dollar signs
24                 before dropping the text into another versioned file.
25         -->
26         <xsl:param name="cvsId">$Id$</xsl:param>
27
28         <!--
29                 Add a comment to the start of the output file.
30         -->
31         <xsl:template match="/">
32                 <xsl:comment>
33                         <xsl:text>&#10;&#9;***DO NOT EDIT THIS FILE***&#10;&#10;</xsl:text>
34                         <xsl:text>&#9;Converted by:&#10;&#10;&#9;</xsl:text>
35                         <xsl:value-of select="substring-before(substring-after($cvsId, ': '), '$')"/>
36                         <xsl:text>&#10;</xsl:text>
37                 </xsl:comment>
38                 <Trust>
39                         <xsl:attribute name="xsi:schemaLocation">
40                                 <xsl:text>urn:mace:shibboleth:trust:1.0 shibboleth-trust-1.0.xsd </xsl:text>
41                                 <xsl:text>http://www.w3.org/2000/09/xmldsig# xmldsig-core-schema.xsd</xsl:text>
42                         </xsl:attribute>
43                         <xsl:apply-templates/>
44                 </Trust>
45         </xsl:template>
46
47         <!--Force UTF-8 encoding for the output.-->
48         <xsl:output omit-xml-declaration="no" method="xml" encoding="UTF-8" indent="yes"/>
49
50         <!--
51                 Extract a KeyAuthority extension from an EntitiesDescriptor.
52         -->
53         <xsl:template match="md:EntitiesDescriptor">
54         
55                 <!-- extract KeyAuthority metadata, if any -->
56                 <xsl:if test="md:Extensions/shibmeta:KeyAuthority/ds:KeyInfo">
57                         <xsl:apply-templates select="md:Extensions/shibmeta:KeyAuthority">
58                                 <xsl:with-param name="name" select="@Name"/>
59                         </xsl:apply-templates>
60                 </xsl:if>
61
62                 <!-- proceed to nested EntitiesDescriptor and EntityDescriptor elements -->
63                 <xsl:apply-templates select="md:EntitiesDescriptor | md:EntityDescriptor"/>
64         </xsl:template>
65
66         <!--
67                 Extract a KeyAuthority extension from an EntityDescriptor.
68         -->
69         <xsl:template match="md:EntityDescriptor">
70                 <!-- extract KeyAuthority metadata, if any -->
71                 <xsl:if test="md:Extensions/shibmeta:KeyAuthority/ds:KeyInfo">
72                         <xsl:apply-templates select="md:Extensions/shibmeta:KeyAuthority">
73                                 <xsl:with-param name="name" select="@entityID"/>
74                         </xsl:apply-templates>
75                 </xsl:if>
76         </xsl:template>
77
78         <!--
79                 Map shibmeta:KeyAuthority to trust:KeyAuthority
80         -->
81         <xsl:template match="shibmeta:KeyAuthority">
82                 <xsl:param name="name"/>
83                 <KeyAuthority>
84                         <!-- copy across VerifyDepth attribute if present -->
85                         <xsl:apply-templates select="@VerifyDepth"/>
86
87                         <!-- generate KeyName -->
88                         <ds:KeyName>
89                                 <xsl:value-of select="$name"/>
90                         </ds:KeyName>
91
92                         <!-- generate single output KeyInfo element -->
93                         <ds:KeyInfo>
94                                 <!-- extract the insides of all KeyInfo elements in the input -->
95                                 <xsl:apply-templates select="text() | comment() | ds:KeyInfo/* | ds:KeyInfo/comment() | ds:KeyInfo/text()"/>
96                         </ds:KeyInfo>
97                 </KeyAuthority>
98         </xsl:template>
99
100         <!--
101                 Generic recursive copy for ds:* elements.
102                 
103                 This works better than an xsl:copy-of because it does not copy across spurious
104                 namespace nodes.
105         -->
106         <xsl:template match="ds:*">
107                 <xsl:element name="{name()}">
108                         <xsl:apply-templates select="ds:* | text() | comment() | @*"/>
109                 </xsl:element>
110         </xsl:template>
111
112         <!--
113                 By default, copy referenced attributes through unchanged.
114         -->
115         <xsl:template match="@*">
116                 <xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
117         </xsl:template>
118
119         <!--
120                 By default, copy comments and text nodes through to the output unchanged.
121         -->
122         <xsl:template match="text()|comment()">
123                 <xsl:copy/>
124         </xsl:template>
125
126 </xsl:stylesheet>
127