473,396 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

XSLTransformation problem

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");

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(contains({$str},{$from}) is an invalid XPath expression. - i am
not sure why this is an invalid xpath.

please do help.

ReplaceString.xsl :
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet 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="substring-before({$str},{$from})"/>
<xsl:with-param name="from" select="substring-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 1187
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($strm $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**************@TK2MSFTNGP09.phx.gbl...
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");

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(contains({$str},{$from}) is an invalid XPath expression. - i am
not sure why this is an invalid xpath.

please do help.

ReplaceString.xsl :
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet 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="substring-before({$str},{$from})"/>
<xsl:with-param name="from" select="substring-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
by: Peter Olcott | last post by:
www.halting-problem.com
5
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...
28
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();...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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
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,...

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.