From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/84901 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: How to debug XML processing Date: Sat, 19 Oct 2013 13:29:22 -0400 (EDT) Message-ID: References: <33536258.250373553.1382102560348.JavaMail.root@zimbra71-e12.priv.proxad.net> <52627E15.8030400@uni-bonn.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1382203779 8871 80.91.229.3 (19 Oct 2013 17:29:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Oct 2013 17:29:39 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Oct 19 19:29:44 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VXaLO-0002iN-2g for gctc-ntg-context-518@m.gmane.org; Sat, 19 Oct 2013 19:29:42 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C1867101DE; Sat, 19 Oct 2013 19:26:51 +0200 (CEST) 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 zTYPD+S-+es7; Sat, 19 Oct 2013 19:26:49 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 2C1BD101E3; Sat, 19 Oct 2013 19:26:49 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 8D886101E3 for ; Sat, 19 Oct 2013 19:26:47 +0200 (CEST) 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 ScNIS6xrqx1G for ; Sat, 19 Oct 2013 19:26:46 +0200 (CEST) Original-Received: from filter1-til.mf.surf.net (filter1-til.mf.surf.net [194.171.167.217]) by balder.ntg.nl (Postfix) with ESMTP id 44947101DE for ; Sat, 19 Oct 2013 19:26:46 +0200 (CEST) Original-Received: from tombraider.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.12.86]) by filter1-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r9JHTWJe021445 for ; Sat, 19 Oct 2013 19:29:34 +0200 Original-Received: FROM adi-thinkpad.local ((null) [135.0.226.162]) By tombraider.mr.itd.umich.edu ID 5262C17A.69EFF.32315 ; Authuser adityam; 19 Oct 2013 13:29:30 EDT In-Reply-To: <52627E15.8030400@uni-bonn.de> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=141.211.12.86; country=US; region=MI; city=Ann Arbor; postalcode=48105; latitude=42.3241; longitude=-83.7113; metrocode=505; areacode=734; http://maps.google.com/maps?q=42.3241,-83.7113&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0RKD5txMF - 41b2d76dc6cc - 20131019 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.217 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:84901 Archived-At: On Sat, 19 Oct 2013, Thomas A. Schmitz wrote: > On 10/18/2013 03:22 PM, stephleg@free.fr wrote: >> Hello, >> >> After reading "Getting Web Content and pdf-Output from One Source" by >> Thomas A. Schmitz, i'm trying to use the same method to build a PDF >> file from a HTML one. But i quickly found that when something doesn't >> work as expected, it's pretty hard to debug because it's hard to tell >> if the error come from the environment file, the lua code or >> something else. >> >> So are there some useful tricks to debug this kind of processing >> besides the \enabletrackers command? Especially is there a way to >> view the generated ConTeXt code after the macro expansion? >> >> Thank you. > > Let me put it this way: if there is a way, I don't know about it. You're > right that debugging becomes more complex because there are more layers of > complexity involved. OTOH: many editors can validate xml as you type (I don't > know of any that does the same for TeX input), so at least you know when your > source should compile. And one tip (something I have started too late): put > your lua code in a separate file and call it from within your TeX > environment, that way, context's error messages become more precise. I find it difficult to wrap my head around the XML processing details, mainly because I don't understand how XPATH works (there are subtle difference between XPATH tutorials that I find online and ConTeXt implementation of it). I find it easier to: 1. Keep the data as an XML source file and create a RNG schema to validate it. 2. Trasform XML into LUA tables. I use the lxml library (that comes with ConTeXt) to do this translation. 3. Format the LUA data using CDL (ConTeXt Lua Document). This way, the parsing is separate from formatting and it is easy to verify both parts independently. Aditya ___________________________________________________________________________________ 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 ___________________________________________________________________________________