From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/53799 Path: news.gmane.org!not-for-mail From: Jelle Huisman Newsgroups: gmane.comp.tex.context Subject: filter contents of xml elements Date: Wed, 28 Oct 2009 15:17:53 +0000 Message-ID: <4AE860A1.9000200@jhnet.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1256743100 26048 80.91.229.12 (28 Oct 2009 15:18:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Oct 2009 15:18:20 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Oct 28 16:18:13 2009 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.50) id 1N3AHt-0004E9-85 for gctc-ntg-context-518@m.gmane.org; Wed, 28 Oct 2009 16:18:13 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 21923C9AFD; Wed, 28 Oct 2009 16:16:57 +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 rsygo2IgXI58; Wed, 28 Oct 2009 16:16:56 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 844F1C9B49; Wed, 28 Oct 2009 16:16:51 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0FC41C9B49 for ; Wed, 28 Oct 2009 16:16:46 +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 kNNhhBz6YaFh for ; Wed, 28 Oct 2009 16:16:43 +0100 (CET) Original-Received: from smtp2.wsfo.org (smtp2.wsfo.org [208.145.81.52]) by balder.ntg.nl (Postfix) with ESMTP id C8A27C9AFD for ; Wed, 28 Oct 2009 16:16:42 +0100 (CET) Original-Received: from mail.link77.net (cgp1.mail.link77.net [172.22.65.13]) by smtp2.wsfo.org (8.13.8/8.13.8) with ESMTP id n9SFHtM9032693 for ; Wed, 28 Oct 2009 11:17:56 -0400 X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.9.5 (ClamAV engine v0.95.2) X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.9.5 (ClamAV engine v0.95.2) X-ExternalMail: External Original-Received: from [172.17.1.94] (account jelle_huisman@sil.org HELO jelle-macbook.local) by cgp1.mail.link77.net (CommuniGate Pro SMTP 5.2.16) with ESMTPSA id 224293924 for ntg-context@ntg.nl; Wed, 28 Oct 2009 11:17:55 -0400 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.4pre) Gecko/20090915 Lightning/1.0pre Thunderbird/3.0b4 X-Scanned-By: MIMEDefang 2.62 on 172.22.65.24 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:53799 Archived-At: Hi all, First of all a big thank you to Hans for MkIV xml support which is so much easier to understand than the MKII based method (or is that just me?) Anyway, I'm processing a rather messy html file and I would like to do some conditional processing based on the actual content of the element. See example below: I have linked

with \subject but I would like to drop this element if the content of the element matches 'Skip title'. Any hints? Thanks! Jelle \startbuffer[test]

Title 1

Hello world.

Skip title

Hello world!

Title 2

Hello world?

Title 3

Hello :-)

\stopbuffer \startxmlsetups xml:setups \xmlsetsetup{main}{html|h3|p}{xml:*} \stopxmlsetups \xmlregistersetup{xml:setups} \startxmlsetups xml:html \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:h3 \subject{\xmlflush{#1}} % but drop this if content of element is 'Skip Title' \stopxmlsetups \startxmlsetups xml:p \xmlflush{#1}\par \stopxmlsetups \starttext \xmlprocessbuffer{main}{test}{} \stoptext Expected outcome: Title 1 Hello world. Hello world! Title 2 Hello world? Title 3 Hello :-) ___________________________________________________________________________________ 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 ___________________________________________________________________________________