[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

Subject: Re: XSLT to populate a SAML AttributeStatement from an XML
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Jan 2023 19:03:31 -0000
Re:  XSLT to populate a SAML AttributeStatement from an
Correction, I left out the second argument to tokenize(), which in your case
should be ':'.

Michael Kay

> On 18 Jan 2023, at 18:56, Michael Kay michaelkay90@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Are you able to use XSLT 2.0+ -- that gives you a tokenize() function which
makes this far easier.
>
> In 2.0 it's essentially
>
> <xsl:template match="personnel/*">
>  <saml:Attribute Name="{name()}"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
>    <xsl:for-each select="tokenize(.)">
>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string"><xsl:value-of select="."/></saml:AttributeValue>
>
> Incidentally, there are no attributes in your input XML - it's all
elements.
>
> Michael Kay
> Saxonica
>
>
>> On 18 Jan 2023, at 17:06, ohaya ohaya@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> [I originally sent this to the wrong email address... sorry!]
>>
>> Hi,
>>
>> I have an application where I am retrieving a number of attributes and
values from a web service, in the form of an XML file, and I want to create
and populate a SAML AttributeStatement from the attributes and values in that
XML file.  A couple of complications (to me):
>>
>> - The attribute names in the XML file are different than the corresponding
attributes in the SAML AttributeStatement.
>> - Some of the attributes are multi-valued:  in the source XML file, the
values are a colon-separated string (e.g. ab:cd:ef), but in the
AttributeStatement, each value will be in separate <saml:Attribute> element.
>>
>> Here's an example source XML:
>>
>> <record>
>> .
>> .
>> .
>> <adrRecord>
>>   <PN_ID>1111111</PN_ID>
>>   <personnel>
>>     <ADM_ORG_CD>urn:NORM:DEPT</ADM_ORG_CD>
>>     <DOD_ASSOC_CD>urn:NORM:V01</DOD_ASSOC_CD>
>>   </personnel>
>> </adrRecord>
>> </record>
>>
>> and the AttributeStatement I want to transform the above to is something
like:
>>
>>
>>   <saml:Attribute Name="MY_PN_ID"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
>>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string">1111111</saml:AttributeValue>
>>   </saml:Attribute>
>>
>>
>>   <saml:Attribute Name="MY_ORG_CD"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
>>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string">DEPT</saml:AttributeValue>
>>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string">urn</saml:AttributeValue>
>>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string">NORM</saml:AttributeValue>
>>   </saml:Attribute>
>>
>>
>>   <saml:Attribute Name="MY_ASSOC_CD"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
>>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string">urn</saml:AttributeValue>
>>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string">NORM</saml:AttributeValue>
>>       <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:string">V01</saml:AttributeValue>
>>   </saml:Attribute>
>>
>> </saml:AttributeStatement>
>>
>> Can someone suggest the best approach to do this?  I actually would prefer
to have a series of transforms to do this, rather than just a single XSLT,
mainly so I can be able to see how things are working (or not working).
>>
>> Thanks,
>> Jim

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.