Hi all,

one of my favorite topics… Here is a minimal example which shows something that 
I don't understand: when I process the subsection with the lua code, I want to 
get the value of the current section's "label" attribute in xml.attribute(r, 
"../../section", "label", "X"). So i was expecting that lua would go up 
(../../) and fetch the current section's label. But if you run the example, you 
see that it actually always gets the first section's label (value is always 1). 
How can I get the current section's label with a lua function?

THanks and all best

Thomas

\startbuffer[test]
<chapter>
  <section label="1">
    <subsection label="1">
      <content>
        text 1.1
      </content>
    </subsection>
  </section>
  <section label="3">
    <subsection label="1">
      <content>
        text 3.1
      </content>
    </subsection>
    <subsection label="5">
      <content>
        text 3.5
      </content>
    </subsection>
  </section>
</chapter>
\stopbuffer

\startxmlsetups xml:testsetups
        \xmlsetsetup{\xmldocument}{chapter|section|subsection|content}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:testsetups}

\startxmlsetups xml:chapter
        \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:section
        \xmlflush{#1} \par
\stopxmlsetups

\startxmlsetups xml:subsection
        \xmlfunction{#1}{test}
\stopxmlsetups

\startluacode
outfile = io.open('temp.tmp', 'w')
function xml.functions.test(r)
  content = xml.text(r, "content")
  section = xml.attribute(r, "../../section", "label", "X")
  context("This ") context(content) context(" is in section ") context(section)
end
\stopluacode

\starttext
\xmlprocessbuffer{main}{test}{}

\enabletrackers[context.trace]

\xmlshow{main}
\stoptext

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 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
___________________________________________________________________________________

Reply via email to