ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Unexpected results with \xmlpos
@ 2023-02-16  9:16 Denis Maier via ntg-context
  2023-02-16 22:44 ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Maier via ntg-context @ 2023-02-16  9:16 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier


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

Hi,

I'm getting unexpected results for \xmlpos
With the example below, I was expecting to get the following positions:
1 2 3 4
However the result is: 2 4 6 8, i.e. each time it's exactly the double.

What am I missing?

Background: I need to define column alignment based on the value of the <col> element inside the colgroup, so I was thinking about something like this :

\xmlmapvalue{colstyle}{dir: rtl}{align=righttolef }
\xmlmapvalue{colstyle}{dir: ltr}{align=lefttoright}

\startxmlsetups xml:table:colgroup:col
  \setupTABLE[c][\xmlpos{#1}][\xmlvalue{colstyle}{\xmlatt{#1}{style}}{}]
\stopxmlsetups

Best,
Denis

\startbuffer[test]
<?xml version='1.0' standalone='yes?>
<document>
<table-wrap>
                <table>
                   <colgroup>
                                 <col/>
                                 <col style="dir: rtl"/>
                                 <col style="dir: rtl"/>
                                 <col/>
                   </colgroup>
                   <thead>
                                 <tr>
                                               <th>a</th>
                                               <th>b</th>
                                               <th>c</th>
                                               <th>d</th>
                                 </tr>
                   </thead>
                   <tbody>
                                 <tr>
                                               <td>a</td>
                                               <td>b</td>
                                               <td>c</td>
                                               <td>d</td>
                                 </tr>
                   </tbody>
                </table>
</table-wrap>
</document>
\stopbuffer

\startxmlsetups xml:test
\xmlsetsetup{\xmldocument}{document}{xml:*}
\xmlsetsetup{#1}{table-wrap}{xml:table-wrap}
\xmlsetsetup{#1}{table}{xml:table}
\stopxmlsetups

\xmlregistersetup{xml:test}

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

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

\startxmlsetups xml:table:colgroup
                %\xmlvalue{colstyle}{\xmlatt{#1}{style}}{}
                \xmlfilter {#1} {/col/command(xml:table:colgroup:col)}
\stopxmlsetups

\startxmlsetups xml:table:colgroup:col
                %\xmlvalue{colstyle}{\xmlatt{#1}{style}}{}
                \xmlpos {#1}
\stopxmlsetups

\startxmlsetups xml:table
  \xmlfilter {#1} {/colgroup/command(xml:table:colgroup)}
  \bTABLE
                \xmlfilter{#1}{/thead/command(xml:table:thead)}
                \xmlfilter{#1}{/tbody/command(xml:table:tbody)}
  \eTABLE
\stopxmlsetups

\startxmlsetups xml:table:thead
                \bTABLEhead
                               \xmlfilter{#1}{/tr/command(xml:table:thead:tr)}
                \eTABLEhead
\stopxmlsetups

\startxmlsetups xml:table:thead:tr
                \bTR
                               \xmlfilter{#1}{/th/command(xml:table:thead:tr:th)}
                \eTR
\stopxmlsetups

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

\startxmlsetups xml:table:tbody
\bTABLEbody\xmlfilter{#1}{/tr/command(xml:table:tbody:tr)}\eTABLEbody
\stopxmlsetups

\startxmlsetups xml:table:tbody:tr
\bTR\xmlfilter{#1}{/td/command(xml:table:tbody:tr:td)}\eTR
\stopxmlsetups

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


\starttext
  \xmlprocessbuffer{test}{test}{}
\stoptext

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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Unexpected results with \xmlpos
  2023-02-16  9:16 Unexpected results with \xmlpos Denis Maier via ntg-context
@ 2023-02-16 22:44 ` Hans Hagen via ntg-context
  2023-02-20 14:31   ` \xmlmap errors when returning key-value Denis Maier via ntg-context
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2023-02-16 22:44 UTC (permalink / raw)
  To: Denis Maier via ntg-context; +Cc: Hans Hagen

On 2/16/2023 10:16 AM, Denis Maier via ntg-context wrote:
> Hi,
> 
> I’m getting unexpected results for \xmlpos
> 
> With the example below, I was expecting to get the following positions:
> 
> 1 2 3 4
> 
> However the result is: 2 4 6 8, i.e. each time it’s exactly the double.
> 
> What am I missing?

that there are spaces between elements .. you can try:

\xmlmatch {#1}

instead

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* \xmlmap errors when returning key-value
  2023-02-16 22:44 ` Hans Hagen via ntg-context
@ 2023-02-20 14:31   ` Denis Maier via ntg-context
  2023-02-22 13:38     ` Denis Maier via ntg-context
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Maier via ntg-context @ 2023-02-20 14:31 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier

> -----Ursprüngliche Nachricht-----
> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Hans Hagen
> via ntg-context
> Gesendet: Donnerstag, 16. Februar 2023 23:45
> An: Denis Maier via ntg-context <ntg-context@ntg.nl>
> Cc: Hans Hagen <j.hagen@freedom.nl>
> Betreff: Re: [NTG-context] Unexpected results with \xmlpos
> 
> On 2/16/2023 10:16 AM, Denis Maier via ntg-context wrote:
> > Hi,
> >
> > I’m getting unexpected results for \xmlpos
> >
> > With the example below, I was expecting to get the following positions:
> >
> > 1 2 3 4
> >
> > However the result is: 2 4 6 8, i.e. each time it’s exactly the double.
> >
> > What am I missing?
> 
> that there are spaces between elements .. you can try:
> 
> \xmlmatch {#1}
> 
> instead
> 
> Hans

Thanks, that does the trick.

However, now I get an error when I try to return a key-value setting via xmlmap, see below. Any hints why this does not work

\xmlmapvalue{colgroupalign}{dir: rtl}{align=righttoleft}
\xmlmapvalue{colgroupalign}{dir: ltr}{align=lefttoright}

as opposed to:

\xmlmapvalue{colgroupalignvar}{dir: rtl}{righttoleft}
\xmlmapvalue{colgroupalignvar}{dir: ltr}{lefttoright}

?

Best,
Denis

\startbuffer[test]
<?xml version='1.0' standalone='yes?>
<document>
<table-wrap>
	<table>
	   <colgroup>
		  <col/>
		  <col style="dir: rtl"/>
		  <col style="dir: rtl"/>
		  <col/>
	   </colgroup>
	   <thead>
		  <tr>
			 <th>asdf</th>
			 <th>bsdf</th>
			 <th>csdf</th>
			 <th>dsdf</th>
		  </tr>
	   </thead>
	   <tbody>
		  <tr>
			 <td>a</td>
			 <td>b</td>
			 <td>c</td>
			 <td>d</td>
		  </tr>
	   </tbody>
	</table>
</table-wrap>
</document>
\stopbuffer

\startxmlsetups xml:test
\xmlsetsetup{\xmldocument}{document}{xml:*}
\xmlsetsetup{#1}{table-wrap}{xml:table-wrap}
\xmlsetsetup{#1}{table}{xml:table}
\stopxmlsetups

\xmlregistersetup{xml:test}

\xmlmapvalue{colgroupalign}{dir: rtl}{align=righttoleft}
\xmlmapvalue{colgroupalign}{dir: ltr}{align=lefttoright}

\xmlmapvalue{colgroupalignvar}{dir: rtl}{righttoleft}
\xmlmapvalue{colgroupalignvar}{dir: ltr}{lefttoright}

\startxmlsetups xml:table:colgroup
	\xmlfilter {#1} {/col/command(xml:table:colgroup:col)} % gives errors
	%\xmlfilter {#1} {/col/command(xml:table:colgroup:colvar)} % works
\stopxmlsetups

\startxmlsetups xml:table:colgroup:colvar
  \setupTABLE[c][\xmlmatch {#1}][align=\xmlvalue{colgroupalignvar}{\xmlatt{#1}{style}}{lefttoright}]
\stopxmlsetups

\startxmlsetups xml:table:colgroup:col
  \setupTABLE[c][\xmlmatch {#1}][\xmlvalue{colgroupalign}{\xmlatt{#1}{style}}{align=lefttoright}]
\stopxmlsetups

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

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

\startxmlsetups xml:table
  \xmlfilter {#1} {/colgroup/command(xml:table:colgroup)}
  \bTABLE
	\xmlfilter{#1}{/thead/command(xml:table:thead)}
	\xmlfilter{#1}{/tbody/command(xml:table:tbody)}
  \eTABLE
\stopxmlsetups

\startxmlsetups xml:table:thead
	\bTABLEhead
		\xmlfilter{#1}{/tr/command(xml:table:thead:tr)}
	\eTABLEhead
\stopxmlsetups

\startxmlsetups xml:table:thead:tr
	\bTR
		\xmlfilter{#1}{/th/command(xml:table:thead:tr:th)}
	\eTR
\stopxmlsetups

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

\startxmlsetups xml:table:tbody 
\bTABLEbody\xmlfilter{#1}{/tr/command(xml:table:tbody:tr)}\eTABLEbody
\stopxmlsetups

\startxmlsetups xml:table:tbody:tr
\bTR\xmlfilter{#1}{/td/command(xml:table:tbody:tr:td)}\eTR
\stopxmlsetups

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


\starttext
  \xmlprocessbuffer{test}{test}{}
\stoptext

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: \xmlmap errors when returning key-value
  2023-02-20 14:31   ` \xmlmap errors when returning key-value Denis Maier via ntg-context
@ 2023-02-22 13:38     ` Denis Maier via ntg-context
  0 siblings, 0 replies; 4+ messages in thread
From: Denis Maier via ntg-context @ 2023-02-22 13:38 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier

I maybe should have mentioned the error message I'm getting:

error in line 9, namespace '1CB>:', key 'align=lefttoright,'

Maybe that's helpful for tracking this down...

Best,
Denis

> -----Ursprüngliche Nachricht-----
> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Denis Maier
> via ntg-context
> Gesendet: Montag, 20. Februar 2023 15:32
> An: ntg-context@ntg.nl
> Cc: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
> Betreff: [NTG-context] \xmlmap errors when returning key-value
> 
> > -----Ursprüngliche Nachricht-----
> > Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Hans
> > Hagen via ntg-context
> > Gesendet: Donnerstag, 16. Februar 2023 23:45
> > An: Denis Maier via ntg-context <ntg-context@ntg.nl>
> > Cc: Hans Hagen <j.hagen@freedom.nl>
> > Betreff: Re: [NTG-context] Unexpected results with \xmlpos
> >
> > On 2/16/2023 10:16 AM, Denis Maier via ntg-context wrote:
> > > Hi,
> > >
> > > I’m getting unexpected results for \xmlpos
> > >
> > > With the example below, I was expecting to get the following positions:
> > >
> > > 1 2 3 4
> > >
> > > However the result is: 2 4 6 8, i.e. each time it’s exactly the double.
> > >
> > > What am I missing?
> >
> > that there are spaces between elements .. you can try:
> >
> > \xmlmatch {#1}
> >
> > instead
> >
> > Hans
> 
> Thanks, that does the trick.
> 
> However, now I get an error when I try to return a key-value setting via
> xmlmap, see below. Any hints why this does not work
> 
> \xmlmapvalue{colgroupalign}{dir: rtl}{align=righttoleft}
> \xmlmapvalue{colgroupalign}{dir: ltr}{align=lefttoright}
> 
> as opposed to:
> 
> \xmlmapvalue{colgroupalignvar}{dir: rtl}{righttoleft}
> \xmlmapvalue{colgroupalignvar}{dir: ltr}{lefttoright}
> 
> ?
> 
> Best,
> Denis
> 
> \startbuffer[test]
> <?xml version='1.0' standalone='yes?>
> <document>
> <table-wrap>
> 	<table>
> 	   <colgroup>
> 		  <col/>
> 		  <col style="dir: rtl"/>
> 		  <col style="dir: rtl"/>
> 		  <col/>
> 	   </colgroup>
> 	   <thead>
> 		  <tr>
> 			 <th>asdf</th>
> 			 <th>bsdf</th>
> 			 <th>csdf</th>
> 			 <th>dsdf</th>
> 		  </tr>
> 	   </thead>
> 	   <tbody>
> 		  <tr>
> 			 <td>a</td>
> 			 <td>b</td>
> 			 <td>c</td>
> 			 <td>d</td>
> 		  </tr>
> 	   </tbody>
> 	</table>
> </table-wrap>
> </document>
> \stopbuffer
> 
> \startxmlsetups xml:test
> \xmlsetsetup{\xmldocument}{document}{xml:*}
> \xmlsetsetup{#1}{table-wrap}{xml:table-wrap}
> \xmlsetsetup{#1}{table}{xml:table}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:test}
> 
> \xmlmapvalue{colgroupalign}{dir: rtl}{align=righttoleft}
> \xmlmapvalue{colgroupalign}{dir: ltr}{align=lefttoright}
> 
> \xmlmapvalue{colgroupalignvar}{dir: rtl}{righttoleft}
> \xmlmapvalue{colgroupalignvar}{dir: ltr}{lefttoright}
> 
> \startxmlsetups xml:table:colgroup
> 	\xmlfilter {#1} {/col/command(xml:table:colgroup:col)} % gives errors
> 	%\xmlfilter {#1} {/col/command(xml:table:colgroup:colvar)} % works
> \stopxmlsetups
> 
> \startxmlsetups xml:table:colgroup:colvar
>   \setupTABLE[c][\xmlmatch
> {#1}][align=\xmlvalue{colgroupalignvar}{\xmlatt{#1}{style}}{lefttoright}]
> \stopxmlsetups
> 
> \startxmlsetups xml:table:colgroup:col
>   \setupTABLE[c][\xmlmatch
> {#1}][\xmlvalue{colgroupalign}{\xmlatt{#1}{style}}{align=lefttoright}]
> \stopxmlsetups
> 
> \startxmlsetups xml:document
>   \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:table-wrap
> 	\startplacetable
> 	    \xmlflush{#1}
>     \stopplacetable
> \stopxmlsetups
> 
> \startxmlsetups xml:table
>   \xmlfilter {#1} {/colgroup/command(xml:table:colgroup)}
>   \bTABLE
> 	\xmlfilter{#1}{/thead/command(xml:table:thead)}
> 	\xmlfilter{#1}{/tbody/command(xml:table:tbody)}
>   \eTABLE
> \stopxmlsetups
> 
> \startxmlsetups xml:table:thead
> 	\bTABLEhead
> 		\xmlfilter{#1}{/tr/command(xml:table:thead:tr)}
> 	\eTABLEhead
> \stopxmlsetups
> 
> \startxmlsetups xml:table:thead:tr
> 	\bTR
> 		\xmlfilter{#1}{/th/command(xml:table:thead:tr:th)}
> 	\eTR
> \stopxmlsetups
> 
> \startxmlsetups xml:table:thead:tr:th
> 	\bTH
> 		\xmlflush{#1}
> 	\eTH
> \stopxmlsetups
> 
> \startxmlsetups xml:table:tbody
> \bTABLEbody\xmlfilter{#1}{/tr/command(xml:table:tbody:tr)}\eTABLEbody
> \stopxmlsetups
> 
> \startxmlsetups xml:table:tbody:tr
> \bTR\xmlfilter{#1}{/td/command(xml:table:tbody:tr:td)}\eTR
> \stopxmlsetups
> 
> \startxmlsetups xml:table:tbody:tr:td
> \bTC \xmlflush{#1} \eTC
> \stopxmlsetups
> 
> 
> \starttext
>   \xmlprocessbuffer{test}{test}{}
> \stoptext
> 
> __________________________________________________________
> _________________________
> If your question is of interest to others as well, please add an entry to the
> Wiki!
> 
> maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-
> context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
> __________________________________________________________
> _________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2023-02-22 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16  9:16 Unexpected results with \xmlpos Denis Maier via ntg-context
2023-02-16 22:44 ` Hans Hagen via ntg-context
2023-02-20 14:31   ` \xmlmap errors when returning key-value Denis Maier via ntg-context
2023-02-22 13:38     ` Denis Maier 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).