ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Refering to parent in XML
@ 2015-08-25 18:18 Xan
  2015-08-26  7:18 ` Hans Hagen
  2015-08-27  9:00 ` Xan
  0 siblings, 2 replies; 4+ messages in thread
From: Xan @ 2015-08-25 18:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

I have this environment:

\startenvironment processadorxml

% Activitat: defineix \Activitat{activitat-id}
\def\Activitat#1%
  {\xmlfilter{rebost}
    {/activitats/activitat[@id=='#1']/command(xml:list)}
  }

% Simplement llistam totes les presentacions.  
\startxmlsetups xml:list
 \startactivitat{\xmlatt{#1}{id}}
  \startitemize
    \xmlfilter{#1}{/presentacio/command(xml:itemize)}
  \stopitemize
 \stopactivitat
\stopxmlsetups

\startxmlsetups xml:itemize
  \startitem[\xmlatt{#1}{tipus}]
    {\ss [\xmlatt{#1}{tipus}]}\space 
    {\xmlflushcontext{#1}}
  \stopitem
\stopxmlsetups





% Presentació: defineix \Presentacio{activitat-id}{presentacio-id}
\def\Presentacio#1#2%
  {\xmlfilter{rebost}
    {/activitats/activitat[@id=='#1']/presentacio[@tipus=='#2']/command(xml:display)}
  }

% Si la presentació és de tipus tradicional, aleshores és un 'exercici'. Altrament és una activitat.
\startxmlsetups xml:display
  \doifelse{\xmlattribute{#1}{.}{tipus}} {tradicional}
  {\startexercici{\xmlatt{#1}{id}}\xmlname{#1}\xmlname{/}
    \xmlflushcontext{#1}
  \stopexercici}
  {\startactivitat{\xmlatt{#1}{id}}
    \xmlflushcontext{#1}
   \stopactivitat
  }
\stopxmlsetups

\stopenvironment



and this file:

\environment ../plantilles/entorn-simple-estructurals-xml
\environment ../plantilles/entorn-simple-estructurals
\environment ../plantilles/entorn-simple-visuals

\xmlloadonly{rebost}{dades/activitats.xml}{}

\starttext

Activitat: llista totes les presentacions
\Activitat{fitxes}

Presentació específica: només en fa una
\Presentacio{fitxes}{tradicional}
\Presentacio{fitxes}{3-act}

\startexercici B
\stopexercici

\stoptext



My XML file is:
<?xml version="1.0" standalone='yes'?>
<activitats>
  <activitat id="fitxes">
    <presentacio tipus="tradicional">La fitxa blava i la fitxa vermella es mouen de la manera següent: la blava recorre les caselles d'una en una, mentre que la vermella les recorre de dues en dues però, després de cada moviment, s'espera un torn (figura~\in[]). Quina de les dues fitxes arribarà primer a la meta?
    </presentacio>
    <presentacio tipus="3-act" >Disponible aquí: URL</presentacio>
  </activitat>
</activitats>


The problem is when I change #1 by '..' in:
% Si la presentació és de tipus tradicional, aleshores és un 'exercici'. Altrament és una activitat.
\startxmlsetups xml:display
  \doifelse{\xmlattribute{#1}{.}{tipus}} {tradicional}
  {\startexercici{\xmlatt{#1}{id}}\xmlname{#1}\xmlname{/}
    \xmlflushcontext{#1}
  \stopexercici}
  {\startactivitat{\xmlatt{#1}{id}}
    \xmlflushcontext{#1}
   \stopactivitat
  }
\stopxmlsetups

I get empty string. I supposed that \xmlatt{..}{id} gives me the id of the <presentacio>.

Any hints?

Sorry. I'm just starting experimenting with XML and ConTeXt... ;-)
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Refering to parent in XML
  2015-08-25 18:18 Refering to parent in XML Xan
@ 2015-08-26  7:18 ` Hans Hagen
  2015-08-27  9:00 ` Xan
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2015-08-26  7:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 8/25/2015 8:18 PM, Xan wrote:
> Hi,
>
> I have this environment:
>
> \startenvironment processadorxml
>
> % Activitat: defineix \Activitat{activitat-id}
> \def\Activitat#1%
>    {\xmlfilter{rebost}
>      {/activitats/activitat[@id=='#1']/command(xml:list)}
>    }
>
> % Simplement llistam totes les presentacions.
> \startxmlsetups xml:list
>   \startactivitat{\xmlatt{#1}{id}}
>    \startitemize
>      \xmlfilter{#1}{/presentacio/command(xml:itemize)}
>    \stopitemize
>   \stopactivitat
> \stopxmlsetups
>
> \startxmlsetups xml:itemize
>    \startitem[\xmlatt{#1}{tipus}]
>      {\ss [\xmlatt{#1}{tipus}]}\space
>      {\xmlflushcontext{#1}}
>    \stopitem
> \stopxmlsetups
>
>
>
>
>
> % Presentació: defineix \Presentacio{activitat-id}{presentacio-id}
> \def\Presentacio#1#2%
>    {\xmlfilter{rebost}
>      {/activitats/activitat[@id=='#1']/presentacio[@tipus=='#2']/command(xml:display)}
>    }
>
> % Si la presentació és de tipus tradicional, aleshores és un 'exercici'. Altrament és una activitat.
> \startxmlsetups xml:display
>    \doifelse{\xmlattribute{#1}{.}{tipus}} {tradicional}
>    {\startexercici{\xmlatt{#1}{id}}\xmlname{#1}\xmlname{/}
>      \xmlflushcontext{#1}
>    \stopexercici}
>    {\startactivitat{\xmlatt{#1}{id}}
>      \xmlflushcontext{#1}
>     \stopactivitat
>    }
> \stopxmlsetups
>
> \stopenvironment
>
>
>
> and this file:
>
> \environment ../plantilles/entorn-simple-estructurals-xml
> \environment ../plantilles/entorn-simple-estructurals
> \environment ../plantilles/entorn-simple-visuals
>
> \xmlloadonly{rebost}{dades/activitats.xml}{}
>
> \starttext
>
> Activitat: llista totes les presentacions
> \Activitat{fitxes}
>
> Presentació específica: només en fa una
> \Presentacio{fitxes}{tradicional}
> \Presentacio{fitxes}{3-act}
>
> \startexercici B
> \stopexercici
>
> \stoptext
>
>
>
> My XML file is:
> <?xml version="1.0" standalone='yes'?>
> <activitats>
>    <activitat id="fitxes">
>      <presentacio tipus="tradicional">La fitxa blava i la fitxa vermella es mouen de la manera següent: la blava recorre les caselles d'una en una, mentre que la vermella les recorre de dues en dues però, després de cada moviment, s'espera un torn (figura~\in[]). Quina de les dues fitxes arribarà primer a la meta?
>      </presentacio>
>      <presentacio tipus="3-act" >Disponible aquí: URL</presentacio>
>    </activitat>
> </activitats>
>
>
> The problem is when I change #1 by '..' in:
> % Si la presentació és de tipus tradicional, aleshores és un 'exercici'. Altrament és una activitat.
> \startxmlsetups xml:display
>    \doifelse{\xmlattribute{#1}{.}{tipus}} {tradicional}
>    {\startexercici{\xmlatt{#1}{id}}\xmlname{#1}\xmlname{/}
>      \xmlflushcontext{#1}
>    \stopexercici}
>    {\startactivitat{\xmlatt{#1}{id}}
>      \xmlflushcontext{#1}
>     \stopactivitat
>    }
> \stopxmlsetups
>
> I get empty string. I supposed that \xmlatt{..}{id} gives me the id of the <presentacio>.
>
> Any hints?

in a setup you can say: \xmlshow{#1} to see what is the (current) node

> Sorry. I'm just starting experimenting with XML and ConTeXt... ;-)
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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 / 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
___________________________________________________________________________________

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

* Re: Refering to parent in XML
  2015-08-25 18:18 Refering to parent in XML Xan
  2015-08-26  7:18 ` Hans Hagen
@ 2015-08-27  9:00 ` Xan
  2015-08-27 18:43   ` Hans Hagen
  1 sibling, 1 reply; 4+ messages in thread
From: Xan @ 2015-08-27  9:00 UTC (permalink / raw)
  To: Xan; +Cc: mailing list for ConTeXt users, Hans

> in a setup you can say: \xmlshow{#1} to see what is the (current) node

It does not help me.

I ask you in other way: if I have this

% Presentació: defineix \Presentacio{activitat-id}{presentacio-id}
\def\Presentacio#1#2%
  {\xmlfilter{rebost}
    {/activitats/activitat[@id=='#1']/presentacio[@tipus=='#2']/command(xml:display)}
  }

% Si la presentació és de tipus tradicional, aleshores és un 'exercici'. Altrament és una activitat.
\startxmlsetups xml:display
  \startitem[\xmlatt{..}{id}]
    \xmlflushcontext{#1}
  \stopexercici
\stopxmlsetups

gives me nothing in the label of startitem:
  \startitem[]
    contents....
  \stopexercici

 when I run \Presentacio{foo}{bar} and it *should* give me

  \startitem[foo]
    \xmlflushcontext{#1}
  \stopexercici


It seems like when I descend to activitat/presentacio then I can't go up.
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Refering to parent in XML
  2015-08-27  9:00 ` Xan
@ 2015-08-27 18:43   ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2015-08-27 18:43 UTC (permalink / raw)
  To: Xan; +Cc: mailing list for ConTeXt users

On 8/27/2015 11:00 AM, Xan wrote:
>> in a setup you can say: \xmlshow{#1} to see what is the (current) node
>
> It does not help me.
>
> I ask you in other way: if I have this
>
> % Presentació: defineix \Presentacio{activitat-id}{presentacio-id}
> \def\Presentacio#1#2%
>    {\xmlfilter{rebost}
>      {/activitats/activitat[@id=='#1']/presentacio[@tipus=='#2']/command(xml:display)}
>    }
>
> % Si la presentació és de tipus tradicional, aleshores és un 'exercici'. Altrament és una activitat.
> \startxmlsetups xml:display
>    \startitem[\xmlatt{..}{id}]
>      \xmlflushcontext{#1}
>    \stopexercici
> \stopxmlsetups
>
> gives me nothing in the label of startitem:
>    \startitem[]
>      contents....
>    \stopexercici
>
>   when I run \Presentacio{foo}{bar} and it *should* give me
>
>    \startitem[foo]
>      \xmlflushcontext{#1}
>    \stopexercici
>
>
> It seems like when I descend to activitat/presentacio then I can't go up.

if you use commands that accept a path you can backtrack, like

\xmlall{#1}{../../*}


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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 / 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
___________________________________________________________________________________

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

end of thread, other threads:[~2015-08-27 18:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-25 18:18 Refering to parent in XML Xan
2015-08-26  7:18 ` Hans Hagen
2015-08-27  9:00 ` Xan
2015-08-27 18:43   ` Hans Hagen

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