473,667 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLTransformati on problem

Hi,

sorry if this is cross post.. I have a simple XSLTransformati on which I am
trying to load it in XSLTransform class as indicated below

loading xsl :

XslTransform tran = new XslTransform();
tran.Load(@"C:\ AV\DotNet Projects\Replac eString.xsl");

but the problem is its always giving the following errors when I load..
1. '' is an invalid QName - I have kind of resolved this by using { } for
accessing params.
2. boolean(contain s({$str},{$from }) is an invalid XPath expression. - i am
not sure why this is an invalid xpath.

please do help.

ReplaceString.x sl :
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:call-template name="replace-string">
<xsl:with-param name="str" select="Str"></xsl:with-param>
<xsl:with-param name="from" select="From"></xsl:with-param>
<xsl:with-param name="to" select="To"></xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="replace-string">
<xsl:param name="str"/>
<xsl:param name="from"/>
<xsl:param name="to"/>
<xsl:if test="contains( {$str},{$from}) ">
<xsl:call-template name="">
<xsl:with-param name="str" select="substri ng-before({$str},{ $from})"/>
<xsl:with-param name="from" select="substri ng-after({$str},{$ from})"/>
<xsl:with-param name="to" select="$to"/>
</xsl:call-template>
</xsl:if>
<xsl:value-of select="concat( {$str},{$to})"/>
</xsl:template>
</xsl:stylesheet>

thank you,
Av.
Nov 16 '05 #1
1 1194
Well this is an XSL question rather than a C#-question.

But to my knowledge the solution is very simple:
contains, substring-before, substring-after and concat are does not handle
params inclosed in {}. instead you would simply do this: concat($str, $to).

You would only use { and } in situations like this:
<xsl:element name="{concat($ str, $to}">stuff in element</xsl:element>

What { and } does is to tell the XSL parser that everything in between is
XSL-commands of a kind. Why is that needed? Well in the displayed example
the parser would expect a valid QName and "concat($st rm $to)" isn't - so by
using {} we tell the parser to use the result of the commands in the
brackets instead.

/rap

"avnrao" <av*@newsgroups .com> wrote in message
news:Ot******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

sorry if this is cross post.. I have a simple XSLTransformati on which I am
trying to load it in XSLTransform class as indicated below

loading xsl :

XslTransform tran = new XslTransform();
tran.Load(@"C:\ AV\DotNet Projects\Replac eString.xsl");

but the problem is its always giving the following errors when I load..
1. '' is an invalid QName - I have kind of resolved this by using { } for
accessing params.
2. boolean(contain s({$str},{$from }) is an invalid XPath expression. - i am
not sure why this is an invalid xpath.

please do help.

ReplaceString.x sl :
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:call-template name="replace-string">
<xsl:with-param name="str" select="Str"></xsl:with-param>
<xsl:with-param name="from" select="From"></xsl:with-param>
<xsl:with-param name="to" select="To"></xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="replace-string">
<xsl:param name="str"/>
<xsl:param name="from"/>
<xsl:param name="to"/>
<xsl:if test="contains( {$str},{$from}) ">
<xsl:call-template name="">
<xsl:with-param name="str" select="substri ng-before({$str},{ $from})"/>
<xsl:with-param name="from" select="substri ng-after({$str},{$ from})"/>
<xsl:with-param name="to" select="$to"/>
</xsl:call-template>
</xsl:if>
<xsl:value-of select="concat( {$str},{$to})"/>
</xsl:template>
</xsl:stylesheet>

thank you,
Av.

Nov 16 '05 #2

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

Similar topics

117
7188
by: Peter Olcott | last post by:
www.halting-problem.com
5
1561
by: Loren Dummer | last post by:
I have an XSLTransformation question I hope someone can help me with. I am trying to program this using VB.Net. I currently have a VB6.0 application which I am converting into VB.Net. The last piece of code I have to convert is an XML transformation. What I am trying to do is take two sting values sXML and sXSL. Take the sXML value, transform it with the sXSL value and return the results as a string. I currently have it working when...
28
5203
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I don't know at runtime what the child class is? I'm using Activator.CreateInstance() to load the...
1
967
by: avnrao | last post by:
Hi, sorry if this is cross post.. I have a simple XSLTransformation which I am trying to load it in XSLTransform class as indicated below loading xsl : XslTransform tran = new XslTransform(); tran.Load(@"C:\AV\DotNet Projects\ReplaceString.xsl");
0
8366
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8565
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.