From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113966 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thangalin via ntg-context Newsgroups: gmane.comp.tex.context Subject: Dynamic document variables from metadata Date: Sat, 1 Jan 2022 17:54:19 -0800 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5290307857576075449==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24147"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Thangalin To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Jan 02 02:54:56 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n3q5H-00063B-OZ for gctc-ntg-context-518@m.gmane-mx.org; Sun, 02 Jan 2022 02:54:55 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id F316D289097; Sun, 2 Jan 2022 02:54:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OenRu0BVOntH; Sun, 2 Jan 2022 02:54:35 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 923B4286D12; Sun, 2 Jan 2022 02:54:35 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8D19F286D12 for ; Sun, 2 Jan 2022 02:54:33 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BSc1zQXYRKHd for ; Sun, 2 Jan 2022 02:54:32 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.47; helo=mail-lf1-f47.google.com; envelope-from=thangalin@gmail.com; receiver= Original-Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id B593E2810F4 for ; Sun, 2 Jan 2022 02:54:31 +0100 (CET) Original-Received: by mail-lf1-f47.google.com with SMTP id i31so67598966lfv.10 for ; Sat, 01 Jan 2022 17:54:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=MluqNqWiO++6meR+HqWT/0Zc0kOyM/aNjQdLEMEixjQ=; b=IM16x1hujD9HhukYmMny3+bVkvNkbc0SseRWw3n/jEqXsG50rcgpqaryj+GpzhHDS8 e7gUOo90P4nLeQHVikQn7JazMN8Fjrw/DQj/lUALTPXR0bgTKVBL85Iok91vOo6rJ5zL fBfa9eSEC0gVjl/cw5O5v+Js4fjfOpr+Q3tsyz20OjbB2CK1qJkSYw3bYwxpM7nwY4ju DU/R3XoWvmT9VB5yW6PiPdOaWVems67yclap3exm+fkcmn2abepZeN+t3CGZoDSYPZoN 9anTuZTN9EBVtTNvgApG66vUiGwLt6EntB/ldiKkS5MhmxRafvgbQpe3mDNJM4C9dDMV TV8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=MluqNqWiO++6meR+HqWT/0Zc0kOyM/aNjQdLEMEixjQ=; b=M/PNqeT99XNUtMdQEFjSEIN53wlY2pwxpBBvCDIvTUD4JRYxJsao+OoAWweiD+dQTW YBfeCQARfrfDZD7mA8XepZerBm8v/1ttlYVBpc+4OIKiNoN+tk1kgpO+IoQ9oL/75wfu OMQslIPgcsiAVaEp9gHHPhvzWgIqGdzVnPsxThtbSEkNynOd3A5+VrDYxedWV0/e0lfN GpRtQCogccbg4dj0jNwDQYcZcpEKsmNRdmjr3OVvlZVhHNSYKKU4QSoc6Alfu5BsVkPZ E9EF3RFbDgN6lxSh3GEJmCdkRbNrX4qNQRJPOYsbOrG3F1XbGl3bCdaavH6txjLtfTKr 93Hg== X-Gm-Message-State: AOAM530AXrJ/UVpaHpqdmqyvc1cVzUXMUMconkr8X4rBXrJt5lNhYr4b b6k4rZICCzbL3wI+MRvfDHDE9Or2UegjpCBjQ6/sDuXm X-Google-Smtp-Source: ABdhPJyPe1Se77XemStr3mtbtGz5BfzSeFUYeBAKTyfYmMx9PdleUUF0uRJKUs03DJwGnxUw7PGibxntsTo2YShjgBo= X-Received: by 2002:ac2:4350:: with SMTP id o16mr35660793lfl.52.1641088470739; Sat, 01 Jan 2022 17:54:30 -0800 (PST) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 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" Xref: news.gmane.io gmane.comp.tex.context:113966 Archived-At: --===============5290307857576075449== Content-Type: multipart/alternative; boundary="00000000000057f20d05d48faf1f" --00000000000057f20d05d48faf1f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Happy New Year! How would you implement a mechanism that takes arbitrary XHTML tags and produces document variables? Consider: After running XML setups, the following would write "Nature": \documentvariable{journal} The tricky part is doing this without pre-defining them. Here's a short, self-contained example to help demonstrate: \startbuffer[xdoc] \stopbuffer \startxmlsetups xml:xhtml \xmlsetsetup{\xmldocument}{*}{-} \xmlsetsetup{\xmldocument}{html|body}{xml:*} \xmlsetsetup{\xmldocument}{head}{xml:meta}\stopxmlsetups \xmlregistersetup{xml:xhtml} \startxmlsetups xml:html % "author" is a special setup, not generalized \xmlfilter{#1}{/head/meta[@name=3D'author']/command(xml:author)} % What goes here to make this dynamic? %\xmlfilter{#1}{/head/meta[@name=3D'journal']/command(xml:journal)} \xmlflush{#1}\stopxmlsetups \startxmlsetups xml:author \setupdocument[author=3D{\xmlatt{#1}{content}}] \setupdocument[metadata:author=3D{\xmlatt{#1}{content}}] \setupinteraction[author=3D{\documentvariable{author}}]\stopxmlsetups % How can this be generalized?%\startxmlsetups xml:journal %\setupdocument[journal=3D{\xmlatt{#1}{content}}]%\stopxmlsetups \startxmlsetups xml:body \startdocument Author: \documentvariable{author} \par Journal: \documentvariable{journal} \stopdocument\stopxmlsetups \xmlprocessbuffer{main}{xdoc}{} Thank you! --00000000000057f20d05d48faf1f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Happy New Year!

