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-contextwebpage :
http://www.pragma-ade.nl /
http://context.aanhet.netarchive :
https://bitbucket.org/phg/context-mirror/commits/wiki :
http://contextgarden.net___________________________________________________________________________________