Hello!

Processing XML I want to manipulate content of XML elements inside Lua.

I can define the Lua function xml.functions.name(t), where processing
happens, and use the command \xmlfunction{#1}{name} to pass the current
node #1 from ctx to lua as described in the xml-mkiv.pdf manual. To access
the element content xml.text(t,"/element") Lua function is used.

However, using the same function xml.text("#1",/element) directly inside
Lua doesn't work for me. Node #1 is available, but not the content of
/element.

\startluacode
    local node = "#1"
    local content = xml.text("#1","/color")
    context.par() context("node: ") context(node)
    context.par() context("lua: ")  context(content)
\stopluacode

MWE (mkiv, beta) attached.

I haven't found an example, so is it even possible? If so, which way is
more efficient?

Thanks,
Jano

Attachment: xmlluanode.tex
Description: Binary data

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to