extracting value from query parameter in XSLT

Hi I have the following XML. I understand its partial but the main chunk of it in the question.

<?xml version='1.0' encoding='UTF-8' ?> <autnresponse xmlns:autn='http://schemas.autonomy.com/aci/'>     <action>GRL</action>     <response>SUCCESS</response>     <responsedata>         <logentry>             <autn:action>GETQUERYTAGVALUES</autn:action>           <autn:request>action=GETQUERYTAGVALUES&amp;outputencoding=UTF8&amp;securityinfo=MzU2fOF%2B5eSQuqdOYyq0j8%2F1oA3pmjQzOeS88Ddrt%2F0kO7ONSKKhD%2BTEScNxjEatqmV%2FJjFWdAD8JMpbv0WRQ%2F2MhQuHZpBpAdWbrTCSkA2xrWRsJp3hpqLk6r6xQM9s0rtaiWnq7hIxdhvJbQhDvKu2zIsmNXxPWbuU%2FOFYejT8Ku62opQP6cY415GJGmVUAkYSXRGjfOWRbvBygPEu48Wsc4V9UHfV2gUnTgJWOqlfnL738qGuCZdVfly5orlmH2qHNhZzet4ZuDmXk%2BI8dbxMdNeI9SgL1VwpeewVKyARciJn%2BiImL2HObDcx%2Bxn9ik%2FfeJ6YkdPQJeULr4QMJlVaDpxiBlLVuA%2FLYPvj0ErQaf%2FtFIJB5W32p2b5eLNVCGQZjSztssDAqtqEPhwAy0KmxGpr%2Bxl7SYfCKNhZwLGShc6EjqqsmYslNWhmuI2aZJxQV3J5tH2Z1GI2epbEKmgz0e4%2BLhQS&amp;databasematch=Exchange%2BFileshare%2BSharePoint%2BMicrosoftTeams&amp;combine=Simple&amp;predict=true&amp;sort=DocumentCount&amp;anylanguage=true&amp;start=1&amp;documentcount=true&amp;valuerestriction=&amp;fieldname=TS%5FINDUSTRY%2CTS%5FCLASSIFICATION%2CDOCUMENT%5FMETADATA%5FFROM%5FSTRING%2CDOCUMENT%5FMETADATA%5FCREATOR%5FSTRING%2CTS%5FPOLICYTYPE%2CACCOUNT%5FNUMBEROFEMPLOYEES%2CIMPORTMAGICEXTENSION%2CACCOUNT%5FBILLINGCITY%2CDOCUMENT%5FMETADATA%5FHASATTACHMENTS%5FBOOLEAN%2CTS%5FNUMBER%2CDOCUMENT%5FMETADATA%5FAUTHOR%5FSTRING%2CTS%5FCONTAINER%2CDOCUMENT%5FKEYVIEW%5FCONTENTTYPE%5FSTRING%2CDOCUMENT%5FMETADATA%5FPRIORITY%5FSTRING%2CDOCUMENT%5FMETADATA%5FTO%5FSTRING&amp;maxvalues=5&amp;valuedetails=true&amp;ranges=&amp;text=%28virtual%20assistant%29&amp;actionid=c0043eda74acecc482431d323defe9a1ccff35be&amp;fieldtext=         </autn:request>         <autn:client>::1</autn:client>         <autn:time>01 Jul 20 12:41:23</autn:time>         <autn:duration>19.00 ms</autn:duration>         <autn:status>success</autn:status>         <autn:thread>2</autn:thread>     </logentry> 

I am trying to transform it so that I can get the value of securityinfo in the autn:request element and render it as a cell in the table. Here is my XSLT I have made progress on.

<?xml version="1.0"?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                 xmlns:autn="http://schemas.autonomy.com/aci/">     <xsl:output method="html" omit-xml-declaration="yes"/>     <xsl:template match="/">         <html>             <body>                 <h2>Audit information</h2>                 <table border="1">                     <tr bgcolor="#9acd32">                         <th>Date</th>                         <th>IP</th>                         <th>Action</th>                     </tr>                     <xsl:for-each select="autnresponse/responsedata/logentry">                         <tr>                             <td><xsl:value-of select="autn:time"/></td>                             <td><xsl:value-of select="autn:client"/></td>                             <td><xsl:value-of select="autn:action"/></td>                         </tr>                     </xsl:for-each>                 </table>             </body>         </html>     </xsl:template>  </xsl:stylesheet> 
Add Comment
2 Answer(s)

If you happen to be using a recent Saxon version, it’s

saxon:analyze-uri('http://dummy/?'||autn:request)?queryParams?securityinfo 
Add Comment

Try:

<xsl:value-of select="substring-before(substring-after(concat(autn:request, '&amp;'), 'securityinfo='), '&amp;')"/> 

This is assuming you are limited to XSLT 1.0. Otherwise you could use regex.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.