>>>>> Jakub Wilk <jw...@debian.org> writes:
>>>>> * Ivan Shmakov <oneing...@gmail.com>, 2012-11-26, 14:32:

 >> Seriously, XML takes a lot of concerns off an application
 >> programmer. It provides quoting, arbitrary hierarchical structure,
 >> support for different encodings, etc.  Why, don't you think that
 >> $ grep [[:lower:]]' FILE is ever supposed to work?  For surely it
 >> isn't: grep has no way to know the encoding of the input file, and
 >> relies on the locale instead.  On the contrary, XML allows for the
 >> encoding to be specified explicitly via a processing instruction.
 >> And then, there's XPath, which takes the input dataset structure
 >> into account.

 > How do you search for a lowercase letter in XPath?

        With fn:matches (WHERE, "\p{Ll}")?

        Specifically, if you're interested in all ENTRY elements, whose
        respective KEY's contain a lower-case letter, it may look
        something like the following:

//x:entry[fn:matches (x:key/text (), "\p{Ll}")]

        For instance, using xqilla(1) (xmlstarlet(1) doesn't seem to
        support fn:matches ()):

$ cat < cf.xml 
<!DOCTYPE cf>
<cf xmlns="urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10">
  <entry>
    <key>there be an all-lowercase key</key>
    <value>all-lowercase key's value</value>
  </entry>
  <entry>
    <key>THERE BE AN ALL-UPPERCASE KEY</key>
    <value>all-uppercase key's value</value>
  </entry>
  <entry>
    <key>There be a Mixed-case Key</key>
    <value>mixed-case key's value</value>
  </entry>
</cf>
$ xqilla -i cf.xml \
      <(printf %s\\n '\
declare namespace x="urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10";' \
            '//x:entry[fn:matches (x:key/text (), "\p{Ll}")]') 
<entry xmlns="urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10">
    <key>there be an all-lowercase key</key>
    <value>all-lowercase key's value</value>
  </entry>
<entry xmlns="urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10">
    <key>There be a Mixed-case Key</key>
    <value>mixed-case key's value</value>
  </entry>
$ 

-- 
FSF associate member #7257


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/86mwy34ojh....@gray.siamics.net

Reply via email to