[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT to populate a SAML AttributeStatement from an
Am 1/19/2023 um 8:41 AM schrieb ohaya ohaya@xxxxxxxxx:
Hi Martin, You can transform e.g. <record> B <adrRecord> B B B <PN_ID>1111111</PN_ID> B B B <personnel> B B B B B <ADM_ORG_CD>urn:NORM:DEPT</ADM_ORG_CD> B B B B B <DOD_ASSOC_CD>urn:NORM:V01</DOD_ASSOC_CD> B B B </personnel> B </adrRecord> </record> with XSLT 3 <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsl:mode on-no-match="shallow-skip"/> <xsl:output indent="yes"/> <xsl:template match="/"> B <saml:AttributeStatement> B B B <xsl:apply-templates /> B </saml:AttributeStatement> </xsl:template> <xsl:template match="record/adrRecord//*[not(*)]"> B <saml:Attribute Name="{name()}"> B B B <xsl:for-each select="tokenize(., ':')"> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"> B B B B B B B <xsl:value-of select="."/> B B B B B </saml:AttributeValue> B B B </xsl:for-each> B </saml:Attribute> </xsl:template> </xsl:stylesheet> into e.g. <saml:AttributeStatement xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> B B <saml:Attribute Name="PN_ID"> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">1111111</saml:AttributeValue> B B </saml:Attribute> B B <saml:Attribute Name="ADM_ORG_CD"> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">urn</saml:AttributeValue> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">NORM</saml:AttributeValue> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">DEPT</saml:AttributeValue> B B </saml:Attribute> B B <saml:Attribute Name="DOD_ASSOC_CD"> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">urn</saml:AttributeValue> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">NORM</saml:AttributeValue> B B B B B <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">V01</saml:AttributeValue> B B </saml:Attribute> </saml:AttributeStatement>
B <xsl:mode on-no-match="shallow-skip"/> but have to spell out <xsl:template match="/ | *"> B <xsl:apply-templates select="@*"/> B <xsl:apply-templates/> </xsl:template> <xsl:template match="text() | @* | comment() | processing-instruction()"/>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|