xsl-list
[Top] [All Lists]

Re: [xsl] question on filtering a one-to-many relationship

2012-03-06 03:48:40
On 06/03/2012 09:30, Robby Pelssers wrote:
Hi all,

Just to make my use case clear I quickly came up with a simple example showing 
my use case.

I need to write a function that enables me to return all<person>'s  which have 
at least 1 child that MATCHES a specific search string.

           persons/person[matches(upper-case(children/child/name), 
upper-case($searchString))]

Above expression does not work as the matches can only handle a single string 
as input and not a sequence of names.  So I was wondering what would be an 
elegant way to solve this puzzler?
persons/person[some $n in children/child/name satisifies matches(upper-case($n), upper-case($searchString))]

or if you prefer to avoid range variables,

persons/person[children/child/name[matches(upper-case(.), upper-case($searchString))]]

(I'm not sure that applying upper-case() to a regular expression is particularly good practice, however - for example it will change \w to \W).

Michael Kay
Saxonica

Kind regards,
Robby Pelssers


<persons>
   <person>
     <name>Robby</name>
        <children>
        <child>
        <name>Lindsey</name>
        <child>
        <child>
        <name>Valerie<name>
        </child>
        </children>
   <person>
   <person>
     <name>Audrey</name>
        <children>
        <child>
        <name>Linn</name>
        <child>
        <child>
        <name>Tamara<name>
        </child>
        </children>
   </person>
</persons>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>