[NTG-context] btx/xml tree - entry with missing field

Michael Eidenbenz eidenbenz at arch.ethz.ch
Thu Dec 22 20:50:57 CET 2016


thanks a lot hans!

> Am 22.12.2016 um 18:30 schrieb Hans Hagen <pragma at 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='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 at 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
> ___________________________________________________________________________________

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20161222/1a9c7778/attachment-0001.html>


More information about the ntg-context mailing list