[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: "ohaya ohaya@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 Jan 2023 07:41:03 -0000
Re:  XSLT to populate a SAML AttributeStatement from an
 Hi Martin,

Actually I think that even without the difference in the name, I am going to
have to do one template match per attribute.

I didn't post the entire XSLT, but the reason that I am saying that is that in
the XML that is the source, not all have the same path (e.g. there is
personnel, enterprise).

So given that, can you (or someone) post a single template match including the
tokenize()?

Thanks,
Jim


     On Thursday, January 19, 2023, 01:50:01 AM EST, Martin Honnen
martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:




 Am 1/19/2023 um 4:58 AM schrieb ohaya ohaya@xxxxxxxxx:


 Hi All,

 Thanks for the help thus far... I was able to integrate the code I posted
earlier today to construct a saml:AttributeStatement, and I was able to
integrate that with the rest of what I'm doing (there were a lot more
attributes, etc.

 So now, I think what I have left is to handle the multi-values.

 I think that Michael posted this (this also has his correction):

 <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>

 but I am confused.

 In the code I had posted (for 3 of the attribs), I had one <xsl:template
match"> for each of the attribs.

 With the code above, are you all sayiI don't have to do that and just have a
single <xsl:template match>?



If there were a one to one relation between input data values and result names
you could use a single template, it seems however that we didn't notice that
e.g.


B 

 <PN_ID>1111111</PN_ID>is supposed to become saml:Attribute Name="MY_PN_ID"
while e.g.   <ADM_ORG_CD>urn:NORM:DEPT</ADM_ORG_CD>is supposed to become e.g.
saml:Attribute Name="MY_ORG_CD"and not    saml:Attribute
Name="MY_ADM_ORG_CD"Thus if you have to use a different approach for each name
you might need more templates than a single one that simply does e.g.
<saml:Attribute Name="MY_{name()}">As for the values, the suggested tokenize
approach, as far as I see it currently, would work, if there is no colon it
creates a single samlAttributeValue, if there are colons it creates several.

     On Wednesday, January 18, 2023, 04:08:40 PM EST, ohaya <ohaya@xxxxxxxxx>
wrote:

      Hi,

 I originally thought that also but didn't know how to add the root to the
XSLT (I tried just putting into the XSLT but it said that template had to be
top-level).

 Anyway, so I was also guessing the problem was what you said, so I found a
page the mentioned how to add the root and got this XSLT:

 <xsl:stylesheet version="1.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:template match="/">
 <saml:AttributeStatement>
 <xsl:apply-templates select="/record/adrRecord/*"/>
 </saml:AttributeStatement>
 </xsl:template>

 <xsl:template match="/record/adrRecord/PN_ID">
 <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"><xsl:value-of select="/record/adrRecord/PN_ID" />
 </saml:AttributeValue>
 </saml:Attribute>
 </xsl:template>

 <xsl:template match="/record/adrRecord/personnel/ADM_ORG_CD">
 <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"> <xsl:value-of
select="/record/adrRecord/personnel/ADM_ORG_CD" />
 </saml:AttributeValue>
 </saml:Attribute>
 </xsl:template>

 <xsl:template match="/record/adrRecord/personnel/DOD_ASSOC_CD">
 <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"> <xsl:value-of
select="/record/adrRecord/personnel/DOD_ASSOC_CD" />
 </saml:AttributeValue>
 </saml:Attribute>

 </xsl:template>


 </xsl:stylesheet>


 I






 XSL-List info and archiveEasyUnsubscribe(by email)

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.