How would yo= u implement a mechanism that takes arbitrary XHTML <meta> tags and pr= oduces document variables? Consider:

=C2=A0=C2=A0= =C2=A0 <meta name=3D"journal" content=3D"Nature" /&g= t;

After running XML setups, the following would w= rite "Nature":

=C2=A0=C2=A0=C2=A0 \d= ocumentvariable{journal}

The tricky part is doing = this without pre-defining them. Here's a short, self-contained example = to help demonstrate:

\s=
tartbuffer[xdoc]
<html>
<head>
  <meta content=3D"Milena Mari=C4=87 Einstein" name=3D"au=
thor"/>
  <meta content=3D"Annalen der Physik" name=3D"journal&qu=
ot;/>
</head>
<body>
</body>
</html>
\stopbuffer

\startxmlsetups xml:xhtml
  \xmlsetsetup{\xmldocument}{*}{-}
  \xmlsetsetup{\xmldocument}{html|body}{xml:*}
  \xmlsetsetup{\xmldocument}{head}{xml:meta}
\stopxmlsetups

\xmlregistersetup{xml:xhtml}

\startxmlsetups xml:html
% "a= uthor" is a special setup, not generalized \xmlfilter{#1}{/head/meta[@name=3D'author']/command(xml:author)} % What goes here to make this dynamic? %\xmlfilter{#1}{/head/meta[@name=3D'jour= nal']/command(xml:journal)} \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:author \setupdocument[author=3D{\xmlatt{#1}{con= tent}}] \setupdocument[metadata:author=3D{\xmlatt{#1}{content}}] \setupinteraction[author=3D{\documentvariable{author}}] \stopxmlsetups % How can this be generalized? %\startxmlsetups xml:journal %\setupdocument[journal=3D{\xmlatt{#1}{conte= nt}}] %\stopxmlsetups \startxmlsetups xml:body \startdocument Author: \documentvariable{author} \par Journal: \documentvariable{journal} \stopdocument \stopxmlsetups \xmlprocessbuffer{main}{xdoc}{}
<= /pre>

Thank you!

--00000000000057f20d05d48faf1f-- --===============5290307857576075449== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============5290307857576075449==--