<div dir="ltr"><div>Happy New Year!</div><div><br></div><div>How would you implement a mechanism that takes arbitrary XHTML <meta> tags and produces document variables? Consider:</div><div><br></div><div>    <meta name="journal" content="Nature" /></div><div><br></div><div>After running XML setups, the following would write "Nature":<br></div><div><br></div><div>    \documentvariable{journal}</div><div><br></div><div>The tricky part is doing this without pre-defining them. Here's a short, self-contained example to help demonstrate:</div><div><br></div><div><pre class="lang-tex s-code-block"><code class="hljs language-latex"><span class="hljs-keyword">\startbuffer</span>[xdoc]
<html>
<head>
  <meta content="Milena Marić Einstein" name="author"/>
  <meta content="Annalen der Physik" name="journal"/>
</head>
<body>
</body>
</html>
<span class="hljs-keyword">\stopbuffer</span>

<span class="hljs-keyword">\startxmlsetups</span> xml:xhtml
  <span class="hljs-keyword">\xmlsetsetup</span>{<span class="hljs-keyword">\xmldocument</span>}{*}{-}
  <span class="hljs-keyword">\xmlsetsetup</span>{<span class="hljs-keyword">\xmldocument</span>}{html|body}{xml:*}
  <span class="hljs-keyword">\xmlsetsetup</span>{<span class="hljs-keyword">\xmldocument</span>}{head}{xml:meta}
<span class="hljs-keyword">\stopxmlsetups</span>

<span class="hljs-keyword">\xmlregistersetup</span>{xml:xhtml}

<span class="hljs-keyword">\startxmlsetups</span> xml:html<br>  % "author" is a special setup, not generalized
  <span class="hljs-keyword">\xmlfilter</span>{<span class="hljs-params">#1</span>}{/head/meta[@name='author']/command(xml:author)}

  <span class="hljs-comment">% What goes here to make this dynamic?</span>
  <span class="hljs-comment">%\xmlfilter{#1}{/head/meta[@name='journal']/command(xml:journal)}</span>

  <span class="hljs-keyword">\xmlflush</span>{<span class="hljs-params">#1</span>}
<span class="hljs-keyword">\stopxmlsetups</span>

<span class="hljs-keyword">\startxmlsetups</span> xml:author
  <span class="hljs-keyword">\setupdocument</span>[author={<span class="hljs-keyword">\xmlatt</span>{<span class="hljs-params">#1</span>}{content}}]
  <span class="hljs-keyword">\setupdocument</span>[metadata:author={<span class="hljs-keyword">\xmlatt</span>{<span class="hljs-params">#1</span>}{content}}]
  <span class="hljs-keyword">\setupinteraction</span>[author={<span class="hljs-keyword">\documentvariable</span>{author}}]
<span class="hljs-keyword">\stopxmlsetups</span>

<span class="hljs-comment">% How can this be generalized?</span>
<span class="hljs-comment">%\startxmlsetups xml:journal</span>
  <span class="hljs-comment">%\setupdocument[journal={\xmlatt{#1}{content}}]</span>
<span class="hljs-comment">%\stopxmlsetups</span>

<span class="hljs-keyword">\startxmlsetups</span> xml:body
  <span class="hljs-keyword">\startdocument</span>
    Author: <span class="hljs-keyword">\documentvariable</span>{author}

    <span class="hljs-keyword">\par</span>

    Journal: <span class="hljs-keyword">\documentvariable</span>{journal}
  <span class="hljs-keyword">\stopdocument</span>
<span class="hljs-keyword">\stopxmlsetups</span>

<span class="hljs-keyword">\xmlprocessbuffer</span>{main}{xdoc}{}</code></pre></div><div><br></div><div>Thank you!<br></div><div><br></div></div>