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 February 9th, 2005, 06:53 PM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Syntax help with string-length and XPath

I don't know if this is possible, but here's what I need to do:

Find the ancestor element named PEDiv whose ID attribute is only 2 digits and begins with the letter 'a'.

What would the syntax for this be? I know how to find the string length of a specific element's ID

string-length(//PETOC/PEDiv[1]/PEDiv[2]/@id) --this returns 2

but not how to find an element whose ID is a specific length.

 
Old February 9th, 2005, 08:02 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

ancestor::PEDiv[string-length(@ID) = 2 and substring(@ID, 1, 1) = 'a']

easy when you know how!

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fix string length Ivanchan Excel VBA 2 July 26th, 2007 08:55 AM
string-length problem alapati.sasi XSLT 3 July 4th, 2007 10:08 AM
XPST0081: XPath syntax error ... with Saxon markus2000 XSLT 3 June 22nd, 2006 09:53 AM
Chap 3, "Length of String" richajos BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 February 25th, 2006 08:38 PM
xpath syntax problem nrane26 XSLT 1 January 22nd, 2005 01:25 PM





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