Skip to content

Commit

Permalink
Introduce a namespace normalisation framework built in XSLT. Use this…
Browse files Browse the repository at this point in the history
… to replace the namespace normalisation performed in the fragment import transform.
  • Loading branch information
iay committed May 16, 2011
1 parent 8a4ccc1 commit c3e4510
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 140 deletions.
20 changes: 17 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,14 @@
limit for all of them.
-->
<property name="java.max.memory" value="768m"/>


<!--
Full paths to a couple of temporary file locations.
-->
<property name="temp.xml" value="${xml.dir}/temp.xml"/>
<property name="temp2.xml" value="${xml.dir}/temp2.xml"/>


<!--
*************************************************
*** ***
Expand Down Expand Up @@ -875,8 +882,15 @@

<target name="import.metadata">
<echo>Importing metadata from ${entities.dir}/import.xml</echo>
<XALAN i="${entities.dir}/import.xml" o="${entities.dir}/imported.xml"
x="${build.dir}/import.xsl"/>

<!-- Step 1: perform real processing into temporary file -->
<XALAN x="${build.dir}/import.xsl"
i="${entities.dir}/import.xml" o="${temp.xml}"/>

<!-- Step 2: normalise namespaces into result file -->
<XALAN x="${build.dir}/ns_norm_fragment.xsl"
i="${temp.xml}" o="${entities.dir}/imported.xml"/>

<echo>Imported metadata to ${entities.dir}/imported.xml</echo>
<CHECK.std i="${entities.dir}/imported.xml">
<arg value="${build.dir}/check_imported.xsl"/>
Expand Down
140 changes: 3 additions & 137 deletions build/import.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -206,39 +206,6 @@
</xsl:template>


<!--
md:*
Normalise namespace prefix.
-->
<xsl:template match="md:*">
<xsl:element name="{local-name()}" namespace="urn:oasis:names:tc:SAML:2.0:metadata">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>


<!--
*************************************
*** ***
*** A L G N A M E S P A C E ***
*** ***
*************************************
-->


<!--
alg:*
Normalise namespace prefix.
-->
<xsl:template match="alg:*">
<xsl:element name="alg:{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>


<!--
***********************************
*** ***
Expand All @@ -248,18 +215,6 @@
-->


<!--
ds:KeyInfo
Normalise namespace prefix.
-->
<xsl:template match="ds:KeyInfo">
<ds:KeyInfo>
<xsl:apply-templates select="node()|@*"/>
</ds:KeyInfo>
</xsl:template>


<!--
ds:KeyName
Expand All @@ -270,30 +225,6 @@
</xsl:template>


<!--
ds:KeyName
Normalise namespace prefix.
-->
<xsl:template match="ds:KeyName">
<ds:KeyName>
<xsl:apply-templates select="node()|@*"/>
</ds:KeyName>
</xsl:template>


<!--
ds:X509Data
Normalise namespace prefix.
-->
<xsl:template match="ds:X509Data">
<ds:X509Data>
<xsl:apply-templates select="node()|@*"/>
</ds:X509Data>
</xsl:template>


<!--
Normalise whitespace in X509Certificate elements.
-->
Expand Down Expand Up @@ -326,81 +257,16 @@
<!--
idpdisc:DiscoveryResponse
Normalise namespace prefix, add missing Binding attribute.
Add missing Binding attribute.
-->
<xsl:template match="idpdisc:DiscoveryResponse">
<xsl:template match="idpdisc:DiscoveryResponse[not(@Binding)]">
<idpdisc:DiscoveryResponse>
<xsl:if test="not(@Binding)">
<xsl:attribute name="Binding">urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol</xsl:attribute>
</xsl:if>
<xsl:attribute name="Binding">urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</idpdisc:DiscoveryResponse>
</xsl:template>


<!--
***************************************
*** ***
*** I N I T N A M E S P A C E ***
*** ***
***************************************
-->


<!--
init:RequestInitiator
Normalise namespace prefix.
-->
<xsl:template match="init:RequestInitiator">
<init:RequestInitiator>
<xsl:apply-templates select="node()|@*"/>
</init:RequestInitiator>
</xsl:template>


<!--
***************************************
*** ***
*** M D U I N A M E S P A C E ***
*** ***
***************************************
-->


<!--
mdui:*
Normalise namespace prefix.
-->
<xsl:template match="mdui:*">
<xsl:element name="mdui:{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>


<!--
*******************************************
*** ***
*** S H I B M D N A M E S P A C E ***
*** ***
*******************************************
-->


<!--
shibmd:Scope
Normalise namespace prefix.
-->
<xsl:template match="shibmd:Scope">
<shibmd:Scope>
<xsl:apply-templates select="node()|@*|text()"/>
</shibmd:Scope>
</xsl:template>


<!--
*********************************************
*** ***
Expand Down
Loading

0 comments on commit c3e4510

Please sign in to comment.