From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/97005 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Eidenbenz Newsgroups: gmane.comp.tex.context Subject: Re: btx/xml tree - entry with missing field Date: Thu, 22 Dec 2016 20:50:57 +0100 Message-ID: References: <0091C820-D45C-473B-A986-EF63C14F5CFD@arch.ethz.ch> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/mixed; boundary="===============4835566745424553814==" X-Trace: blaine.gmane.org 1482436300 30072 195.159.176.226 (22 Dec 2016 19:51:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 22 Dec 2016 19:51:40 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Dec 22 20:51:35 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cK9Ol-00063A-MO for gctc-ntg-context-518@m.gmane.org; Thu, 22 Dec 2016 20:51:31 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 99C7782CB9; Thu, 22 Dec 2016 20:51:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BqW7WgRVu2fJ; Thu, 22 Dec 2016 20:51:13 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 3CC9782CB3; Thu, 22 Dec 2016 20:51:13 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2DF3182CB1 for ; Thu, 22 Dec 2016 20:51:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cHVCq304Mqp3 for ; Thu, 22 Dec 2016 20:51:10 +0100 (CET) Original-Received: from edge20.ethz.ch (edge20.ethz.ch [82.130.99.26]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 80FF482CB0 for ; Thu, 22 Dec 2016 20:51:00 +0100 (CET) Original-Received: from CAS21.d.ethz.ch (172.31.51.111) by edge20.ethz.ch (82.130.99.26) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 22 Dec 2016 20:50:49 +0100 Original-Received: from [192.168.88.11] (212.51.141.26) by CAS21.d.ethz.ch (172.31.51.111) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 22 Dec 2016 20:50:58 +0100 In-Reply-To: X-Mailer: Apple Mail (2.3124) X-Originating-IP: [212.51.141.26] X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:97005 Archived-At: --===============4835566745424553814== Content-Type: multipart/alternative; boundary="Apple-Mail=_363BB15F-E6DE-4C18-8DCB-DED56A996F8C" --Apple-Mail=_363BB15F-E6DE-4C18-8DCB-DED56A996F8C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" thanks a lot hans! > Am 22.12.2016 um 18:30 schrieb Hans Hagen : >=20 > On 12/22/2016 6:06 PM, Michael Eidenbenz wrote: >> Hello >>=20 >> I use the xml interface to list all publications that dont match a >> search criteria: >>=20 >> /field[@name=3D'keywords' >> and not (contains(text(),'alpha'))] >>=20 >> but there are entries where the keywords field is missing. >> how can I include them (here "test-3") in the output? >>=20 >> Thanks Michael >>=20 >> -------------------------- >>=20 >> \startbuffer[bib] >>=20 >> @article{test-1, >> title =3D {Article One}, >> author =3D {A. Foo and X. Bar}, >> year =3D {2001}, >> keywords =3D {alpha}, >> } >>=20 >> @book{test-2, >> title =3D {Book Two}, >> author =3D {B. Foo}, >> year =3D {2002}, >> keywords =3D {beta}, >> } >>=20 >> @whatever{test-3, >> title =3D {Book Three}, >> author =3D {C. Foo}, >> year =3D {2003}, >> } >>=20 >> \stopbuffer >>=20 >> \usebtxdataset [database] [bib.buffer] >> \convertbtxdatasettoxml [database] >>=20 >> \startxmlsetups btx:tag >> \hbox{\xmlatt{#1}{tag}} >> \stopxmlsetups >>=20 >> \startxmlsetups btx:demo >> \xmlfilter {#1} { >> /bibtex >> /* >> /field[@name=3D'keywords' >> and not (contains(text(),'alpha'))] >> /.. >> /command(btx:tag) >> } >> \stopxmlsetups >>=20 >> \starttext >> \xmlsetup{btx:database}{btx:demo} >> \stoptext >=20 > \startxmlsetups btx:demo > \xmlfilter {#1} {/bibtex/*/command(btx:demo:action)} > \stopxmlsetups >=20 > \startxmlsetups btx:demo:action > \xmldoifelse {#1} {/field[@name=3D'keywords']} { > \xmlfilter {#1} { > /field[@name=3D'keywords' > and not contains(text(),'alpha')] > /.. > /command(btx:tag) > } > } { > \xmlsetup{#1}{btx:tag} > } > \stopxmlsetups >=20 >=20 > ----------------------------------------------------------------- > 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! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_363BB15F-E6DE-4C18-8DCB-DED56A996F8C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="us-ascii"
thanks a lot = hans!

Am 22.12.2016 um 18:30 schrieb Hans Hagen <pragma@wxs.nl>:

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=3D'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 =    =3D {Article One},
  author =   =3D {A. Foo and X. Bar},
  year =     =3D {2001},
  keywords = =3D {alpha},
}

@book{test-2,   title    =3D {Book Two},
  author   =3D {B. Foo},
=   year     =3D {2002},
=   keywords =3D {beta},
}

@whatever{test-3,
  title =    =3D {Book Three},
  author =   =3D {C. Foo},
  year =     =3D {2003},
}

\stopbuffer

\usebtxdataset = [database] [bib.buffer]
\convertbtxdatasettoxml = [database]

\startxmlsetups btx:tag
\hbox{\xmlatt{#1}{tag}}
\stopxmlsetups

\startxmlsetups btx:demo
=   \xmlfilter {#1} {
=     /bibtex
=     /*
=     /field[@name=3D'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=3D'keywords']} {
=        \xmlfilter {#1} {
= =             /f= ield[@name=3D'keywords'
=             &n= bsp;      and not = contains(text(),'alpha')]
=             /.= .
=             /c= ommand(btx:tag)
=        }
=    } {
=        \xmlsetup{#1}{btx:tag}
  }
\stopxmlsetups


---------------------------------------------------------------= --
=             &n= bsp;           &nbs= p;            =     Hans Hagen | PRAGMA ADE
=             &n= bsp;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
_______________________________________________________________= ____________________

= --Apple-Mail=_363BB15F-E6DE-4C18-8DCB-DED56A996F8C-- --===============4835566745424553814== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f --===============4835566745424553814==--