ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* XML attributes
@ 2003-06-05 22:06 Jedrzej Nasiadek
  2003-06-06 19:37 ` Simon Pepping
  0 siblings, 1 reply; 13+ messages in thread
From: Jedrzej Nasiadek @ 2003-06-05 22:06 UTC (permalink / raw)



Hi,

So I've got to use this modern XML thingy.. ;-)
I tried to set up ConTeXt to typeset processed XML data.
What goes wrong is the \XMLpar which sometimes gives default value
instead of the real one. See the code below:

\starttext
\defineXMLpickup [log]
   {\starttabulate[|p(7cm)|p|] \HL\NC ObjectID \NC Value \NC\NR\HL}
   {\stoptabulate}

\defineXMLenvironment [var]
    {\NC \XMLpar{var}{name}{blah} \NC }
    {\NC\NR }

\startXMLdata
<log>
<entry date="1054844187">
<var name=".1.3.6.1.2.1.5.16.0"> 28674524 </var>
</entry>
<entry date="1054844247">
<var name=".1.3.6.1.2.1.5.16.0"> 28674677 </var>
</entry>
<entry date="1054844307">
<var name=".1.3.6.1.2.1.5.16.0"> 28674824 </var>
</entry>
<entry date="1054844367">
<var name=".1.3.6.1.2.1.5.16.0"> 28674963 </var>
</entry>
</log>
\stopXMLdata

\stoptext


If I remove the \NC before \XMLpar -- it gives the real value of the
name attribute. 

  Jedrzej

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

* Re: XML attributes
  2003-06-05 22:06 XML attributes Jedrzej Nasiadek
@ 2003-06-06 19:37 ` Simon Pepping
  2003-06-06 20:55   ` Jedrzej Nasiadek
  2003-06-07  0:03   ` Jedrzej Nasiadek
  0 siblings, 2 replies; 13+ messages in thread
From: Simon Pepping @ 2003-06-06 19:37 UTC (permalink / raw)


Tables make a lot of groups. When your <var> tag is read, your
parameter is defined in a group. When you use it in the next cell, you
are in another group, and your parameter value has disappeared. Try
this:

\defineXMLenvironment [var]
    {\xdef\varname{\XMLpar{var}{name}{blah}} \NC \varname \NC }
    {\NC\NR }

On Fri, Jun 06, 2003 at 12:06:39AM +0200, Jedrzej Nasiadek wrote:
> 
> Hi,
> 
> So I've got to use this modern XML thingy.. ;-)
> I tried to set up ConTeXt to typeset processed XML data.
> What goes wrong is the \XMLpar which sometimes gives default value
> instead of the real one. See the code below:
> 
> \starttext
> \defineXMLpickup [log]
>    {\starttabulate[|p(7cm)|p|] \HL\NC ObjectID \NC Value \NC\NR\HL}
>    {\stoptabulate}
> 
> \defineXMLenvironment [var]
>     {\NC \XMLpar{var}{name}{blah} \NC }
>     {\NC\NR }
> 
> \startXMLdata
> <log>
> <entry date="1054844187">
> <var name=".1.3.6.1.2.1.5.16.0"> 28674524 </var>
> </entry>
> <entry date="1054844247">
> <var name=".1.3.6.1.2.1.5.16.0"> 28674677 </var>
> </entry>
> <entry date="1054844307">
> <var name=".1.3.6.1.2.1.5.16.0"> 28674824 </var>
> </entry>
> <entry date="1054844367">
> <var name=".1.3.6.1.2.1.5.16.0"> 28674963 </var>
> </entry>
> </log>
> \stopXMLdata
> 
> \stoptext
> 
> 
> If I remove the \NC before \XMLpar -- it gives the real value of the
> name attribute. 
> 
>   Jedrzej
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl

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

* Re: XML attributes
  2003-06-06 19:37 ` Simon Pepping
@ 2003-06-06 20:55   ` Jedrzej Nasiadek
  2003-06-13 16:18     ` Hans Hagen
  2003-06-07  0:03   ` Jedrzej Nasiadek
  1 sibling, 1 reply; 13+ messages in thread
From: Jedrzej Nasiadek @ 2003-06-06 20:55 UTC (permalink / raw)



> \defineXMLenvironment [var]
>     {\xdef\varname{\XMLpar{var}{name}{blah}} \NC \varname \NC }
>     {\NC\NR }

Hah!  Now it works like charm :-) Thanks Simon!

Jedrzej

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

* Re: XML attributes
  2003-06-06 19:37 ` Simon Pepping
  2003-06-06 20:55   ` Jedrzej Nasiadek
@ 2003-06-07  0:03   ` Jedrzej Nasiadek
  1 sibling, 0 replies; 13+ messages in thread
From: Jedrzej Nasiadek @ 2003-06-07  0:03 UTC (permalink / raw)



> \defineXMLenvironment [var]
>     {\xdef\varname{\XMLpar{var}{name}{blah}} \NC \varname \NC }
>     {\NC\NR }

Hah!  Now it works like charm :-) Thanks Simon!

Jedrzej

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

* Re: XML attributes
  2003-06-06 20:55   ` Jedrzej Nasiadek
@ 2003-06-13 16:18     ` Hans Hagen
  0 siblings, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2003-06-13 16:18 UTC (permalink / raw)


At 22:55 06/06/2003 +0200, you wrote:

> > \defineXMLenvironment [var]
> >     {\xdef\varname{\XMLpar{var}{name}{blah}} \NC \varname \NC }
> >     {\NC\NR }
>
>Hah!  Now it works like charm :-) Thanks Simon!

or better:

   \defineXMLenvironment [var] {\expanded {\NC \XMLpar {var} {name}} \NC} 
{\NC \NR}

since you need the expanded value in a collected content like tabulate

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

* Re: XML attributes
  2002-07-10 20:05 ` Simon Pepping
@ 2002-07-12 16:31   ` Hans Hagen
  0 siblings, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2002-07-12 16:31 UTC (permalink / raw)
  Cc: ntg-context

At 10:05 PM 7/10/2002 +0200, Simon Pepping wrote:
>On Wed, Jul 10, 2002 at 08:51:44AM +0200, scarsoluigi@libero.it wrote:
> > So, another question (yes,  I have texbook but i'm a novice):
> >
> > give
> > <node attr="<context command or enviroinment">
> > ...
> > </node>
> >
> > where <context command or enviroinment> is for example
> >  {\bf}
> > or
> >  \startframedtexts[...setups..] ... \stopframedtexts
> >
> > how can i 'execute'  under context the attr value ?
>
>You cannot. An attribute is not supposed to be an action; it is a
>value to which you may associate an action in your context
>mapping. The context XML documentation, example.pdf, shows how you can
>use attribute values directly as arguments in a context command, but
>that is as far as you can go.

right, of course you can use processing instructions

<?context-command ...?>

given that this feature is enabled (\setupXMLprocessing[command=yes])

or you can tex an attribute

\def\xxxx{....}
\disableXML\scantokens\expandafter{\xxxx}\enableXML

but i agree with simon that this is not what attributes are for; actually, 
this is also what is wrong with svg

Hans

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------


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

* Re: XML attributes
  2002-07-10  6:51 scarsoluigi
@ 2002-07-10 20:05 ` Simon Pepping
  2002-07-12 16:31   ` Hans Hagen
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Pepping @ 2002-07-10 20:05 UTC (permalink / raw)


On Wed, Jul 10, 2002 at 08:51:44AM +0200, scarsoluigi@libero.it wrote:
> So, another question (yes,  I have texbook but i'm a novice):
> 
> give
> <node attr="<context command or enviroinment">
> ...
> </node>
> 
> where <context command or enviroinment> is for example
>  {\bf} 
> or 
>  \startframedtexts[...setups..] ... \stopframedtexts
> 
> how can i 'execute'  under context the attr value ?

You cannot. An attribute is not supposed to be an action; it is a
value to which you may associate an action in your context
mapping. The context XML documentation, example.pdf, shows how you can
use attribute values directly as arguments in a context command, but
that is as far as you can go.

Regards, Simon

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl


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

* Re: XML attributes
@ 2002-07-10  6:51 scarsoluigi
  2002-07-10 20:05 ` Simon Pepping
  0 siblings, 1 reply; 13+ messages in thread
From: scarsoluigi @ 2002-07-10  6:51 UTC (permalink / raw)


> \edef\tmp{\XMLpar{node}{type}{}
> \doifelse{\tmp}{type1}{case for type1}
>       {\doifelse{\tmp}{type2}{case for type2}
>               {case for other values}}}
> 
> or
> 
> \processaction[\XMLpar{node}{type}{default}]
>       [  type1=>case for type1,
>          type2=>case for type2,
>        default=>default case]
> 
many thanks simon, I will work on it today.
So, another question (yes,  I have texbook but i'm a novice):

give
<node attr="<context command or enviroinment">
...
</node>

where <context command or enviroinment> is for example
 {\bf} 
or 
 \startframedtexts[...setups..] ... \stopframedtexts

how can i 'execute'  under context the attr value ?

thanks
luigi


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

* Re: XML attributes
  2002-07-09  9:47 scarsoluigi
@ 2002-07-09 19:05 ` Simon Pepping
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Pepping @ 2002-07-09 19:05 UTC (permalink / raw)


On Tue, Jul 09, 2002 at 11:47:01AM +0200, scarsoluigi@libero.it wrote:
> Hi, i'm just working on xml and context and i have the following
> question:
> give the following doc. fragm.
> 
> <node type="type1">
>   <node type="type2">
>     <leaf>LEAF</leaf>
>   </node>
>   <node >FLAT</node>
> </node>
>      
> 
> How can i discriminate <node> by attribute, and how to recognize <node>
> without attribute?

\edef\tmp{\XMLpar{node}{type}{}
\doifelse{\tmp}{type1}{case for type1}
	{\doifelse{\tmp}{type2}{case for type2}
		{case for other values}}}

or

\processaction[\XMLpar{node}{type}{default}]
	[  type1=>case for type1,
	   type2=>case for type2,
	 default=>default case]

> Thanks
> luigi

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl


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

* XML attributes
@ 2002-07-09  9:47 scarsoluigi
  2002-07-09 19:05 ` Simon Pepping
  0 siblings, 1 reply; 13+ messages in thread
From: scarsoluigi @ 2002-07-09  9:47 UTC (permalink / raw)


Hi, i'm just working on xml and context and i have the following
question:
give the following doc. fragm.

<node type="type1">
  <node type="type2">
    <leaf>LEAF</leaf>
  </node>
  <node >FLAT</node>
</node>

How can i discriminate <node> by attribute, and how to recognize <node>
without attribute?
Thanks
luigi


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

* Re: XML attributes
  2001-10-15  7:56 ` Hans Hagen
@ 2001-10-15 18:50   ` Simon Pepping
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Pepping @ 2001-10-15 18:50 UTC (permalink / raw)


On Mon, Oct 15, 2001 at 09:56:32AM +0200, Hans Hagen wrote:
> At 11:08 PM 10/13/2001 +0200, Simon Pepping wrote:
> >I have been experimenting a bit with attributes, e.g. in this phrase:
> ><item>And even worse<ref/>, <ref name="att"/> attributes <ref/> will not 
> >be the
> >same as in &context;.</item>
> >
> >1. In the third ref element, the value \XMLpar{ref}{name}{\relax} is
> >    not relax. Because the element has no (rather an implicit)
> >    attribute name, the context value is left as it was set by the
> >    preceding ref element. I think it would be better if attribute
> >    values are local to the element, and there exists a command that
> >    lets the user store the value in a control sequence, much like
> >    \defXMLstring\command.
> 
> locality is a bit of a problem since you don't want tex's grouping to 
> interfere;
> 
> this is why the following method is to be used (eg):
> 
> \defineXMLenvironment[whatever][bla=,junk=]
> 
> now, each time the element is encountered, 'bla' and 'junk' are set to 
> nothing, so you start afresh.

That is not yet described in example.pdf. I saw it in an example you
gave me, but it has no effect. Perhaps in an updated version (mine is
cont-tmf from 9 August)?

Simon

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl


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

* Re: XML attributes
  2001-10-13 21:08 Simon Pepping
@ 2001-10-15  7:56 ` Hans Hagen
  2001-10-15 18:50   ` Simon Pepping
  0 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2001-10-15  7:56 UTC (permalink / raw)
  Cc: ntg-context

At 11:08 PM 10/13/2001 +0200, Simon Pepping wrote:
>I have been experimenting a bit with attributes, e.g. in this phrase:
><item>And even worse<ref/>, <ref name="att"/> attributes <ref/> will not 
>be the
>same as in &context;.</item>
>
>1. In the third ref element, the value \XMLpar{ref}{name}{\relax} is
>    not relax. Because the element has no (rather an implicit)
>    attribute name, the context value is left as it was set by the
>    preceding ref element. I think it would be better if attribute
>    values are local to the element, and there exists a command that
>    lets the user store the value in a control sequence, much like
>    \defXMLstring\command.
>
>2. When I use the attribute like this:
>    \doifXMLparelse{ref}{name}{(ref:\XMLpar{ref}{name}{})}{}, it would
>    be nice to have a shorter way to access the attribute value, say
>    \XMLattvalue. The above code contains two implicit if/then branches
>    for the attribute, the second not very useful.

locality is a bit of a problem since you don't want tex's grouping to 
interfere;

this is why the following method is to be used (eg):

\defineXMLenvironment[whatever][bla=,junk=]

now, each time the element is encountered, 'bla' and 'junk' are set to 
nothing, so you start afresh.

concerning the second question: there is \XMLpar{element}{name}{default} 
and there will be a \XMLparself too as well as a \XMLNSpar one for 
namespaced pars (this kind of works now). There are (in the release that 
will be posted soon) now severel modes of operandi with respect to handling 
element namespaces and attribute namespaces. I just implemented &#number; 
things and there are methods to turn thngs like

key="value&value;and&tex;and&#123;andworse&eacute;"

into tex robust things (again several methods) which is handy when they are 
used in for instance cross referencing.

[as a bonus the module is sped up a bit; i use the maps biblography as 
reference run: some 139 sec now, while 150 last month).

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


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

* XML attributes
@ 2001-10-13 21:08 Simon Pepping
  2001-10-15  7:56 ` Hans Hagen
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Pepping @ 2001-10-13 21:08 UTC (permalink / raw)


I have been experimenting a bit with attributes, e.g. in this phrase:
<item>And even worse<ref/>, <ref name="att"/> attributes <ref/> will not be the
same as in &context;.</item>

1. In the third ref element, the value \XMLpar{ref}{name}{\relax} is
   not relax. Because the element has no (rather an implicit)
   attribute name, the context value is left as it was set by the
   preceding ref element. I think it would be better if attribute
   values are local to the element, and there exists a command that
   lets the user store the value in a control sequence, much like
   \defXMLstring\command.

2. When I use the attribute like this:
   \doifXMLparelse{ref}{name}{(ref:\XMLpar{ref}{name}{})}{}, it would
   be nice to have a shorter way to access the attribute value, say
   \XMLattvalue. The above code contains two implicit if/then branches
   for the attribute, the second not very useful.

Regards, Simon

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl


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

end of thread, other threads:[~2003-06-13 16:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-05 22:06 XML attributes Jedrzej Nasiadek
2003-06-06 19:37 ` Simon Pepping
2003-06-06 20:55   ` Jedrzej Nasiadek
2003-06-13 16:18     ` Hans Hagen
2003-06-07  0:03   ` Jedrzej Nasiadek
  -- strict thread matches above, loose matches on Subject: below --
2002-07-10  6:51 scarsoluigi
2002-07-10 20:05 ` Simon Pepping
2002-07-12 16:31   ` Hans Hagen
2002-07-09  9:47 scarsoluigi
2002-07-09 19:05 ` Simon Pepping
2001-10-13 21:08 Simon Pepping
2001-10-15  7:56 ` Hans Hagen
2001-10-15 18:50   ` Simon Pepping

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