473,398 Members | 2,125 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,398 software developers and data experts.

XSLT Selecting characters in string

Allo,

I'm a little confused. I have an XSLT, in which my parser selects a
node, but I want to just capture the first two characters to a
variable. How would I do this? I know how to create the variable, but
I'm not sure how to take just the first two characters of the string.

Thanks,

RT Starid

Sep 26 '06 #1
3 1800
re*****@gmail.com wrote:
variable. How would I do this? I know how to create the variable, but
I'm not sure how to take just the first two characters of the string.
XSLT and XPath come with a function library that includes the
traditional substring function. Just set the variable to an XPath
expression that invokes it. For example, if you want the truncated value
of the current node's foo attribute, you could write

<xsl:variable name="myvar" select="substring(@foo,0,2)
http://www.w3.org/TR/1999/REC-xpath-...ring-Functions
(though it looks like there's a typo in one of the examples).

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Sep 26 '06 #2
<xsl:variable name="myvar" select="substring(@foo,0,2)
XPath is 1-based. Therefore, the expression to produce the substring,
consisting of the first two characters in the string value of @foo is:

substring(@foo, 1, 2)
Cheers,
Dimitre Novatchev
"Joseph Kesselman" <ke************@comcast.netwrote in message
news:45196e65$1@kcnews01...
re*****@gmail.com wrote:
>variable. How would I do this? I know how to create the variable, but
I'm not sure how to take just the first two characters of the string.

XSLT and XPath come with a function library that includes the traditional
substring function. Just set the variable to an XPath expression that
invokes it. For example, if you want the truncated value of the current
node's foo attribute, you could write

<xsl:variable name="myvar" select="substring(@foo,0,2)
http://www.w3.org/TR/1999/REC-xpath-...ring-Functions
(though it looks like there's a typo in one of the examples).

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

Sep 27 '06 #3
Dimitre Novatchev wrote:
XPath is 1-based. Therefore, the expression to produce the substring,
consisting of the first two characters in the string value of @foo is:
substring(@foo, 1, 2)
Whups. Yes, my bad. I'm coding in three languages at once these days,
and I got confused.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 27 '06 #4

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

Similar topics

1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
4
by: David Blickstein | last post by:
I have an application where I have a shared "method" of selecting a nodeset. The method currently is duplicated everywhere it is needed but I'd like that code to be shared. The method also...
4
by: | last post by:
Hi Guys, I am using XSLT to render my XML dataset at the client side to HTML code. When I am trying to load the XslTransform with an Xslt file, it gives me the following error. >>>> The...
2
by: Benzari.Alex | last post by:
Hello, the majority of my sites use PHP MYSQL and XSLT for dynamic pages and all of it works ok for English characters. The problem begins when I try to use Romanian or Russian characters while...
3
by: thomas.porschberg | last post by:
Hi, I want to read records from a database and export it in an arbitrary format. My idea was to feed a class with a String array fetched from the database and let this class fire SAX events as...
1
by: balderdash | last post by:
Hi I am very close to achieving the output I need but I cant seem to get it right. The problem is I am looping through a table and selecting values, if there are 2 values per (row) Issuer I...
3
by: ManWithNoName | last post by:
Hi! I am trying to load files that contain non-standard (and non-English) characters (e.g. µ), and need some help in understanding how the XSLT document() function interprets non-standard (and...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
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...
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.