From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/55521 Path: news.gmane.org!not-for-mail From: Peter Rolf Newsgroups: gmane.comp.tex.context Subject: Re: XML - creating a list by hand (mkiv) Date: Tue, 12 Jan 2010 15:47:00 +0100 Message-ID: <4B4C8B64.6010900@gmx.net> References: <4B2F79FA.6030802@gmx.net> <4B30C3E5.5080506@wxs.nl> <4B30C7DD.4020505@gmx.net> <4B30CABD.1080303@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070007000804010701040707" X-Trace: ger.gmane.org 1263307646 23535 80.91.229.12 (12 Jan 2010 14:47:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 Jan 2010 14:47:26 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jan 12 15:47:19 2010 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 1NUi1Y-0004J0-Jr for gctc-ntg-context-518@m.gmane.org; Tue, 12 Jan 2010 15:47:12 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E539AC9AF1; Tue, 12 Jan 2010 15:47:10 +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 OWCUlvjcV7lu; Tue, 12 Jan 2010 15:47:10 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 54A93C9AFD; Tue, 12 Jan 2010 15:47:08 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id B41FBC9AFD for ; Tue, 12 Jan 2010 15:47:06 +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 ejwIEx0-9f6b for ; Tue, 12 Jan 2010 15:47:04 +0100 (CET) Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by balder.ntg.nl (Postfix) with SMTP id 47B87C9AF1 for ; Tue, 12 Jan 2010 15:47:04 +0100 (CET) Original-Received: (qmail invoked by alias); 12 Jan 2010 14:47:03 -0000 Original-Received: from i577BF004.versanet.de (EHLO [192.168.1.3]) [87.123.240.4] by mail.gmx.net (mp051) with SMTP; 12 Jan 2010 15:47:03 +0100 X-Authenticated: #24293357 X-Provags-ID: V01U2FsdGVkX1/NL60rslvNq3SdiTMeHPGq0T2hiHX2IoU6H60Zay a5PfeQNmbDNK00 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 In-Reply-To: <4B30CABD.1080303@wxs.nl> X-Enigmail-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.48 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:55521 Archived-At: This is a multi-part message in MIME format. --------------070007000804010701040707 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, after a (too short) vacation I'm again trying to make this run. (btw: inserting in empty root still does not work here) I have attached a more detailed example (ugly XMP), that shows my current problems. The result of the operations is saved in "xmp.xml". And here are the problems... 1. xml.replace(xmp,"xml://rdf:Description/dc:creator/rdf:Seq/rdf:li","dc:CREATOR1") wanted: .. dc:CREATOR1 .. I get : .. dc:CREATOR1 .. 2. How can I inject a piece of XML (file or text sequence) into the existing XML tree? I have managed to get a valid lpath expression ("xml://rdf:..." does not work), but nothing is inserted. 3. xml.insert(xmp,"xml://rdf:Description/dc:creator/rdf:Seq","dc:CREATOR2") works only, if another (even empty) element already exists. If I delete this element beforehand, the string is inserted after . What does ["comment"]={ "auto-child replaced by auto-descendant" } mean here? --- The problems must be examined exclusively (comment other problems to test). This is all very confusing, aside from the fact, that I'm used to think in xpath and not lpath. So I'm quite unsure, if this is a ConTeXt problem or just my ignorance of lpath. Anyhow, no fun ;) Greetings, Peter MTXrun | current version: 2010.01.11 14:57 This is LuaTeX, Version beta-0.50.0-2010011118 Am 22.12.2009 14:33, schrieb Hans Hagen: > Peter Rolf wrote: >> Am 22.12.2009 14:04, schrieb Hans Hagen: >>> Peter Rolf wrote: >>>> Hi, >>>> >>>> can someone give me a helping hand with the following example. I still >>>> have no general survey over the XML related code in ConTeXt (donno >>>> what functions to use). The last time I played with it is one and a >>>> half year ago and many things have changed (meaning that the old >>>> examples no longer work). >>> http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf >>> >> oeps, how could I missed that one... :( >> >> >>>> I simply want to create a XML document and insert some elements. My >>>> main problem is to insert an element at root level. I can insert an >>>> element before and after another element, but not into the element. >>>> I'm not sure, if I have understood the meaning of the pattern >>>> parameter correctly. Is this equal to XPath? >>>> >>>> >>>> %----- >>>> \starttext >>>> >>>> \startluacode >>>> >>>> local xmp = xml.convert(">>> standalone='yes'?>\n\nbla\n") >>>> --xml.before(xmp,"/root/bar","foo") >>>> >>>> --xml.delete(xmp,"bar") >>>> --xml.inject(xmp,"/sub","bar")-- only for xml-files? >>>> >>>> xml.insert(xmp,"/root/bar","") >>>> --xml.inject(xmp,"/*/bar","") >>> this works >>> >>> >>> >> Mhh, not here. When I look into the saved file (test.xml) I get > > add some content (i need to look into the empty case (root only)) > >> >> >> blainvalid xml file - unparsed text >> >> >> >> But I guess that the linked PDF will give all the answers I need. > > the most important change is that we now can have many handlers; when > you are inside tex and want to manipulate xml without piping to tex, you > need the xml:// path prefix but the manual mentions this > > also, there are some tracing options that can be handy > > 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 : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ > > --------------070007000804010701040707 Content-Type: text/plain; name="xmp.tex" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xmp.tex" \starttext \enabletrackers[xml.parse] %\enabletrackers[xml.path] %\enabletrackers[xml.profile] -- exclusive %\enabletrackers[xml.entities] \startluacode local xmp = xml.load("xmp-default.xml") -- 1. replace empty ; (results in "dc:CREATOR1" without tags) xml.replace(xmp,"xml://rdf:Description/dc:creator/rdf:Seq/rdf:li","dc:CREATOR1") -- 2. inject XML sequence; (how?) --xml.inject (xmp,"xml:///rdf:Description/dc:creator/rdf:Seq","dc:CREATOR1") -- delete the first entry --xml.delete(xmp,"xml://rdf:Description/dc:creator/rdf:Seq/rdf:li") -- 3. insert element into ; (only after/before, but not into empty) --xml.insert (xmp,"xml:///rdf:Description/dc:creator/rdf:Seq","dc:CREATOR2") xml.save(xmp,"xmp.xml") \stopluacode \null \stoptext --------------070007000804010701040707 Content-Type: text/xml; name="xmp-default.xml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xmp-default.xml" application/pdf --------------070007000804010701040707 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --------------070007000804010701040707--