0

I am trying to convert the following URI parameters and respective values, using substring function. but it is giving error, obvious because it is not a string.
FROM: http://host/URI/api/abc/xml?xxx=a-b-c&pqr=123
TO: http://host/URI/api/abc/xml?yyy=d-e-f&pqr=123

Input is from a variable.

XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:func="http://exslt.org/functions" xmlns:str="http://exslt.org/strings" xmlns:dpfunc="http://www.datapower.com/extensions/functions" xmlns:dpconfig="http://www.datapower.com/param/config" xmlns:regexp="http://exslt.org/regular-expressions" extension-element-prefixes="dp func dpfunc dpconfig regexp" exclude-result-prefixes="dp func dpfunc dpconfig regexp">
  <xsl:template match="/">
    <xsl:variable name="currentURI" select="dp:variable('var://service/URI')"/>
    <xsl:variable name="new-uri" select="regexp:replace($currentURI, 'xxx', 'yyy')"/>
    <xsl:variable name="SubStringBeforeyyy" select="substring-before($new-uri, 'yyy=')"/>
    <xsl:variable name="SubStringAfteryyy" select="substring-after($new-uri, '&' )"/>  <!-- ERROR: -->
    <xsl:variable name="NewParmValue" select="'d-e-f'"/>
    <xsl:variable name="NewURI" select="concat($SubStringBeforeyyy, $NewParmValue, $SubStringAfteryyy)"/>
  </xsl:template>
</xsl:stylesheet>

Error from xmlSpy is:

XML Production Error: Character ''' within text ''' does not fulfill production 'Name'.

2
  • Please show us a minimal but complete stylesheet together with the XML input that causes the error. Commented Mar 3, 2017 at 21:01
  • Please show us the XSLT code you have that is causing the error you say you get. Commented Mar 3, 2017 at 21:12

1 Answer 1

2

XSLT is XML, so to write an ampersand(&) character you need to use

<xsl:variable name="SubStringAfteryyy" select="substring-after($new-uri, '&amp;' )" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.