ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* xmlpos values doubled
@ 2022-03-28  9:44 Ben Moon via ntg-context
  2022-04-20  9:51 ` Ben Moon via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Moon via ntg-context @ 2022-03-28  9:44 UTC (permalink / raw)
  To: Context Mailing List; +Cc: Ben Moon


[-- Attachment #1.1: Type: text/plain, Size: 2469 bytes --]

Hello All,

I'm trying to render a table stored in XML JATS format (https://jats.nlm.nih.gov/archiving/) and eventually want to use the <colgroup> tag to setup column aligning from the @align attribute, e.g.,

    \setupTABLE [column] [\xmlpos{#1}] [align=\xmlatt{#1}{align}]

Including \xmlpos{#1} I get double the value returned, i.e.: the first element in colgroup returns 2, the second returns 4 etc.

Below is a MWE to show my issue. I show \xmlpos for each <col> tag in <colgroup>  above the table, which returns 2, 4, 6, 8 but I expected 1, 2, 3, 4. Am I missing something or is there another way I could do this?

~~~~~~~~~~~~
\startbuffer[table]
  <table-wrap>
    <table>
      <colgroup>
        <col align="center" />
        <col align="right" />
        <col />
        <col />
      </colgroup>
      <thead>
        <tr>
          <th>H1 (centre)</th>
          <th>H2 (right)</th>
          <th>H3</th>
          <th>H4</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>A1</td>
          <td>A2</td>
          <td>A3</td>
          <td>A4</td>
        </tr>
        <tr>
          <td>B1</td>
          <td>B2</td>
          <td>B3</td>
          <td>B4</td>
        </tr>
      </tbody>
    </table>
  </table-wrap>
\stopbuffer

\startxmlsetups xml:tabletestsetups
    \xmlsetsetup{#1}{*}{-}
    % tables
    \xmlsetsetup{#1}{table-wrap|table}{xml:*}
    \xmlsetsetup{#1}{thead|tbody|tr|th|td}{xml:table:*}
    \xmlsetsetup{#1}{colgroup|col}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:tabletestsetups}

\startxmlsetups xml:table-wrap
    \startplacetable
        % \contextversion \par
        \xmlflush{#1}
    \stopplacetable
\stopxmlsetups

\startxmlsetups xml:table
    \bTABLE
        \xmlflush{#1}
    \eTABLE
\stopxmlsetups

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

\startxmlsetups xml:col
    \xmlpos{#1} \xmlatt{#1}{align}\par
\stopxmlsetups

\startxmlsetups xml:table:thead
    \bTABLEhead
        \xmlflush{#1}
    \eTABLEhead
\stopxmlsetups

\startxmlsetups xml:table:tr
    \bTR
        \xmlflush{#1}
    \eTR
\stopxmlsetups

\startxmlsetups xml:table:th
    \bTH
        \xmlflush{#1}
    \eTH
\stopxmlsetups

\startxmlsetups xml:table:tbody
    \bTABLEbody
        \xmlflush{#1}
    \eTABLEbody
\stopxmlsetups

\startxmlsetups xml:table:td
    \bTC
        \xmlflush{#1}
    \eTC
\stopxmlsetups

\xmlprocessbuffer{main}{table}{}
~~~~~~~~~~~~

All the best,
Ben

Ben Moon
ben@themoons.uk

[-- Attachment #1.2: Type: text/html, Size: 6354 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: xmlpos values doubled
  2022-03-28  9:44 xmlpos values doubled Ben Moon via ntg-context
@ 2022-04-20  9:51 ` Ben Moon via ntg-context
  2022-04-20 14:53   ` Pablo Rodriguez via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Moon via ntg-context @ 2022-04-20  9:51 UTC (permalink / raw)
  To: Context Mailing List; +Cc: Ben Moon


[-- Attachment #1.1: Type: text/plain, Size: 3464 bytes --]

Hello again,

I wonder whether anyone has some thoughts to help with my problem? Either why \xmlpos gives double values or alternatives to arrange my table format?

Best wishes,
Ben


On Mon, 28 Mar 2022, at 10:44, Ben Moon via ntg-context wrote:
> Hello All,
> 
> I'm trying to render a table stored in XML JATS format (https://jats.nlm.nih.gov/archiving/) and eventually want to use the <colgroup> tag to setup column aligning from the @align attribute, e.g.,
> 
>     \setupTABLE [column] [\xmlpos{#1}] [align=\xmlatt{#1}{align}]
> 
> Including \xmlpos{#1} I get double the value returned, i.e.: the first element in colgroup returns 2, the second returns 4 etc.
> 
> Below is a MWE to show my issue. I show \xmlpos for each <col> tag in <colgroup>  above the table, which returns 2, 4, 6, 8 but I expected 1, 2, 3, 4. Am I missing something or is there another way I could do this?
> 
> ~~~~~~~~~~~~
> \startbuffer[table]
>   <table-wrap>
>     <table>
>       <colgroup>
>         <col align="center" />
>         <col align="right" />
>         <col />
>         <col />
>       </colgroup>
>       <thead>
>         <tr>
>           <th>H1 (centre)</th>
>           <th>H2 (right)</th>
>           <th>H3</th>
>           <th>H4</th>
>         </tr>
>       </thead>
>       <tbody>
>         <tr>
>           <td>A1</td>
>           <td>A2</td>
>           <td>A3</td>
>           <td>A4</td>
>         </tr>
>         <tr>
>           <td>B1</td>
>           <td>B2</td>
>           <td>B3</td>
>           <td>B4</td>
>         </tr>
>       </tbody>
>     </table>
>   </table-wrap>
> \stopbuffer
> 
> \startxmlsetups xml:tabletestsetups
>     \xmlsetsetup{#1}{*}{-}
>     % tables
>     \xmlsetsetup{#1}{table-wrap|table}{xml:*}
>     \xmlsetsetup{#1}{thead|tbody|tr|th|td}{xml:table:*}
>     \xmlsetsetup{#1}{colgroup|col}{xml:*}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:tabletestsetups}
> 
> \startxmlsetups xml:table-wrap
>     \startplacetable
>         % \contextversion \par
>         \xmlflush{#1}
>     \stopplacetable
> \stopxmlsetups
> 
> \startxmlsetups xml:table
>     \bTABLE
>         \xmlflush{#1}
>     \eTABLE
> \stopxmlsetups
> 
> \startxmlsetups xml:colgroup
>     \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:col
>     \xmlpos{#1} \xmlatt{#1}{align}\par
> \stopxmlsetups
> 
> \startxmlsetups xml:table:thead
>     \bTABLEhead
>         \xmlflush{#1}
>     \eTABLEhead
> \stopxmlsetups
> 
> \startxmlsetups xml:table:tr
>     \bTR
>         \xmlflush{#1}
>     \eTR
> \stopxmlsetups
> 
> \startxmlsetups xml:table:th
>     \bTH
>         \xmlflush{#1}
>     \eTH
> \stopxmlsetups
> 
> \startxmlsetups xml:table:tbody
>     \bTABLEbody
>         \xmlflush{#1}
>     \eTABLEbody
> \stopxmlsetups
> 
> \startxmlsetups xml:table:td
>     \bTC
>         \xmlflush{#1}
>     \eTC
> \stopxmlsetups
> 
> \xmlprocessbuffer{main}{table}{}
> ~~~~~~~~~~~~
> 
> All the best,
> Ben
> 
> 
> Ben Moon
> ben@themoons.uk
> 
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
> 

[-- Attachment #1.2: Type: text/html, Size: 7744 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: xmlpos values doubled
  2022-04-20  9:51 ` Ben Moon via ntg-context
