0

I have a custom xsl for AAA to pick the authenticated value(Output credential ) and to pass it on for authorization.

Am using the AAAinfo.xml file for this.

AAAinfo.xml :

<?xml version="1.0" encoding="UTF-8"?>
<AAAInfo xmlns="http://www.datapower.com/AAAInfo">
   <Authenticate>
      <OU>****</OU>
      <OutputCredential>****</OutputCredential>
      <OutputCredential>****</OutputCredential>
   </Authenticate>
   <Authenticate>
      <OU>****</OU>
      <OutputCredential>****</OutputCredential>
      <OutputCredential>****</OutputCredential>
   </Authenticate>
   <Authorize>
      <InputCredential>****</InputCredential>
      <InputResource>/****</InputResource>
      <Access>****</Access>
   </Authorize>
   <Authorize>
      <InputCredential>****</InputCredential>
      <InputResource>/****</InputResource>
      <Access>allow</Access>
   </Authorize>
</AAAInfo>

In the below xsl , am unable to loop into <Authenticate> tag.....

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" version="1.0" extension-element-prefixes="dp str regexp" exclude-result-prefixes="dp str regexp">
   <xsl:template match="/">
      <xsl:variable name="AAA_File" select="document('local:///TEST/AAA_data.xml')" />
      <xsl:variable name="DN">
         <xsl:value-of select="dp:variable('var://context/AAA-internal-debug/EI')/identity/entry/dn" />
      </xsl:variable>
      <xsl:variable name="OU_Split1" select="substring-after(normalize-space($DN),'OU=')" />
      <xsl:variable name="OU_Split2" select="substring-before(normalize-space($OU_Split1),'/CN')" />
      <xsl:variable name="OU_Name">
         <xsl:value-of select="regexp:replace($OU_Split2,'/OU=','g','|')" />
      </xsl:variable>
      <xsl:for-each select="$AAA_File/AAA_data/Authenticate">
         <xsl:variable name="OU_File_Name">
            <xsl:value-of select="OU" />
         </xsl:variable>
         <xsl:if test="contains($OU_Name,$OU_File_Name)">
            <xsl:for-each select="OutputCredential">
               <OutputCredential>
                  <xsl:value-of select="." />
               </OutputCredential>
            </xsl:for-each>
         </xsl:if>
      </xsl:for-each>
   </xsl:template>
</xsl:stylesheet>

Let me know how to handle <AAAInfo xmlns="http://www.datapower.com/AAAInfo"> while looping.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
sreevathsa a
  • 149
  • 13
  • have you tried `` ? – Carlos Oct 27 '16 at 09:36
  • tried the same but still the same and if I remove xmlns="http://www.datapower.com/AAAInfo" tag , the the loop is working fine. – sreevathsa a Oct 27 '16 at 09:55
  • What is your desired output? – Rao Oct 27 '16 at 09:56
  • **** **** **** **** **** **** Take out the value of when matches with the incoming DN . – sreevathsa a Oct 27 '16 at 09:59
  • SO community would appreciate if you read this: [mcve] – uL1 Oct 27 '16 at 10:00
  • 1
    @sreevathsaa **1.** Please don't post code in comments - edit your question instead. **2.** Please don't tag your questions `xslt2.0` when you're using an XSLT 1.0 processor. **3.** With regard to your problem (or at least one major part of your problem) , see: http://stackoverflow.com/questions/34758492/xslt-transform-doesnt-work-until-i-remove-root-node/34762628#34762628 – michael.hor257k Oct 27 '16 at 17:59
  • Search for "XPath default namespace" -- this is the most FAQ about XPath and XSLT ... – Dimitre Novatchev Oct 28 '16 at 04:37

2 Answers2

0

Thx all for the comments.

Solution: declare the same namespace in your stylesheet, assign it a prefix and use that prefix to address the elements in the source XML:

According have dec

xmlns:ns="http://www.datapower.com/AAAInfo"

and have looped as below

 <xsl:for-each select="$AAA_File/ns:AAAInfo/ns:Authenticate">
 <xsl:variable name = "OU_File_Name">
        <xsl:value-of select="ns:OU"/>
</xsl:variable>

        <xsl:if test = "contains($OU_Name,$OU_File_Name)">
         <xsl:for-each select="ns:OutputCredential">    
sreevathsa a
  • 149
  • 13
-1

xsl:for-each select="$AAA_File//AAAInfo/Authenticate">

Should do the trick... Nu! AAAInfo, not AAA_Data.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Anders
  • 3,198
  • 1
  • 20
  • 43
  • 1
    Just changing `AAA_Data` to `AAAInfo` isn't going to work. `AAAInfo` is in a default namespace (`{http://www.datapower.com/AAAInfo}AAAInfo`). – Daniel Haley Oct 27 '16 at 21:33