Hi, I've a simple issue with the use of extension objects.
I'm trying to call a text formating method from an object that I add to
my arguments collection, this method take an input string and output
the formatted string.
So far everything process correctly (the method is called without any
issue) but my problem is that the output is htmlencoded, it means that
my method (wich work as intended in other contexts) is called but the
output is automatically encoded (& become & etc.)
If you need further explanation here is a simple testcase that
illustrate my issue:
Main.cs
================================
using System;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
class XSLTSimpleTest
{
static void Main()
{
XPathDocument xmldoc = new XPathDocument(new
System.IO.StringReader("<doc/>"));
XslTransform xslt = new XslTransform();
xslt.Load("test.xslt");
XsltArgumentList args = new XsltArgumentList();
args.AddExtensionObject("myObjects:DotNetString"," Lorem ipsum...");
// this Transform method signature is obsolete, but only used for
demonstration purpose
xslt.Transform(xmldoc, args, Console.OpenStandardOutput());
args.Clear();
args.AddExtensionObject("myObjects:DotNetString"," Lorem
<em>ipsum...</em>");
xslt.Transform(xmldoc, args, Console.OpenStandardOutput());
}
}
================================
test.xslt
================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:DotNetString="myObjects:DotNetString">
<xsl:template match="/*">
<strong><xsl:value-of select="DotNetString:Substring(0, 1)"
/></strong><xsl:value-of select="DotNetString:Substring(1)" />
</xsl:template>
</xsl:stylesheet>
================================
the output of this program is (it isn't event a valid xml doc...):
================================
´++<?xml version="1.0" encoding="utf-8"?>
<strong xmlns:DotNetString="myObjects:DotNetString">L</strong>orem
ipsum...´++<?
xml version="1.0" encoding="utf-8"?>
<strong xmlns:DotNetString="myObjects:DotNetString">L</strong>orem
<em>ips
um...</em>
================================
where I would want:
================================
´++<?xml version="1.0" encoding="utf-8"?>
<strong xmlns:DotNetString="myObjects:DotNetString">L</strong>orem
ipsum...´++<?
xml version="1.0" encoding="utf-8"?>
<strong xmlns:DotNetString="myObjects:DotNetString">L</strong>orem
<em>ips
um...</em>
================================
So anyone's help would be appreciated.
Thanks
Gauthier Segay