[NTG-context] pagefigure cow

2014-12-10 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

the following code doesn't find cow image with the latest beta; what am I 
doing wrong?


local C = context

C.starttext()
  C(a)
  C.pagefigure{cow}
C.stoptext()


Best regards,

Lukas


--
Ing. Lukáš Procházka | mailto:l...@pontex.cz
Pontex s. r. o.  | mailto:pon...@pontex.cz | http://www.pontex.cz
Bezová 1658
147 14 Praha 4

Tel: +420 241 096 751
Fax: +420 244 461 038

t.cld
Description: Binary data


t.log
Description: Binary data


t.pdf
Description: Adobe PDF document
___
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
___

Re: [NTG-context] pagefigure cow

2014-12-10 Thread Peter Münster
On Wed, Dec 10 2014, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

 the following code doesn't find cow image with the latest beta; what am I 
 doing wrong?

 local C = context

C.setupexternalfigure{location = default}

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

[NTG-context] bug in latest beta?

2014-12-10 Thread Pablo Rodriguez
Hans,

after updating to latest beta I get an error when compiling the sample
bellow with beta from 2014.12.09 13:03:

   \setupitaliccorrection[global,always]
   \definefontfamily[mainface][serif][TeX Gyre Pagella]
   \setupbodyfont[mainface,15pt]

   \def\ConTeXt{Con\-\TeX{}t}

   \starttext
   \itc The Book on \ConTeXt
   \medskip
   \tfa\setupinterlinespace[2.6ex] {\sc The Author}
   \par
   \currentdate
   \stoptext

Beta from 2014.11.26 21:43 compiles it without problems.

Is this a bug or am I missing something?

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] two questions on the new simplefonts interface

2014-12-10 Thread Pablo Rodriguez
On 12/08/2014 09:43 PM, Wolfgang Schuster wrote:
 Am 08.12.2014 um 13:26 schrieb Pablo Rodriguez:

 Dear list,

 which are the replacements for \definesimplefont and
 \definesimplefonttypeface in the new simplefonts interface?

 I need the size option for \definesimplefont and the scale option for
 \definesimplefonttypeface.
 
 You can create a typeface with the \definefontfamily (you can find a lot
 of information in the mail archive) command.

Many thanks for your help, Wolfgang.

I forgot that \definefontfamily had a scale option.

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] bug in latest beta?

2014-12-10 Thread Hans Hagen

On 12/10/2014 7:51 PM, Pablo Rodriguez wrote:

Hans,

after updating to latest beta I get an error when compiling the sample
bellow with beta from 2014.12.09 13:03:

\setupitaliccorrection[global,always]
\definefontfamily[mainface][serif][TeX Gyre Pagella]
\setupbodyfont[mainface,15pt]

\def\ConTeXt{Con\-\TeX{}t}

\starttext
\itc The Book on \ConTeXt
\medskip
\tfa\setupinterlinespace[2.6ex] {\sc The Author}
\par
\currentdate
\stoptext

Beta from 2014.11.26 21:43 compiles it without problems.

Is this a bug or am I missing something?


It's a bug (I updated some discretionary related code so ther might be a 
few more border cases not handled well). I'll make a new beta.


Hans

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

Re: [NTG-context] two issues with new hyphenator

2014-12-10 Thread Pablo Rodriguez
On 12/09/2014 12:07 AM, Hans Hagen wrote:
 On 12/8/2014 5:47 PM, Pablo Rodriguez wrote:
 [..]
 And sorry for asking this again, but I need underscore hyphenation with
 the underscore character from the font and only for the \tex and
 \hyphenatedurl commands (not for the rest of the text).
 [...]
 
 just a variant of the addfunyhyphen:

Many thanks for your sample, Hans.

It really works great.

Sorry for asking this again: would it be possible to add this feature
also to \hyphenatedurl.

I’m composing a book on A6 and it is really hard to add some urls.

Many thanks for your help again,


Pablo


 \startluacode
 
   function document.addfunnyhyphen(tfmdata)
   local underscore = utf.byte(_)
   local char   = tfmdata.characters[underscore]
