Skip to content

Instantly share code, notes, and snippets.

@trscavo
Last active May 15, 2017 21:43
Show Gist options
  • Save trscavo/0c30a591c8fe85aec5c838bd3f83842a to your computer and use it in GitHub Desktop.
Save trscavo/0c30a591c8fe85aec5c838bd3f83842a to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!--
list_entity_roles_txt.xsl
This XSL transform takes a SAML metadata document and produces
a tab-separated list of triples:
(@entityID, roleDescriptor, @registrationAuthority)
where roleDescriptor is one of the following:
IDPSSODescriptor
SPSSODescriptor
AttributeAuthorityDescriptor
Note that a given entityID may appear multiple times since
an entity may assume multiple roles.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi">
<!-- Output is plain text -->
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="//md:EntityDescriptor[md:IDPSSODescriptor]">
<xsl:value-of select="./@entityID"/>
<xsl:text>&#x09;</xsl:text>
<xsl:text>IDPSSODescriptor</xsl:text>
<xsl:text>&#x09;</xsl:text>
<xsl:value-of select="./md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority"/>
<xsl:text>&#x0a;</xsl:text>
</xsl:for-each>
<xsl:for-each select="//md:EntityDescriptor[md:SPSSODescriptor]">
<xsl:value-of select="./@entityID"/>
<xsl:text>&#x09;</xsl:text>
<xsl:text>SPSSODescriptor</xsl:text>
<xsl:text>&#x09;</xsl:text>
<xsl:value-of select="./md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority"/>
<xsl:text>&#x0a;</xsl:text>
</xsl:for-each>
<xsl:for-each select="//md:EntityDescriptor[md:AttributeAuthorityDescriptor]">
<xsl:value-of select="./@entityID"/>
<xsl:text>&#x09;</xsl:text>
<xsl:text>AttributeAuthorityDescriptor</xsl:text>
<xsl:text>&#x09;</xsl:text>
<xsl:value-of select="./md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority"/>
<xsl:text>&#x0a;</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="text()">
<!-- do nothing -->
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment