ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: ntg-context@ntg.nl
Subject: Re: btx/xml tree - entry with missing field
Date: Thu, 22 Dec 2016 18:30:43 +0100	[thread overview]
Message-ID: <b2522f5a-b293-9f8f-ced7-970d350bd3e4@wxs.nl> (raw)
In-Reply-To: <0091C820-D45C-473B-A986-EF63C14F5CFD@arch.ethz.ch>

On 12/22/2016 6:06 PM, Michael Eidenbenz wrote:
> Hello
>
> I use the xml interface to list all publications that dont match a
> search criteria:
>
>      /field[@name='keywords'
>             and not (contains(text(),'alpha'))]
>
> but there are entries where the keywords field is missing.
> how can I include them (here "test-3") in the output?
>
> Thanks Michael
>
> --------------------------
>
> \startbuffer[bib]
>
> @article{test-1,
>    title    = {Article One},
>    author   = {A. Foo and X. Bar},
>    year     = {2001},
>    keywords = {alpha},
> }
>
> @book{test-2,
>    title    = {Book Two},
>    author   = {B. Foo},
>    year     = {2002},
>    keywords = {beta},
> }
>
> @whatever{test-3,
>    title    = {Book Three},
>    author   = {C. Foo},
>    year     = {2003},
> }
>
> \stopbuffer
>
> \usebtxdataset [database] [bib.buffer]
> \convertbtxdatasettoxml [database]
>
> \startxmlsetups btx:tag
> \hbox{\xmlatt{#1}{tag}}
> \stopxmlsetups
>
> \startxmlsetups btx:demo
>    \xmlfilter {#1} {
>      /bibtex
>      /*
>      /field[@name='keywords'
>             and not (contains(text(),'alpha'))]
>      /..
>      /command(btx:tag)
>    }
> \stopxmlsetups
>
> \starttext
> \xmlsetup{btx:database}{btx:demo}
> \stoptext

\startxmlsetups btx:demo
    \xmlfilter {#1} {/bibtex/*/command(btx:demo:action)}
\stopxmlsetups

\startxmlsetups btx:demo:action
     \xmldoifelse {#1} {/field[@name='keywords']} {
         \xmlfilter {#1} {
              /field[@name='keywords'
                     and not contains(text(),'alpha')]
              /..
              /command(btx:tag)
         }
     } {
         \xmlsetup{#1}{btx:tag}
    }
\stopxmlsetups


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2016-12-22 17:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22 17:06 Michael Eidenbenz
2016-12-22 17:30 ` Hans Hagen [this message]
2016-12-22 19:50   ` Michael Eidenbenz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2522f5a-b293-9f8f-ced7-970d350bd3e4@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).