Short answer: it looks like you use XSLT with PHP (at least you tagged it PHP), but you are using JScript in the extension function, which is Microsoft, and you use msxsl:script
, which is also a Microsoft extension instruction.
Your extension function presently is illegal in XML, so you cannot possibly run the code above (you have an unescaped &
), so it should not run on any processor.
If you use PHP you are likely using libxslt, here's a tutorial. Not sure if you can use extension functions, but from the description I doubt you actually need any, as replacing characters in a value can be done without extension functions (use translate
).
strValue = strValue.replace('&','&');
This is an error, as mentioned above. But it looks like you try to prevent your stylesheet to output &
, which means you are trying to prevent your stylesheet from creating legal XML. This is a slippery slope, but if you really need it, simply use xsl:value-of
with disable-output-escaping
. The effect will only be visible if you actually serialize the output, though, and if the processor supports it (it is not required to do so).
Here's a question on exactly the same subject where I showed you how to resolve this the easy way. Perhaps you should try to first try the simple solution (just using XSLT) and only if that does not suffice, resort to a more complex solution (using extension functions)?
I have the impression that you are just starting out with XSLT and have a lot of questions. That is good. But it seems that these questions are related to understanding the basics of XML, which precludes understanding XSLT. There are plenty tutorials on XML and XSLT, give yourself some time to read up on those, as otherwise it may continue to be challenging and confusing.