[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: comparing sequences that contain more than one of

Subject: RE: comparing sequences that contain more than one of the same item
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 22 Feb 2008 14:58:42 -0000
RE:  comparing sequences that contain more than one of
Sort the characters in the long string into code point order

farmer => aefmrr

Turn this into a regular expression in which each character is optional

a?e?f?m?r?r?

Sort the characters in the short string into code point order, and test
whether the result matches this regular expression.

You could start with a quick filter:

translate($short, $long, '') = '' 

will be false if $short contains a character that is not present in $long.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Andrew Welch [mailto:andrew.j.welch@xxxxxxxxx] 
> Sent: 22 February 2008 13:57
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  comparing sequences that contain more than one 
> of the same item
> 
> A bit of a Friday challenge...
> 
> Is it possible to compare to sequences such that items in the 
> sequence are consumed after the comparison?
> 
> For example, I want to compare two words to see if one is a 
> subset of the other.
> 
> "farmer" and "frame"
> 
> If you do:
> 
> string-to-codepoints('farmer')[not(. = string-to-codepoints('frame'))]
> 
> the result is empty because the two r's in farmer are both 
> being compared to the single r in frame.
> 
> Currently I've a got a recursive function that removes each 
> letter after a match, but I'm wondering if there's a 
> one-liner or some other set based approach?
> 
> 
> thanks
> --
> Andrew Welch
> http://andrewjwelch.com
> Kernow: http://kernowforsaxon.sf.net/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.