Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 11th, 2013, 02:48 PM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Unhappy xsl select only if there are only 3 numbers after a period

Hi,

i've the below piece of xml code.

HTML Code:
<para>
A testator may by will appoint any number of executors that he chooses, but s.25 of the PAO provides that probate or administration shall not be granted to more than four persons in respect of the same property. Where only one or some of the executors apply for probate, power can be reserved to the other or others to apply subsequently if necessary to complete the administration of the estate. As noted above (para.2.027), where this happens the death of the proving executor will not result in a transmission of the office to his executor. The originally appointed other executor will, if he subsequently proves, prevent the necessity for any chain of executors. </para>

here i want to select the number only if there are 3 numbers after '.'. but not less than it or greater than it. i've using the below template, but it is not giving the right result.

HTML Code:
<xsl:template match="para">
<xsl:apply-templates/>
</xsl:template>

 <xsl:template match="text()">
    <xsl:choose>
      <xsl:when test="not[contains(substring(substring-after(text(),'.'),1,3),'')]">
<a href="substring(substring-after(text(),'.'),1,3)">
<xsl:value-of select="substring(substring-after(text(),'.'),1,3)"/>
</a>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

please let me know how to achieve this.

Thanks
Reply With Quote
  #2 (permalink)  
Old June 11th, 2013, 03:18 PM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Are you using XSLT 1.0 or 2.0?
Reply With Quote
  #3 (permalink)  
Old June 11th, 2013, 03:35 PM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Default

i use xslt 1.0
Reply With Quote
  #4 (permalink)  
Old June 12th, 2013, 03:51 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It would be useful to know what the desired output is.

This kind of string manipulation is very easy in XSLT 2.0 using regular expressions, it's much harder in XSLT 1.0. Are you really sure you can't move to XSLT 2.0?
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #5 (permalink)  
Old June 12th, 2013, 04:38 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hi Mckay,
i cannot move this to xslt 2.0 as my entire code needs to be manipulated, please let me know how do i do it xslt1.0.

Thanks
Reply With Quote
  #6 (permalink)  
Old June 12th, 2013, 04:56 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sorry, I don't do XSLT 1.0 any more. Too much like hard work, especially for this kind of problem.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping between the numbers using Xsl:for each? kvbhaskar7 XSLT 1 November 8th, 2011 06:00 PM
XSL: How to get javascript function return SELECT value in xsl ojoker XSLT 5 May 24th, 2011 11:52 AM
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
regarding adding numbers in xsl umair.aziz XSLT 1 June 24th, 2006 12:12 PM
Splitting numbers in XSL francislang XSLT 2 September 15th, 2004 05:34 AM



All times are GMT -4. The time now is 10:47 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.