Page 1 of 1

Using function from different namespace

Posted: Mon Mar 21, 2022 12:15 pm
by albrjens
Hi,
I have a problem with this regex function for getting the ticket ID from the subject of an email

Code: Select all

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
				xmlns:fn="http://www.w3.org/2005/xpath-functions">

.............................
			<xsl:variable name="aaVendorIncidentNumber">
				<fn:analyze-string select="$emailSubject" regex="\[Ticket\d{{10}}\]">
					<fn:matching-substring>
						<xsl:value-of select="."/>
					</fn:matching-substring>
				</fn:analyze-string>
			</xsl:variable>
....................
Input:

Subject: Re: [Ticket0123456789] Testmail

Expected Result: aaVendorIncidentNumber -> [Ticket0123456789]
Instead of the Matching Substring I get the hole emailbody. I suggest it has something to do with the different namespaces.
How can I edit it correctly?
Info: I don't know why but the x-path functions are not available in namespace xsl

Re: Using function from different namespace

Posted: Wed Mar 23, 2022 4:55 pm
by Mircea
Hello,

Please consider using the following code for your implementation:

Code: Select all

<xsl:variable name="aaVendorIncidentNumber">
  <xsl:value-of select="fn:analyze-string($emailSubject,'\[Ticket\d{10}\]')/fn:match"/>
 </xsl:variable>
Please note that the fn:analyze-string() function returns as a result a fn:analyze-string-result element.

Regards,
Mircea.