torsten's .NET blog In the end, everything is a gag [Ch. Chaplin]
# Friday, December 01, 2006
Strange XSL Transform Exception - figured out

Recently we migrated our software dev. to use CLR 2.0. One part of the migration was to rework the usage of XslTransform class to the new XslCompiledTransform class. Reading the "Migrating From the XslTransform class" MSDN paper, it was not much work, just minutes. But then I got this strange exception:

Cannot transform XML using stylesheet 'transform.xslt.'
Exception: Extension function parameters or return values which have Clr type 'ConcatString' are not supported.

This really took me a half day to track it down! First, I did the usual things like reading more carefully the MSDN docs (my wrong direction: security issues), google'd for it and found at least one topic about. This was the right direction to solve it, but I tried various other things to get around - inclusive a complete redesign of the transformation code not using any stylesheet scripts. At last I was more confused (introduced other errors) than as I started, so I reverted the most unrelated changes. After reading the more interesting post "Introducing XslCompiledTransform" and IM'ed with a OS project coworker it gets more clear to me what happens: the System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltResult(XmlQueryType xmlType, Object value) visible in the call stack try to make my <msxsl:script language="JScript" ...> functions to return strong types - but: only the top level functions called from XSL element! Here is the non-working stylesheet code sample:

<msxsl:script language="JScript" implements-prefix="local"><![CDATA[
   
    function fmtDate(val, fmtmask)
    {

   var s = "" + val; 
   ...
   return formatDate(new Date(s.substring(0,4),s.substring(4,6)-1,s.substring(6,8)), fmtmask);
    }
    function formatDate(varDate, bstrFormat)
    {
...
return "" + formattedDate;
}
]]></msxsl:script>

And this is the working one:

<msxsl:script language="JScript" implements-prefix="local"><![CDATA[
   
    function fmtDate(val, fmtmask)
    {

   var s = "" + val; 
   ...
   return "" + formatDate(new Date(s.substring(0,4),s.substring(4,6)-1,s.substring(6,8)), fmtmask);
    }
    function formatDate(varDate, bstrFormat)
    {
...
return "" + formattedDate;
}
]]></msxsl:script>

You notice the small but important difference? Now the stylesheet compiler consider my return value correctly as a string. Whoa...

Technorati tags:  | 
Friday, December 01, 2006 8:58:49 AM (W. Europe Standard Time, UTC+01:00)    #  Comments [1]  | 
# Wednesday, April 14, 2004
Sign of live

Very busy the last days: spent time with my family on easter, finished the work to prepare our product for the chinese market and prepared my car for the summer time (spring finery).

That TeXML: an XML vocabulary for TeX sounds cool: now somebody can write a Word-XML/OpenOffice-XML to TeXML to TeX converter with the help of XSLT only. The power of XML spreads the world...

Rss Bandit UI translation goes on: now we have russian, chinese (simplified) and german 100% done! Thanks to Oleg, Ryan Ma for their work!

Technorati tags:  |  | 
Wednesday, April 14, 2004 9:21:39 AM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
# Wednesday, July 02, 2003
Translating RSS with XSLT

ScottW points here to an article of Jeff Julian. But this is only the first step. One step further you ends up at bloglines.

Update: Thanks Jeff - I refreshed the link targets!

Technorati tags:  |  | 
Wednesday, July 02, 2003 12:02:04 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [2]  | 
# Saturday, April 26, 2003
It's a hack?
Everything familar with MSXML3 and transformations know about a "feature" of the : it cannot output something without escaping. And the story goes on for .NET. If you have to produce html with xml transform you have a big problem: you get a correcly url formatted link within the xml source that you have to write to an <A>element as the href attribute. How about "&" signs in the url? They are escaped with "&" which result in wrong formatted url's. The normal way you can use to write element content to html output without escaping:

<xsl:value-of select="urlElement" disable-output-escaping="yes"></xsl:value-of>

Now the non-working version to write a valid <A> element:

<A><xsl:attribute name="href"><xsl:value-of select="urlElement" disable-output-escaping="yes"/></xsl:attribute>Link</A>

And here is the code to work around (name it a hack):

<xsl:text disable-output-escaping="yes">&lt;a href='</xsl:text><xsl:value-of disable-output-escaping='yes' select=url'/><xsl:text>'></xsl:text>Link Text<xsl:text disable-output-escaping='yes'>&lt;/a></xsl:text>

Technorati tags:  | 
Saturday, April 26, 2003 10:34:14 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
# Friday, March 28, 2003
Fighting XslTransform
Yesterday it took me several hours to figure out how to get XslTransform work with output-escaping. I had thought, it should not be a problem to implement it based on my experiences with our intranet app. It uses .asp to get some xml from a BL Layer and transform it using the MSXML Parser and some xslt. There I can transform a DOM and get back a DOM and output-escaping is not a problem. Now moved it up to .NET XslTransform it does not work this way. Thanks to Prajakta Joshi [@microsoft.com] 's post I have learned to use a Stream as output, then read the stream back with StreamReader to get the string I need. Has that to be?
Technorati tags:
Friday, March 28, 2003 9:11:02 AM (W. Europe Standard Time, UTC+01:00)    #  Comments [1]  | 
Navigation

Like RSS Bandit? Make a donation to help support its development and maintenance. As little as 1€ will help.

Make payments with PayPal - it's fast, free and secure!
On this page....
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

SUBSCRIBE RSS GeoURL e-mail

Search
Categories
Blogroll
[Feed] Dare Obasanjo
Dare Obasanjo aka Carnage4Life
[Feed] Clemens Vasters
[Feed] Omar Shahine
[Feed] Tom Mertens

newtelligence dasBlog 2.1.8102.813

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

WOT Notar

Join WebHost4Life.com