Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2013, 08:26 AM
Registered User
 
Join Date: Jun 2013
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default String Validation Using XSLT

I have some requirement which should validate the string. My requirement is:

1. if the given string length is less than 5, throw an error.
2. if the string is longer than 5, then break the string into substrings of length of 6. Test the Substring.
-> the substring last value should end with ; or |. i.e., 6th character.
-> if the value at position 0 or 4 are a whitespace throw an error.
-> if the value at position 0 thru 4 is something other than alphanumeric character or whitespace or '@' symbol, throw an error.
if there are more substring, repeat the process.

How to obtain this.
sample xml file is:
Code:
<sample>
<row>
   <comment>
      <value>ABCDE</value>
   </comment>
</row>
<row>
   <comment>
      <value>ABCDE;ABCDE</value>
   </comment>
</row>
</sample>
if u need more info, kindly let me know.
 
Old June 21st, 2013, 08:37 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

First, it makes a big difference whether you are using XSLT 1.0 or 2.0 - you need to say.

Secondly, please don't just ask people to write the code for you. You need to explain what you have tried and where you got stuck. I'm here to help you solve the problem, not to present you with the solution on a plate, and I can't help you solve it if I have no idea why you are finding it difficult.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old June 21st, 2013, 09:48 AM
Registered User
 
Join Date: Jun 2013
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I did the above validation step in the javascript. It is working fine. I dont know know how to implement the same in xml.
 
Old June 21st, 2013, 10:44 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Then read my book, and tell me which parts you don't understand.

You'll want to understand functions such as concat(), substring(), tokenize() etc and perhaps xsl:analyze-string.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following 2 Users Say Thank You to mhkay For This Useful Post:
bonekrusher (June 22nd, 2013), elango271986 (June 21st, 2013)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Validation from String iceandrews XSLT 4 May 14th, 2008 07:25 AM
xslt -> xhtml validation rahulsk1947 XSLT 3 May 17th, 2007 02:54 AM
String in XSLT sani723 XSLT 4 March 8th, 2007 09:51 AM
checking string length for form validation Tachyon Beginning PHP 1 June 14th, 2004 08:16 PM
string validation john_reeve41 Beginning VB 6 3 March 3rd, 2004 01:41 PM





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