-- logs.report(fonts,adding funny hyphen to font 
 %a,tfmdata.properties.fontname)
   tfmdata.characters[0xFE000]   = {
   width= 0,
   height   = 0,
   depth= 0,
   commands = {
   { right, -char.width },
   { down, char.depth },
   { slot, 1, underscore },
   }
   }
   end
 
  
 utilities.sequencers.appendaction(aftercopyingcharacters,after,document.addfunnyhyphen)
 
 \stopluacode
 
 \definefontfeature[default][default][funnyhyphen=yes]
 \definefontfeature[always] [always] [funnyhyphen=yes]
 \definefontfeature[none]   [none]   [funnyhyphen=yes]
 
 \definetype
   [TeXcode]
   [option=TEX,
compact=absolute,
lines=hyphenated]
 
 \definehyphenationfeatures
   [whatever]
   [righthyphenchar=FE000]
 
 \setuphyphenation
   [method=traditional]
 
 \unexpanded\def\TexC#1%
   {\dontleavehmode\begingroup
\sethyphenationfeatures[whatever]%
  % \prehyphencharFE000
\normalexpanded{\TeXcode{\letterbackslash#1}}%
\endgroup}

 \starttext
 \input tufte
 \dorecurse{100}{\TexC{definebodyfont} }
 \input tufte
 \stoptext
 
 we can add some of them but first i need to think about what slots to 
 use (shouldn't conflict with other private slots)




-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] Problems with repeating layers

2014-12-10 Thread Pablo Rodriguez
On 12/09/2014 04:08 PM, Reza Housseini wrote:
 
 Thanks Pablo
 
 I already used this solution. For me it looks like a bug that the
 state argument does not change anything because the manual clearly
 states the expected behaviour of state.
 But anyhow I'll use the other solution.

Hi Reza,

I don’t really know whether this is a bug or a feature, because I don’t
know the internals.

But the only way to find out is to report it and see what happens.


Pablo
-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] issue with t-scancsv.lua

2014-12-10 Thread Pablo Rodriguez
On 12/09/2014 12:45 AM, Jaroslav Hajtmar wrote:
 Hi Pablo.
 I am glad that my library for you to use ...
 I noticed that you have in your CSV file header with column names (ie. 
 head of CSV document). I do not know if you noticed the option put this 
 information into scancsv.lua library. This is done via the command 
 \setheader. In this case library does not consider the first line of the 
 CSV file as a data line.

Hi Jaroslav,

I know that, ubt I removed it in the sample I sent because I edited the
CVS file with gedit and I forgot that the first line was the header (I
was in a hurry).

I actually use \setheader to ignore it, since headers with non-ASCII
characters or spaces are problematic. I’m fine invoking \cA, \cB, \cC...

 From the header of CSV file are now macros (from header names)
 contain later data from rows of the CSV file (changing in cycle). In
 addition, you can also use internal hooks. CSV file can even contain
 macros (must be defined before processing the CSV file).

Well, your sample needs further study. Internal hooks are fine (once I
know what they really are and how to use them ;-)), but macros are
totally out of question. CVS files come from Excel users (I don’t even
mention what TeX or ConTeXt might be).

Many thanks for your help,


