From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/36380 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: mkiv and xml Date: Wed, 05 Sep 2007 14:34:17 +0200 Message-ID: <46DEA249.2030806@wxs.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" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1188995735 9746 80.91.229.12 (5 Sep 2007 12:35:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 5 Sep 2007 12:35:35 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Sep 05 14:35:34 2007 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1ISu6P-0003bn-FK for gctc-ntg-context-518@m.gmane.org; Wed, 05 Sep 2007 14:35:25 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 8117B202CB; Wed, 5 Sep 2007 14:35:18 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 28259-02; Wed, 5 Sep 2007 14:35:07 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 0AB5E20097; Wed, 5 Sep 2007 14:35:07 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 908E320097 for ; Wed, 5 Sep 2007 14:35:00 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 28296-06-2 for ; Wed, 5 Sep 2007 14:34:55 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with ESMTP id A0A9B2006A for ; Wed, 5 Sep 2007 14:34:54 +0200 (CEST) Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by controller-1 (SurgeMail 3.7b8) with ESMTP id 12788 for ; Wed, 05 Sep 2007 14:34:54 +0200 User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) X-Server: High Performance Mail Server - http://surgemail.com r=-274017400 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 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 X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:36380 Archived-At: Hi, I uploaded a new beta which may be of interest to xml lovers. The current (mkii) XML handler is based on hooking code into active < characters. This works ok but has limitations. In MKIV we will have an alternative method which has a few advantages: = you have access to arbitrary elements using a subset of xpath = you can attach fully expandable hooks to elements, using 'setups' = for manu cases xml processing is faster (no need for definitions and save/flush) = with lua as programming environemnt rather tricky manipulations are possible The downside of this method is = loading a document eats a bit of memory Think of this: First we load a file (pretty fast btw given that the whole tree is built in memory in such a way that it can also be flushed as-is) \xmlload{main}{cont-en.xml}{} We hook a specific setup into one of the elements \xmlgrab{main}{cd:command}{cd-demo} This setup is (here #1 represents the current node): \startxmlsetups cd-demo \NC \xmlatt{#1}{name} \NC \xmlatt{#1}{file} \NC \NR \stopxmlsetups Now we can say: \starttabulate[|l|l|] \NC command \NC file \NC \NR \xmlall{main}{//cd:command} \stoptabulate This gives us a two column table There is a truckload of (to be documented) commands, for instance one can filter wlements with: first \xmlfilter{main}{cd:command/first()} \blank[2*big] last \xmlfilter{main}{cd:command/last()} \blank[2*big] first \xmlfirst{main}{cd:command} \blank[2*big] last \xmllast {main}{cd:command} \blank[2*big] You can flush whole (sub)trees, access elements by index, etc A variant of the table builder (without the need for adding hooks) is \startxmlsetups cd-demo \NC \xmlatt{#1}{name} \NC \xmlatt{#1}{file} \NC \NR \stopxmlsetups \starttabulate[|l|l|] \NC command \NC file \NC \NR \xmlcommand{main}{//cd:command}{cd-demo} \stoptabulate Or: \startxmlsetups another-demo \NC \xmlatt{#1}{name} \NC \xmlatt{#1}{file} \NC \NR \stopxmlsetups \starttabulate[|l|l|] \NC command \NC file \NC \NR \xmlfilter{main}{//cd:command/command('another-demo')} \stoptabulate I reimplemented the presentation mml module (partially) using this mechanism. The regular definitions still work but processing a file is done differently: \xmlprocess{id}{filename}{optional initiaization setup} It probably takes a while to get accustomed to this, but this mixture of stream and tree handling of xml files looks promising. The current functionality is still experimental and details may change but the base is there. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | 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://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________