I have a problem writing my XSL. I have a link with the following code:
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat($myUrl,'&projectNumber=',$projectNumber)"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="title"/>
</xsl:attribute>
LINK
</a>
So I need to pass a variable projectNumber
to the end of myUrl
. This works just fine and I get ...myUrl...&projectNumber=...projectNumber...
in HTML.
The problem is, that the variable projectNumber
sometimes has some characters which have to be escaped in the href of my link. I tried using the XSL function str:escape-uri()
in many different ways, but still no success...
For example if myUrl is www.example.com/example.aspx?a=b
and projectNumber is aaaūaaa
I get href like www.example.com/example.aspx?a=b&projectNumber=aaaūaaa
, but I need to get www.example.com/example.aspx?a=b&projectNumber=aaa%C5%ABaaa
. (%C5%AB
is the way that 'ū' is escaped) Any suggestions? Thanks.
Specifies the format pattern. Here are some of the characters used in the formatting pattern: 0 (Digit) # (Digit, zero shows as absent)
XSLT is used for transforming XML to XML (either according to a different data model, or by, for example, filtering some data), or into an HTML or text document. These transformations require an XSLT processor, which processes one or more XML documents with an XSLT stylesheet to produce an output document.
contains() Function — Determines if the first argument string contains the second.
If you are using XSLT 1.0, then refer this.
In case of XSLT 2.0, you may use this to solve the issue.
<xsl:value-of select="concat($myUrl,'&projectNumber=',encode-for-uri($projectNumber))"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With