Numeric Encode xlst Transform

Topics: Developer Forum, User Forum
Sep 13, 2007 at 6:00 AM
Hi,

I have a simple xsl transform below:

private static void testtransform()
{
try
{
MvpXslTransform xslt = new MvpXslTransform();
xslt.Load("test.xsl");
XsltArgumentList argList = new XsltArgumentList();
xslt.Transform(new XmlInput("in.xml"), argList, new XmlOutput("out.xml"));
}
catch (Exception ex)
{
}
}

in.xml is UTF-8 encoded.

test.xsl specifies US-ASCII encoding (<xsl:output method="xml" version="1.0" encoding="US-ASCII" indent="yes"/>).

As a result, when I do a transform, it generates the below error:

Unable to translate Unicode character \u201C at index 293 to specified code page. at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
...

Instead, I would like it to numeric encode what falls outside the ASCII code page. Looking at the documentation, it appears that I could do something with WriteCharEntity, but am uncertain how to do so.

Any help would be appreciated.

Thanks,

Alex
Coordinator
Sep 29, 2007 at 6:36 PM
MvpXslTransform doesn't support this feature. Here is a sample implementation you can follow:

http://www.tkachenko.com/blog/archives/000266.html