Skip to content

Commit

Permalink
Copy attributes on document element from input to output.
Browse files Browse the repository at this point in the history
Compute a validUntil value a (parameterised) 28 days from the aggregation timestamp, and interpose it both in the document comment and in a new validUntil attribute on the document element.
  • Loading branch information
iay committed Mar 21, 2009
1 parent 9bb23f3 commit 3615f28
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion build/uk_master_test.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,27 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wayf="http://sdss.ac.uk/2006/06/WAYF"
xmlns:uklabel="http://ukfederation.org.uk/2006/11/label"

xmlns:date="http://exslt.org/dates-and-times"
xmlns:ukfxd="xalan://uk.org.ukfederation.xalan.Dates"
extension-element-prefixes="date ukfxd"

xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
exclude-result-prefixes="wayf">

<!--Force UTF-8 encoding for the output.-->
<xsl:output omit-xml-declaration="no" method="xml" encoding="UTF-8" indent="yes"/>

<!--
validityDays
This parameter determines the number of days between the aggregation instant and the
end of validity of the signed metadata.
-->
<xsl:variable name="validityDays" select="28"/>

<xsl:variable name="now" select="date:date-time()"/>
<xsl:variable name="validUntil" select="ukfxd:dateAdd($now, $validityDays)"/>

<!--
Document root.
Expand All @@ -42,8 +55,12 @@
-->
<xsl:template match="/md:EntitiesDescriptor">
<xsl:copy>
<xsl:attribute name="validUntil">
<xsl:value-of select="$validUntil"/>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:call-template name="document.comment"/>
<xsl:apply-templates/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>

Expand All @@ -59,6 +76,12 @@
<xsl:text>&#9;Aggregate built </xsl:text>
<xsl:value-of select="$now"/>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#9;Aggregate valid for </xsl:text>
<xsl:value-of select="$validityDays"/>
<xsl:text> days, until </xsl:text>
<xsl:value-of select="$validUntil"/>
<xsl:text>&#10;</xsl:text>
</xsl:comment>
</xsl:template>

Expand Down

0 comments on commit 3615f28

Please sign in to comment.