Pablo


 Example of use hooks etc. eg. Here:
 
 \usemodule[scancsv]
 
 \setuppapersize[C6, landscape]
 \setuppagenumbering[location=]
 
 % Structure of CSV file - you can use macros in CSV table too
 % name;address;postcode;city;linecolor
 % ME;STREET;;HERE;\green;
 % You;Square;;There;\red;
 % we;another Square;111;anyplace;\blue;
 
 
 % Library is making \name, \address, \postcode, \city and \linecolor macros
 % when you using \setheader command.
 
 % Your example:
 \unexpanded\def\lineaction{
 \edef\lowercasename{\lowercase{\name}}
 \edef\uppercaseaddress{\uppercase{\address}}
 name: {\linecolor\name}\ -- lowercase name: \lowercasename\crlf
 address: \address\ -- upercase address: \uppercaseaddress\crlf
 \postcode\ \city\crlf
 
 \page
 }
 
 
 % My example with hooks:
 \unexpanded\def\tablelineaction{%
  \edef\ehname{\hname}%
  \edef\ehaddress{\haddress}%
  \edef\ehpostcode{\hpostcode}%
  \edef\ehcity{\hcity}%
 \ehname \ehaddress \ehpostcode \ehcity %
 }
 
 % My simple example with hooks:
 \def\simpletablelineaction{%
 \bTD{\linecolor\numline}\eTD\hname\haddress\hpostcode\hcity%
 }
 
 
 \setsep{;} % set separator
 \setheader % set information about header
 \setfiletoscan{mailmergedatatable.csv}
 
 \starttext
 % process all file
 
 Here is begin of processing...
 
 \filelineaction
 
 And here is end
 
 \page
 
 And now we can use internal hooks:
 
 \def\bch{\bTD } % begin column hook
 \def\ech{\eTD} % end column hook
 \def\blinehook{\bTR } % begin line hook
 \def\elinehook{\eTR} % end line hook
 \def\bfilehook{\bTABLE } % begin CSV file hook
 \def\efilehook{\eTABLE} % end CSV file hook
 
 Here is begin of processing...
 
 %process all file too (endless cycle)
 \doloopif{1}{==}{1}{\tablelineaction}
 
 And here is end
 
 \page
 
 Printing only specific data:
 
 \doloopif{\name}{eq}{You}{\tablelineaction}
 
 \page
 
 Simpletablelineaction:
 
 \doloopif{1}{==}{1}{\simpletablelineaction}
 
 \page
 
 Another using of hooks:
 
 \def\bch{\bgroup\linecolor\bf } % begin column hook
 \def\ech{\egroup,\ } % end column hook
 \def\blinehook{Here is new \numline. line of CSV file:\crlf } % begin 
 line hook
 \def\elinehook{\hairline\par} % end line hook
 \def\bfilehook{Here is all CSV file:\blank[2*big] } % begin CSV file hook
 \def\efilehook{\par Here is end of file processing\par} % end CSV file hook
 
 \doloopif{1}{==}{1}{\tablelineaction}
 
 
 
 \stoptext


-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] bug in latest beta?

2014-12-10 Thread Pablo Rodriguez
On 12/10/2014 08:14 PM, Hans Hagen wrote:
 On 12/10/2014 7:51 PM, Pablo Rodriguez wrote:
 Hans,

 after updating to latest beta I get an error when compiling the sample
 bellow with beta from 2014.12.09 13:03:

 \setupitaliccorrection[global,always]
 \definefontfamily[mainface][serif][TeX Gyre Pagella]
 \setupbodyfont[mainface,15pt]

 \def\ConTeXt{Con\-\TeX{}t}

 \starttext
 \itc The Book on \ConTeXt
 \medskip
 \tfa\setupinterlinespace[2.6ex] {\sc The Author}
 \par
 \currentdate
 \stoptext

 Beta from 2014.11.26 21:43 compiles it without problems.

 Is this a bug or am I missing something?
 
 It's a bug (I updated some discretionary related code so ther might be a 
 few more border cases not handled well). I'll make a new beta.

Many thanks for the fast fix, Hans.


Pablo
-- 
http://www.ousia.tk
___
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
___

[NTG-context] underscore hyphenation

2014-12-10 Thread Pablo Rodriguez
Hans,

the sample below hyphenates right what comes before \TexC in the
paragraph. Also the contents of \TexC are hyphenated right.

But hyphen is removed from standard text after the last \TexC command in
the paragraph.

I have just accidentally discovered it.

Many thanks for your help,

Pablo



\startluacode

function document.addfunnyhyphen(tfmdata)
local underscore = utf.byte(_)
local char   = tfmdata.characters[underscore]
tfmdata.characters[0xFE000]   = {
width= 0,
height   = 0,
depth= 0,
commands = {
{ right, -char.width },
{ down, char.depth },
{ slot, 1, underscore },
}
}
end

utilities.sequencers.appendaction(aftercopyingcharacters,after,document.addfunnyhyphen)

\stopluacode

\definefontfamily[mainface][serif][GaramondNo8]
\definefontfamily[mainface][mono][Mechanica]
\setupbodyfont[mainface, 14pt]

