XSLTransform.Transform() doesn't work!

G

Guest

Hello,

I am using translate in my .xslt to remove the space like this:

<xsl:for-each select=".//Illustration">
<xsl:value-of select="translate(./@illusName, ' ', '')"/>

But this doesn't seem to work when i use the Transform() of .NET. The above
works well with command line msxsl and XMLSpy.

I also tried the following workarounds, but it still doesn't work:
<xsl:element name="{translate(@value1, ' ', '')}">
<xsl:value-of select="translate( (./@illusName, ' ', '')"/>

Is this a known problem with .NET. Plz help!
 
M

Marc Gravell

Well, from what I can see it shouldn't work in the others... first:
you have an odd number of brackets in the second line; second:
translate converts characters from the first array into the
corresponding (by index) from the second, e.g. (from w3schools):

<quote>Example: translate('12:30','30','45')
Result: '12:45'

Example: translate('12:30','03','54')
Result: '12:45'

Example: translate('12:30','0123','abcd')
Result: 'bc:da'</quote>

It is *not* the same as "replace"; look at the "replace" function...

Also : ".//element" and "./@attrib" are usually just "//element" and
"@attrib"

Marc
 
M

Marc Gravell

(ignore my "number of brackets" remark; the *entire* workaround
example (OP) is just plain wrong; don't use any of this "workaround")
 
K

Kevin Spencer

The translate function takes 3 strings as arguments. you are passing a node
or attribute into it. Use the string() function to transform the node or
attribute to a string.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top