Dear all: Is it possible to select a range of node using XSLT, for example, for the following XML: <test> <scan>1</scan> <scan>2</scan> <scan>3</scan> <scan>4</scan> <scan>5</scan> </test> How to select all scan element with text value less than 4. In other word, I want to select <scan>1</scan> <scan>2</scan> <scan>3</scan> by knowing incoming parameter value as 4. Any help, thanks in advance.
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
The first template generates the outer <test> element -- without this, the output would not be well-formed XML since it would contain multiple <scan> elements at the root level. The second template matches each <scan> element whose text value is less than 4. Note that in the predicate expression, I had to escape the less-than sign as < since "<" isn't allowed in an XML attribute value. The third template suppresses the default action of printing out the text value of all nodes. [ November 12, 2002: Message edited by: Ron Newman ]
Hi, Ron: Thank you very much for your reply!!! I think your method works to my above example. Can I further ask another question, is it possible if the value is not merely number, like the following: To select from: <test> <scan>1a</scan> <scan>2a</scan> <scan>3a</scan> <scan>4a</scan> <scan>5a</scan> </test> to get the following: <test> <scan>1a</scan> <scan>2a</scan> <scan>3a</scan> </test> using 4a as the criteria? Thanks again for your reply! guoqiao
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
You'll need to precisely define the format of that string, and then use the substring(), substring-before(), substring-after(), translate(), string-length(), and/or contains() functions to extract the numeric information from it. [ November 12, 2002: Message edited by: Ron Newman ]
Hi, Ron: Thank you very much! I think I got very helpful hint from your words. Thanks again and have a nice day there!!! Guoqiao
Originally posted by Ron Newman: You'll need to precisely define the format of that string, and then use the substring(), substring-before(), substring-after(), translate(), string-length(), and/or contains() functions to extract the numeric information from it. [ November 12, 2002: Message edited by: Ron Newman ]
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
Is that a spider in your hair? Here, threaten it with this tiny ad:
New web page for Paul's Rocket Mass Heaters movies