Accessing current XML node in Lua function
Hi, I'd like to write a Lua function that processes the href attribute from a HTML file and outputs different content depending on the URL. However, I don't know how to convert the XML attribute and the contents of the link tag to a string value for the Lua function. I've tried the following, which does not work but makes my intention clearer: \startxmlsetups xml:a \directlua{getlinkcode("\\xmlatt{#1}{href}", "\\xmlflush{#1}")} \stopxmlsetups It's probably calls to lxml.att and lxml.flush instead of the strings, but how do I convert the "#1" ? Kind regards, Gabriel -- Gabriel Birke Open Science Lab Technische Informationsbibliothek / German National Library of Science and Technology Welfengarten 1 B, 30167 Hannover, Germany Telefon: +49 511 762 14235 E-Mail: gabriel.birke@tib.uni-hannover.de Internet: http://www.tib.uni-hannover.de
On 02/25/2014 11:13 AM, Birke, Gabriel wrote:
Hi,
I'd like to write a Lua function that processes the href attribute from a HTML file and outputs different content depending on the URL. However, I don't know how to convert the XML attribute and the contents of the link tag to a string value for the Lua function. I've tried the following, which does not work but makes my intention clearer:
\startxmlsetups xml:a \directlua{getlinkcode("\\xmlatt{#1}{href}", "\\xmlflush{#1}")} \stopxmlsetups
It's probably calls to lxml.att and lxml.flush instead of the strings, but how do I convert the "#1" ?
Kind regards,
Gabriel
Have you seen http://wiki.contextgarden.net/XML_Lua ? In lua, you get the attribute with xml.attribute(t, "/", "name", "default value"), and can then use it for tests or typeset it. If you want to know more, you will need to provide a real example instead of a code snippet. Thomas Thomas -- Prof. Dr. Thomas A. Schmitz Geschäftsführender Direktor Institut für Klassische und Romanische Philologie Universität Bonn Am Hof 1e 53113 Bonn http://www.philologie.uni-bonn.de/personal/schmitz
participants (2)
-
Birke, Gabriel
-
Thomas A. Schmitz