Hans Hagen wrote:
Vit Zyka wrote:

Hallo,

it is possible to use TeX control sequence inside XML param? How?
Example:

<figure file="file.pdf" width=".45\textwidth" />
                                  ^^^^^^^^^^
\defineXMLenvironment[figure][file=,width=]
  {}
  {\externalfigure[\XMLop{file}][width=\XMLop{width}]}


Hm. You're lucky. We should make a test suite (at the wiki) to make sure that this kind of stuff keeps working -)

\starttext

\defineXMLentity[ctx-var-textwidth] {\textwidth}

I seeee! I might come to me... Actually I'd like to solve a bit more complex task:


\starttext

\defineXMLentity[ctx-var-textwidth] {\textwidth}

\newcount\FigNo
\defineXMLenvironment[float][]
  {\defineXMLpush[caption]%
   \global\FigNo=0
  }
  {\placefigure{\XMLflush{caption}}%
     {\dorecurse{\FigNo}%
        {\edef\filewithpath{\XMLpop{dir-fig}\getvalue{file:\recurselevel}}%
         \edef\param{\getvalue{param:\recurselevel}}%
         \externalfigure[\filewithpath][\param]}}%
  }
\defineXMLenvironment[figure][file=,context=]
  {}
  {\global\advance\FigNo by1 %
   \expanded{\setvalue{file:\the\FigNo}{\XMLop{file}}}%
   \expanded{\setvalue{param:\the\FigNo}{\XMLop{context}}}%
  }

\startXMLdata
<float>
  <figure file="cow.pdf" context="width=.5&ctx-var-textwidth;" />
  <figure file="hacker.jpg" context="width=3cm" />
  <caption>Cow and hacker.</caption>
</float>
\stopXMLdata

\stoptext
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to