Re: [NTG-context] Reading XML with lua

2019-05-06 Thread Hans Hagen

On 5/3/2019 5:24 PM, Axel Kielhorn wrote:

Hi,

I’ m finally at a point where I can read an XML file look at it and write it 
back.

Right now I have two problems:

1. There are many empty entries in the table.
This makes processing the file a little tedious since I have to filter the real 
entries.

2. Some entries contain leading and trailing whitespace and linkebreaks.
These are the result of formatting the XML file.
Shouldn't
strip_cm_and_dt
take care of them?


no, as comments and doctype definitions are not the same as spaces


Or do I use that incorrectly?


the stored xml is largely roundtrip


I have included my lua file and an example xml.
You can run it with
mtxrun —script p.lua

Greetings Axel




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




--

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


[NTG-context] Reading XML with lua

2019-05-03 Thread Axel Kielhorn
Hi,

I’ m finally at a point where I can read an XML file look at it and write it 
back.

Right now I have two problems:

1. There are many empty entries in the table.
This makes processing the file a little tedious since I have to filter the real 
entries.

2. Some entries contain leading and trailing whitespace and linkebreaks.
These are the result of formatting the XML file.
Shouldn't
strip_cm_and_dt
take care of them?
Or do I use that incorrectly?

I have included my lua file and an example xml.
You can run it with
mtxrun —script p.lua

Greetings Axel





doclist.xml
Description: XML document


p.lua
Description: Binary data
___
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
___