Re: [NTG-context] Reverse traversing of xml.collected()?

2020-11-10 Thread Jano Kula
Hello!

On Fri, 1 May 2020 at 14:06, Gerben Wierda  wrote:

>
>
> On 1 May 2020, at 13:30, Hans Hagen  wrote:
>
> On 5/1/2020 11:31 AM, Gerben Wierda wrote:
>
> I’d like to travese the contents of an xml.collected() in a reverse order.
>
> it's an iterator
>
> What is the correct way to do it?
>
> xml.all
>
>
It had been awhile, so for the record.

I was looking for something similar and found out that adding a third
argument to the xml.collected reverses the iterations. Looks like the
argument has to be true in a boolean sense, so puting any "string" there
will do the trick.

for v in xml.collected(doc, "/chapter/section", "string") do
...
end

Jano
___
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
___


Re: [NTG-context] Reverse traversing of xml.collected()?

2020-05-01 Thread Gerben Wierda


> On 1 May 2020, at 13:30, Hans Hagen  wrote:
> 
> On 5/1/2020 11:31 AM, Gerben Wierda wrote:
>> I’d like to travese the contents of an xml.collected() in a reverse order. I 
>> have
>> for connectionFromXML in xml.collected(viewFromXML,"/connection") do
>>   parseXMLConnection( rootFromXML, connectionFromXML, viewFromXML, 
>> rootFromOverrideXML)
>> end
>> I tried:
>> local relationTable = xml.collected(viewFromXML,"/connection")
>> for i=#relationTable, 1, -1 do
>>   connectionFromXML = relationTable[i]
>>   parseXMLConnection( rootFromXML, connectionFromXML, viewFromXML, 
>> rootFromOverrideXML)
>> end
>> But apparently my lua knowledge is lacking (severely, I might say) as this 
>> ends with “attempt to get length of a function value“
> 
> it's an iterator
> 
>> What is the correct way to do it?
> xml.all

Tried to find documentation, but failed.

Tried this:

local relationTable = xml.all(viewFromXML,"/connection")
for i=#relationTable, 1, -1 do
  connectionFromXML = relationTable[i]
  parseXMLConnection( rootFromXML, connectionFromXML, viewFromXML, 
rootFromOverrideXML)
end

but it fails as well.

G

> 
> -
>  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 / 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
___


Re: [NTG-context] Reverse traversing of xml.collected()?

2020-05-01 Thread Hans Hagen

On 5/1/2020 11:31 AM, Gerben Wierda wrote:
I’d like to travese the contents of an xml.collected() in a reverse 
order. I have


     for connectionFromXML in xml.collected(viewFromXML,"/connection") do
       parseXMLConnection( rootFromXML, connectionFromXML, viewFromXML, 
rootFromOverrideXML)

     end

I tried:

     local relationTable = xml.collected(viewFromXML,"/connection")
     for i=#relationTable, 1, -1 do
       connectionFromXML = relationTable[i]
       parseXMLConnection( rootFromXML, connectionFromXML, viewFromXML, 
rootFromOverrideXML)

     end

But apparently my lua knowledge is lacking (severely, I might say) as 
this ends with “attempt to get length of a function value“


it's an iterator


What is the correct way to do it?

xml.all

-
  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 / 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
___