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 23rd, 2011, 07:22 PM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default Defining a Constraint for a 2-Value Element

Hello,

If I an XML structure that looks like:

- <sa:position>
- <gml:Point>
<gml:pos srsName="urn:ogc:def:crs:EPSG:4326">100.0 50.0</gml:pos>
</gml:Point>
</sa:position>

, how would constrain the latitude/longitude (in this case 50.0/100.0)? For instance, if I wanted the find an object with a latitude of < 100.0 and a longitude of < 50.0?

Any response is appreciated. thanks!
 
Old February 23rd, 2011, 08:05 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If it's a schema-aware XSLT 2.0 transformation then the element will be atomized as a list of decimals and you can do

Code:
gml:pos[data(.)[1] lt 50 and data(.)[2] gt 100]
But sadly, I suspect it isn't.

Without it you're stuck with something like

Code:
gml:pos[number(substring-before(., ' ')) &lt; 50 and number (substring-after(., ' ')) &gt; 100]
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old March 8th, 2011, 01:43 PM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default apologies for delay in response

thanks so much my friend. I used your hint some time ago, and forgot to respond. Indeed the second solution (not XSLT 2.0) worked great!

Always impressed with the time and energy you take for us.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 9: Element[user control] is not a known element Arya BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 December 20th, 2009 07:31 AM
Defining restrictions based on element/attribute values aldwinenriquez XML 3 May 13th, 2009 03:55 AM
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
Can I have a constraint like this.....? callagga SQL Language 7 August 13th, 2008 01:08 AM
help with defining in the database derrida BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 April 14th, 2007 03:17 AM





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