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

XSLT regexp?

Is there a shorthand for this:

<xsl:when test="$day2[.='1'] or $day2[.='2'] or $day2[.='3']">

Jul 20 '05 #1
6 5461


Mark Johnson wrote:
Is there a shorthand for this:

<xsl:when test="$day2[.='1'] or $day2[.='2'] or $day2[.='3']">


Your subject line asks for regexp support, that doesn't exist in XPath
1.0 respectively XSLT 1.0.
XPath 2.0 introduces that, see
http://www.w3.org/TR/xquery-operators/#string.match
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin Honnen <ma*******@yahoo.de> wrote:
Mark Johnson wrote:
Is there a shorthand for this: <xsl:when test="$day2[.='1'] or $day2[.='2'] or $day2[.='3']">

Your subject line asks for regexp support
Patterns, such as you'd find in regexp. Otherwise, I have to
separately test against all 9 digits to see if a field is a base-10
symbol, not incl. 0. Too bad there isn't a shorthand, for it.

The alternative, of course, is just to run out to a msxml call, and
use regexp in the jscript. But . .

that doesn't exist in XPath
1.0 respectively XSLT 1.0.
XPath 2.0 introduces that, see
http://www.w3.org/TR/xquery-operators/#string.match


A FEB 2004 working draft? I can assume msxml does yet include all of
these interesting functions?
Jul 20 '05 #3


Mark Johnson wrote:
Martin Honnen <ma*******@yahoo.de> wrote:

that doesn't exist in XPath
1.0 respectively XSLT 1.0.
XPath 2.0 introduces that, see
http://www.w3.org/TR/xquery-operators/#string.match

A FEB 2004 working draft? I can assume msxml does yet include all of
these interesting functions?


MSXML 3 and 4 implement XPath 1.0 and XSLT 1.0, I don't know whether MS
has any plans to update MSXML at all to cover newer standards, it could
well be that only .NET is going to cover the newer standards. I think
..NET 2.0 has some XQuery support but it is not yet publically available.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4
Mark Johnson <10*******@compuserve.com> writes:
Is there a shorthand for this:

<xsl:when test="$day2[.='1'] or $day2[.='2'] or $day2[.='3']">


How about this?

<xsl:when test="contains('123', string($day2))">

There's not really enough context to see what $day2 is, but in XSLT
1.0 it can only be a Result Tree Fragment (see
http://www.w3.org/TR/xslt#section-Result-Tree-Fragments) on which it
is not permitted to use the [] operator. So your code is not
conforming to XSLT 1.0 anyways. I believe you code should be:

<xsl:when test="$day2='1' or $day2='2' or $day2='3'">

in order to conform to XSLT 1.0.

You might want to take a look at the book "XSLT and XPath On The Edge"
by Jeni Tennison. She lists lots of goodies in XPath and XSLT.

Regards, kga
Jul 20 '05 #5
Mark Johnson wrote:
Is there a shorthand for this:

<xsl:when test="$day2[.='1'] or $day2[.='2'] or $day2[.='3']">


<xsl:when test="$test2[.&gt;=1 and .&lt;=3]">

Off topic because you seem to use MSXML, but transformers like Xalan offer a
simple way to implement regular expressions from Java packages like Jakarta
ORO by defining a name space, e.g.:

<xsl:stylesheet
...
xmlns:regex="xalan://com.company.RegExpWrapper">

Which can be applied in the stylesheet as follows:

<xsl:if test="regex:testExp('^\d+$', '0123456789')">
<xsl:text>Match</xsl:text>
</xsl:if>

Where testExp is a method in the RegExpWrapper class.
JW

Jul 20 '05 #6
"Janwillem Borleffs" <jw@jwscripts.com> wrote:
Mark Johnson wrote:
Is there a shorthand for this: <xsl:when test="$day2[.='1'] or $day2[.='2'] or $day2[.='3']">
<xsl:when test="$test2[.&gt;=1 and .&lt;=3]">
Yes, that would be it. When one sees it, it's - d'uh!

Off topic because you seem to use MSXML, but transformers like Xalan offer a
simple way to implement regular expressions from Java packages like Jakarta
ORO by defining a name space, e.g.: <xsl:stylesheet xmlns:regex="xalan://com.company.RegExpWrapper"> Which can be applied in the stylesheet as follows: <xsl:if test="regex:testExp('^\d+$', '0123456789')">
<xsl:text>Match</xsl:text>
</xsl:if> Where testExp is a method in the RegExpWrapper class.


That is more direct and neater than an msxml call. But I do have
regexp in msxml calls. It's not that complicated. But it is integrated
directly into Microsoft office and suite. You can use loadxml and
transform right in VB or whatever code, which many need to do.

How would run load and transform, in Visual Basic, using Xalan? Would
have to save the xml, first, as a file, and then call some
'wrapper'/cover module to transform?
Jul 20 '05 #7

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

Similar topics

10
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1:...
5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
4
by: matatu | last post by:
Hi to all, I have a xml file, a substring like: &lt;a href=&quot;#&quot;&gt;text&lt;/a&gt; which after an xslt trasform is rendered as (using xsl:output method html): &lt;a...
4
by: el_bandido | last post by:
Hello, I've tried the FAQ and some minutes in googl'ing but was not happy with what I got. Basically I'd like to get a _simple_ example on how I could create a web based (portable across all...
0
by: Chris Croughton | last post by:
I'm trying to use the EXSLT regexp package from http://www.exslt.org/regexp/functions/match/index.html (specifically the match function) with the libxml xltproc (which supports EXSLT), but...
4
by: Jon Maz | last post by:
Hi All, I want to strip the accents off characters in a string so that, for example, the (Spanish) word "práctico" comes out as "practico" - but ignoring case, so that "PRÁCTICO" comes out as...
26
by: Matt Kruse | last post by:
Are there any current browsers that have Javascript support, but not RegExp support? For example, cell phone browsers, blackberrys, or other "minimal" browsers? I know that someone using Netscape...
1
by: jrwarwick | last post by:
Hello, I believe I have uncovered a bug in the .Net XSLT engine to do with 'for' loops in XSLT. Here are the steps to reproduce it: -Create A new webform project. -Add the xml file...
4
by: Matt | last post by:
Hello all, I have just discovered (the long way) that using a RegExp object with the 'global' flag set produces inconsistent results when its test() method is executed. I realize that 'global'...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.