473,473 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1957
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: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.