@ 2022-04-20 14:53   ` Pablo Rodriguez via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-04-20 14:53 UTC (permalink / raw)
  To: Ben Moon via ntg-context; +Cc: Pablo Rodriguez

On 4/20/22 11:51, Ben Moon via ntg-context wrote:
> Hello again,
>
> I wonder whether anyone has some thoughts to help with my problem?
> Either why \xmlpos gives double values or alternatives to arrange my
> table format?

Hi Ben,

I think that both \xmlpos and \xmldepth give weird results.

With this minimal sample:

  \startbuffer[text]
  <doc>first level
  <s>second level
  <ss>third level</ss>
  <ss>third level</ss>
  </s>
  <s>second level
  <ss>third level</ss>
  <ss>third level</ss>
  </s>
  <s>second level
  <ss>third level</ss>
  <ss>third level</ss>
  </s>
  </doc>
  \stopbuffer

  \startxmlsetups xml:text
      \xmlsetsetup{#1}{doc|s|ss}{xml:*}
  \stopxmlsetups

  \xmlregistersetup{xml:text}

  \startxmlsetups xml:doc
      \chapter{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
  \stopxmlsetups

  \startxmlsetups xml:s
      \section{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
  \stopxmlsetups

  \startxmlsetups xml:ss
      \subsection{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
  \stopxmlsetups

  \setuphead[chapter,section,subsection][before=,after=,]
  \starttext
  \xmlprocessbuffer{main}{text}{}
  \stoptext

\xmldepth shows values that I think are +1 than they should be.

\xmlpos counts in pairs and not in units (as you wrote, 2, 4, 6...).

Hans, could you check whether this is working as expected?

Sorry, but if this isn’t a bug, I have no idea of what I may be missing.

Pablo

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-20 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28  9:44 xmlpos values doubled Ben Moon via ntg-context
2022-04-20  9:51 ` Ben Moon via ntg-context
2022-04-20 14:53   ` Pablo Rodriguez via ntg-context

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).