From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/66272 Path: news.gmane.org!not-for-mail From: "Thomas A. Schmitz" Newsgroups: gmane.comp.tex.context Subject: Re: filtering xml Date: Tue, 22 Feb 2011 08:34:59 +0100 Message-ID: <4B867345-2129-4D86-A8E1-2CBF7DD53469@uni-bonn.de> References: <4D62E943.1090107@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1298360170 3615 80.91.229.12 (22 Feb 2011 07:36:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 Feb 2011 07:36:10 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Feb 22 08:36:02 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Prmmw-00035D-PC for gctc-ntg-context-518@m.gmane.org; Tue, 22 Feb 2011 08:36:02 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 8A39ACAA4B; Tue, 22 Feb 2011 08:36:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id CYL3mnvCZdh3; Tue, 22 Feb 2011 08:35:48 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 84174CAA3F; Tue, 22 Feb 2011 08:35:48 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 12AB5CAA3D for ; Tue, 22 Feb 2011 08:35:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4t1bt8aUafBg for ; Tue, 22 Feb 2011 08:35:16 +0100 (CET) Original-Received: from filter3-til.mf.surf.net (filter3-til.mf.surf.net [194.171.167.219]) by balder.ntg.nl (Postfix) with ESMTP id 0F4CFCAA3F for ; Tue, 22 Feb 2011 08:35:16 +0100 (CET) Original-Received: from uni-bonn.de (mail.uni-bonn.de [131.220.15.113]) by filter3-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p1M7ZFAS020104 for ; Tue, 22 Feb 2011 08:35:15 +0100 Original-Received: from [88.128.94.159] (account tschmit1@uni-bonn.de HELO [10.142.15.140]) by fe2.uni-bonn.de (CommuniGate Pro SMTP 5.2.12) with ESMTPA id 56093693 for ntg-context@ntg.nl; Tue, 22 Feb 2011 08:35:14 +0100 In-Reply-To: <4D62E943.1090107@wxs.nl> X-Mailer: Apple Mail (2.1082) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=131.220.15.113; country=DE; region=07; city=Bonn; latitude=50.7333; longitude=7.1000; http://maps.google.com/maps?q=50.7333,7.1000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0eEaTzfUq - 771b03cc8a68 - 20110222 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.219 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:66272 Archived-At: On Feb 21, 2011, at 11:37 PM, Hans Hagen wrote: > On 21-2-2011 8:11, Thomas Schmitz wrote: >> Hi all, >> >> this must be easy, but I don't find the solution. Given an xml structure >> like this: >> >> >> dog >> cat >> mouse >> >> >> which \xmlfilter expression do I need to get the first element which >> has a subelement ? I.e., the filter should only return "cat," not >> "dog" or "mouse." There can be 0 or more elements without before and >> after the one I want to retrieve. >> >> Sorry if this is elementary, but I looked at xml-mkiv.pdf and mk.pdf and >> couldn't find an answer. > > "A/B[1]" > Sorry, I guess I wasn't clear enough. Here's a fuller example: \startbuffer[test] cat dog mouse donkey giraffe \stopbuffer \startxmlsetups xml:testsetups \xmlsetsetup{\xmldocument}{A|B|C}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups xml:A \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:B \xmlfilter{#1}{/C[1]/command(xml:C:first)} \stopxmlsetups \startxmlsetups xml:C:first \color[red]{\xmlflush{#1}} \stopxmlsetups \startxmlsetups xml:C \xmlflush{#1} \stopxmlsetups \starttext \xmlprocessbuffer{main}{test}{} \stoptext Suppose I want the first subelement in red, all the other subelements in blue? Right now, I get all the B's in red. Thanks, as always Thomas ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________