\definetype
  [TeXcode]
  [option=TEX,
   compact=absolute,
   lines=hyphenated]

\definehyphenationfeatures
  [whatever]
  [righthyphenchar=FE000]

\setuphyphenation[method=traditional]
\sethyphenationfeatures[strict]

\unexpanded\def\TexC#1%
  {\dontleavehmode\begingroup
   \sethyphenationfeatures[whatever]%
   \normalexpanded{\TeXcode{\letterbackslash#1}}%
   \endgroup}

\starttext
\hsize\zeropoint
newlargewordwithhyphen
\TexC{definebodyfont}
newlargewordwithnohyphen
\stoptext

-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] underscore hyphenation

2014-12-10 Thread Hans Hagen

On 12/10/2014 9:03 PM, Pablo Rodriguez wrote:

Hans,

the sample below hyphenates right what comes before \TexC in the
paragraph. Also the contents of \TexC are hyphenated right.

But hyphen is removed from standard text after the last \TexC command in
the paragraph.

I have just accidentally discovered it.


Fixed, thanks for noticing, it had to do with picking up the right 
settings after a change in alternative (we operate on several axis: 
language, glyph and hyphenation properties).




Many thanks for your help,

Pablo



\startluacode

 function document.addfunnyhyphen(tfmdata)
 local underscore = utf.byte(_)
 local char   = tfmdata.characters[underscore]
 tfmdata.characters[0xFE000]   = {
 width= 0,
 height   = 0,
 depth= 0,
 commands = {
 { right, -char.width },
 { down, char.depth },
 { slot, 1, underscore },
 }
 }
 end

utilities.sequencers.appendaction(aftercopyingcharacters,after,document.addfunnyhyphen)

\stopluacode

\definefontfamily[mainface][serif][GaramondNo8]
\definefontfamily[mainface][mono][Mechanica]
\setupbodyfont[mainface, 14pt]

\definetype
   [TeXcode]
   [option=TEX,
compact=absolute,
lines=hyphenated]

\definehyphenationfeatures
   [whatever]
   [righthyphenchar=FE000]

\setuphyphenation[method=traditional]
\sethyphenationfeatures[strict]

\unexpanded\def\TexC#1%
   {\dontleavehmode\begingroup
\sethyphenationfeatures[whatever]%
\normalexpanded{\TeXcode{\letterbackslash#1}}%
\endgroup}

\starttext
 \hsize\zeropoint
 newlargewordwithhyphen
 \TexC{definebodyfont}
 newlargewordwithnohyphen
\stoptext




--

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

Re: [NTG-context] two issues with new hyphenator

2014-12-10 Thread Hans Hagen

On 12/10/2014 8:15 PM, Pablo Rodriguez wrote:

On 12/09/2014 12:07 AM, Hans Hagen wrote:

On 12/8/2014 5:47 PM, Pablo Rodriguez wrote:

[..]
And sorry for asking this again, but I need underscore hyphenation with
the underscore character from the font and only for the \tex and
\hyphenatedurl commands (not for the rest of the text).
[...]


just a variant of the addfunyhyphen:


Many thanks for your sample, Hans.

It really works great.

Sorry for asking this again: would it be possible to add this feature
also to \hyphenatedurl.

I’m composing a book on A6 and it is really hard to add some urls.


some code from an upcoming manual:

\startluacode
local specials = {
[!]  = before, [?]  = before,
['']  = before, [']  = before,
[/]  = before, [\\] = before,
[#]  = before,
[$]  = before,
[%]  = before,
[]  = before,
[*]  = before,
[+]  = before, [-]  = before,
[,]  = before, [.]  = before,
[:]  = before, [;]  = before,
[]  = before, []  = before,
[=]  = before,
[@]  = before,
[(]  = before,
[[]  = before,
[{]  = before,
[^]  = before, [_]  = before,
[`]  = before,
[|]  = before,
[~]  = before,
--
[)]  = after,
[]]  = after,
[}]  = after,
}

languages.hyphenators.traditional.installmethod(url,
function(dictionary,word,n)
local t = { }
for i=1,#word do
local w = word[i]
local s = specials[w]
if s == after then
s = {
start  = 1,
length = 1,
after  = w,
left   = false,
right  = false,
}
specials[w] = s
elseif s == before then
s = {
start  = 1,
length = 1,
before = w,
left   = false,
 -- right  = false,
}
specials[w] = s
end
t[i] = s or false
end
return t
end
)
\stopluacode

\startluacode

function document.addfunnyhyphen(tfmdata)
local underscore = utf.byte(_)
local char   = tfmdata.characters[underscore]
tfmdata.characters[0xFE000]   = {
width= 0,
height   = 0,
depth= 0,
commands = {
{ right, -char.width },
{ down, char.depth },
{ slot, 1, underscore },
}
}
end


utilities.sequencers.appendaction(aftercopyingcharacters,after,document.addfunnyhyphen)

\stopluacode

\definehyphenationfeatures
  [url]
  [characters=all,
   righthyphenchar=FE000,
   alternative=url]

\setuphyphenation[method=traditional]

\unexpanded\def\hyphenatedurl#1%
  {\dontleavehmode
   \begingroup
   \tt
   \sethyphenationfeatures[url]%
   #1%
   \endgroup}

\starttext

\hsize5mm
\hyphenatedurl{http://www.pragma-ade.nl}

\stoptext




Many thanks for your help again,


Pablo



\startluacode

   function document.addfunnyhyphen(tfmdata)
   local underscore = utf.byte(_)
   local char   = tfmdata.characters[underscore]
-- logs.report(fonts,adding funny hyphen to font
%a,tfmdata.properties.fontname)
   tfmdata.characters[0xFE000]   = {
   width= 0,
   height   = 0,
   depth= 0,
   commands = {
   { right, -char.width },
   { down, char.depth },
   { slot, 1, underscore },
   }
   }
   end


utilities.sequencers.appendaction(aftercopyingcharacters,after,document.addfunnyhyphen)

\stopluacode

\definefontfeature[default][default][funnyhyphen=yes]
\definefontfeature[always] [always] [funnyhyphen=yes]
\definefontfeature[none]   [none]   [funnyhyphen=yes]

\definetype
   [TeXcode]
   [option=TEX,
compact=absolute,
lines=hyphenated]

\definehyphenationfeatures
   [whatever]
   [righthyphenchar=FE000]

\setuphyphenation
   [method=traditional]

\unexpanded\def\TexC#1%
   {\dontleavehmode\begingroup
\sethyphenationfeatures[whatever]%
  % \prehyphencharFE000
\normalexpanded{\TeXcode{\letterbackslash#1}}%
\endgroup}

\starttext
 \input tufte
 \dorecurse{100}{\TexC{definebodyfont} }
 \input tufte
\stoptext

we can add some of them but first i need to think about what slots to
use (shouldn't conflict with other private slots)








--

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The 

[NTG-context] Ctx XML

2014-12-10 Thread Lukáš Procházka

Hello,

I'm having problem using LuaXml library with Ctx, both using Lua ver. 5.2.

LuaXml works fine with Lua standalone programs/scripts;
but something weird occurs when used from within Ctx (e.g. a .xml file can be read 
successfully from standalone Lua with LuaXml lib; but the same code doesn't give 
the desired result when used in combination with Ctx; a problem might be version 
mismatch - I'm still using both Lua 5.1 and 5.2 including 3rd party modules in my 
scripts - but my latest tests with Ctx  LuaXml should have avoid this; or 
namespace mismatch...?).

Anyway, does native Ctx XML API (has it its own namespace, like 'context.xml'?) provide a 
function to load a .xml file and to return its XML tree as a table, with nodes (as a 
table with node attributes as table members) in a proper sequence... something like 
LuaXml's 'xml.load(file.xml)' does?

Or how to achieve this in a best way under Ctx: XML file - Lua table/tree?

Best regards,

Lukas


--
Ing. Lukáš Procházka | mailto:l...@pontex.cz
Pontex s. r. o.  | mailto:pon...@pontex.cz | http://www.pontex.cz
Bezová 1658
147 14 Praha 4

Tel: +420 241 096 751
Fax: +420 244 461 038

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

Re: [NTG-context] Ctx XML

2014-12-10 Thread Hans Hagen

On 12/10/2014 11:08 PM, Lukáš Procházka wrote:

Hello,

I'm having problem using LuaXml library with Ctx, both using Lua ver. 5.2.

LuaXml works fine with Lua standalone programs/scripts;
but something weird occurs when used from within Ctx (e.g. a .xml file
can be read successfully from standalone Lua with LuaXml lib; but the
same code doesn't give the desired result when used in combination with
Ctx; a problem might be version mismatch - I'm still using both Lua 5.1
and 5.2 including 3rd party modules in my scripts - but my latest tests
with Ctx  LuaXml should have avoid this; or namespace mismatch...?).


I don't know (and as we have quite some code on-board I don't care too 
much either about clashes in namespaces).



Anyway, does native Ctx XML API (has it its own namespace, like
'context.xml'?) provide a function to load a .xml file and to return its
XML tree as a table, with nodes (as a table with node attributes as
table members) in a proper sequence... something like LuaXml's
'xml.load(file.xml)' does?


I assume that you also want the content of elements, not just the 
attributes.



Or how to achieve this in a best way under Ctx: XML file - Lua table/tree?


It all depends on what kin dof table you want (if the content is an 
indexed table and attributes keys then you have the problem that the 
element cannot be a key too as it can clash) .. anyway, it's no big deal 
to provide a stupid table, so I can provide something because after all 
the loaded xml file is a table already.


local x = xml.load(file.xml)

local t = xml.totable(x)

where x is an index/hash mix plus _tag, _type and _namespace fields as 
well (after all I assume that you need to know that too).


(btw, I bet that you can do what you want with the existing 
functionality as well, so there is not much benefit in such a table)


Probably in the next upload,

Hans



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

Re: [NTG-context] Ctx XML

2014-12-10 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

On Thu, 11 Dec 2014 02:24:24 +0100, Hans Hagen pra...@wxs.nl wrote:


On 12/10/2014 11:08 PM, Lukáš Procházka wrote:

I assume that you also want the content of elements, not just the
attributes.


Yes...


Or how to achieve this in a best way under Ctx: XML file - Lua table/tree?


It all depends on what kin dof table you want (if the content is an
indexed table and attributes keys then you have the problem that the
element cannot be a key too as it can clash) .. anyway, it's no big deal
to provide a stupid table, so I can provide something because after all
the loaded xml file is a table already.


It would be great.


local x = xml.load(file.xml)

local t = xml.totable(x)

where x is an index/hash mix plus _tag, _type and _namespace fields as
well (after all I assume that you need to know that too).

(btw, I bet that you can do what you want with the existing
functionality as well, so there is not much benefit in such a table)

Probably in the next upload,


... Means - some functionality (for me to test or to play with) might be 
available tomorrow morning?


Hans


BTW, I prepared a really-simple-XML-test which shows XML - Lua table/tree 
conversion, which I'd like to achieve (and which (approx.) provides LuaXml lib).

 XML
a aaa=AAA
  b bbb=B1/
  b bbb=B2
c
  /b
/a


 Lua representation
{ [0] = a, -- Element name
  { [0] = b, -- Element name
-- No nested members
bbb = B1, -- Atts
  },
  { [0] = b, -- Element name
{ c, }, -- Nested member
bbb = B2, -- Atts
  },
  aaa = AAA, -- Atts
}


Thanks again.

Best regards,

Lukas


--
Ing. Lukáš Procházka | mailto:l...@pontex.cz
Pontex s. r. o.  | mailto:pon...@pontex.cz | http://www.pontex.cz
Bezová 1658
147 14 Praha 4

Tel: +420 241 096 751
Fax: +420 244 461 038a aaa=AAA
  b bbb=B1/
  b bbb=B2
c
  /b
/a

!--
{ [0] = a, -- Element name
  { [0] = b, -- Element name
-- No nested members
bbb = B1, -- Atts
  },
  { [0] = b, -- Element name
{ c, }, -- Nested member
bbb = B2, -- Atts
  },
  aaa = AAA, -- Atts
}
--
___
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
___