* Accessing current XML node in Lua function
@ 2014-02-25 10:13 Birke, Gabriel
2014-02-25 10:50 ` Thomas A. Schmitz
0 siblings, 1 reply; 2+ messages in thread
From: Birke, Gabriel @ 2014-02-25 10:13 UTC (permalink / raw)
To: 'ntg-context@ntg.nl'
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
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Accessing current XML node in Lua function
2014-02-25 10:13 Accessing current XML node in Lua function Birke, Gabriel
@ 2014-02-25 10:50 ` Thomas A. Schmitz
0 siblings, 0 replies; 2+ messages in thread
From: Thomas A. Schmitz @ 2014-02-25 10:50 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-25 10:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-25 10:13 Accessing current XML node in Lua function Birke, Gabriel
2014-02-25 10:50 ` Thomas A. Schmitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).