472,984 Members | 2,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 software developers and data experts.

Simple issue with XSLT Extension Objects

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
&lt;em&gt;ips
um...&lt;/em&gt;
================================

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
Nov 12 '05 #1
4 1927
Hello, Gauthier!
You wrote on Thu, 08 Apr 2004 21:33:19 -0700:
[Sorry, skipped]

Modify the xslt with

<xsl:value-of select="DotNetString:Substring(1)"
disable-output-escaping="yes"/>

With best regards, Alex Shirshov.
Nov 12 '05 #2
g
Thanks Alex!

Needless to say that I'm a XSLT newbie ;)

Gauthier Segay

Alex Shirshov wrote:
Hello, Gauthier!
You wrote on Thu, 08 Apr 2004 21:33:19 -0700:
[Sorry, skipped]

Modify the xslt with

<xsl:value-of select="DotNetString:Substring(1)"
disable-output-escaping="yes"/>

With best regards, Alex Shirshov.


Nov 12 '05 #3
As a side note, this works only when using something other than
XmlTextWriter, because it seems to enforce encoding.

So I've switched to a simple StreamWriter that keep my bits running
without encoding.

Since it took me some correct/rebuild steps to figure it out, it's
better to report it here with accessible keywords as message subject :)

Gauthier Segay
Nov 12 '05 #4
Gauthier wrote:
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 &amp; etc.)


Return it as XPathNodeIterator (represents XPath's nodeset) instead of
string to avoid output encoding.
Otherwise use disable-output-escaping (beware it's ignored when
transforming to XmlWriter ot XmlReader).

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gordan | last post by:
I'm running Apache/1.3.33 (Win32) PHP/5.0.4 on WinXP in my php.ini I uncommented the extension=php_xsl.dll line. When running phpinfo() I have the following section on XSL xsl XSL enabled...
7
by: RC | last post by:
First, let me say I couldn't find a group discuss XML/XSLT. So I only choose the closest groups to post this message. Here is part of my *.xsl file <xsl:stylesheet...
1
by: Diego Rivero | last post by:
Hi. I'm working with the XsltTransform class and I found that invocations to extension objects are extremely time consuming in contrast to invocations to embebed code using "msxsl:script"...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
by: Yarik | last post by:
Hello, I am not sure the subject of my post adequately describes the problem I am trying to solve, so I think a specific example would be helpful. Let's say there are XML descriptions of...
1
by: =?Utf-8?B?UHJhc2hhbnQgQw==?= | last post by:
Hi All, Is it possible to query database in XSLT? or pass value to XSLT through C# or VB.NET -- Regards, Prashant C
3
by: WideBoy | last post by:
Hi, I have a software generated schema which creates a few empty elements, e.g. <xsd:sequence/>. I would like to be able to delete these elements from the schema post-generation using XSLT. ...
11
by: Ebenezer | last post by:
Let's suppose I have some nodes in an XML file, with an URL attribute: <node url="mypage.php?name1=value1&foo=bar&foo2=bar2&name2=value0" /> <node...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.