* XML and Lua/Ctx
@ 2012-11-14 15:45 Procházka Lukáš Ing. - Pontex s. r. o.
0 siblings, 0 replies; 5+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-11-14 15:45 UTC (permalink / raw)
To: ConTeXt
[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]
Hello,
I've read that when Ctx is to process a XML file, the whole XML tree is loaded first and processed as wanted.
I'd need to process a XML file which represents an Excel workbook saved as .xml.
When working in pure Lua, I'm using Expat library (http://matthewwild.co.uk/projects/luaexpat/index.html) which allow to create a parser with callbacks (e.g. StartElement(), StopElement(), CharacterData()...).
It processes the .xml file on-the-go.
However, this solution cannot be used with Ctx as it causes Ctx to crash.
How to access a XML file loaded and parsed from within Ctx via Lua?
I attach a simple Excel XML (for those who are familiar with Excel and don't refuse using it).
As an example, I'd need process the attached .xml into a simple Lua table:
----
-- return -- Lua table as a result
{ workbooks =
{ [1] = { name = "1",
-- No more info is necessary so far,
-- I just need to see the way how to access XML elements
},
[2] = { name = "Imp",
},
[3] = { name = "Exp",
},
[4] = { name = "<Template>",
},
}
}
----
Could anyone experienced kindly present a way how to get such table from the attached Excel XML file?
TIA.
Best regards,
Lukas
--
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4
Tel: +420 244 062 238
Fax: +420 244 461 038
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Test.xml --]
[-- Type: text/xml; name="Test.xml", Size: 8333 bytes --]
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Ing. Lukáš Procházka</Author>
<LastAuthor>LPr</LastAuthor>
<LastPrinted>2008-05-05T16:32:23Z</LastPrinted>
<Created>1999-03-17T11:22:56Z</Created>
<LastSaved>2010-02-14T15:45:18Z</LastSaved>
<Company>Pontex s.r.o.</Company>
<Version>11.9999</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<SupBook>
<AltStartup>LP.xls</AltStartup>
<SheetName>.</SheetName>
<Xct>
<Count>0</Count>
<SheetIndex>0</SheetIndex>
</Xct>
</SupBook>
<WindowHeight>10875</WindowHeight>
<WindowWidth>15480</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>30</WindowTopY>
<AcceptLabelsInFormulas/>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center"/>
<Borders/>
<Font ss:FontName="Tahoma" x:CharSet="238" x:Family="Swiss"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s21">
<Font ss:FontName="Tahoma" x:CharSet="238" x:Family="Swiss" ss:Italic="1"/>
</Style>
<Style ss:ID="s22">
<Font ss:FontName="Tahoma" x:CharSet="238" x:Family="Swiss"/>
</Style>
<Style ss:ID="s23">
<Font ss:FontName="Tahoma" x:CharSet="238" x:Family="Swiss" ss:Italic="1"/>
<Interior ss:Color="#CCFFCC" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s24">
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="Tahoma" x:CharSet="238" x:Family="Swiss" ss:Italic="1"/>
</Style>
<Style ss:ID="s25">
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
</Style>
<Style ss:ID="s26">
<Borders/>
<Font ss:FontName="Tahoma" x:CharSet="238" x:Family="Swiss" ss:Italic="1"/>
</Style>
<Style ss:ID="s27">
<Borders/>
</Style>
</Styles>
<Worksheet ss:Name="1">
<Table ss:ExpandedColumnCount="256" ss:ExpandedRowCount="4" x:FullColumns="1"
x:FullRows="1">
<Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="45.75"/>
<Column ss:StyleID="s22" ss:AutoFitWidth="0" ss:Width="45.75"/>
<Column ss:AutoFitWidth="0" ss:Width="45.75" ss:Span="253"/>
<Row ss:StyleID="s21">
<Cell><Data ss:Type="String">#something</Data></Cell>
<Cell ss:StyleID="s22"/>
</Row>
<Row ss:Index="3">
<Cell ss:Index="2"><Data ss:Type="String">AAA</Data></Cell>
<Cell><Data ss:Type="Number">1.4</Data><Comment ss:Author="LPr"
ss:ShowAlways="1"><ss:Data xmlns="http://www.w3.org/TR/REC-html40"><Font
html:Size="8" html:Color="#000000">alpha.cc</Font></ss:Data></Comment></Cell>
</Row>
<Row>
<Cell ss:Index="2"><Data ss:Type="String">BBB</Data></Cell>
<Cell><Data ss:Type="Number">1.5</Data><Comment ss:Author="LPr"
ss:ShowAlways="1"><ss:Data xmlns="http://www.w3.org/TR/REC-html40"><Font
html:Size="8" html:Color="#000000">al</Font><B><Font html:Size="8"
html:Color="#000000">pha</Font></B><Font html:Size="8" html:Color="#000000">.cc</Font></ss:Data></Comment></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Layout x:CenterHorizontal="1"/>
<Header x:Margin="0.59055118110236227"/>
<Footer x:Margin="0.51181102362204722"
x:Data="&R&"Tahoma,Kurzíva"&8&Z&F [&A], &P/&N, &D"/>
<PageMargins x:Bottom="0.70866141732283472" x:Left="0.51181102362204722"
x:Right="0.51181102362204722" x:Top="0.59055118110236227"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Imp">
<Table ss:ExpandedColumnCount="256" ss:ExpandedRowCount="11" x:FullColumns="1"
x:FullRows="1">
<Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="45.75"/>
<Column ss:AutoFitWidth="0" ss:Width="45.75" ss:Span="254"/>
<Row ss:StyleID="s21">
<Cell ss:Index="11" ss:StyleID="s23"/>
</Row>
<Row ss:Index="10" ss:StyleID="s25">
<Cell ss:StyleID="s24"/>
</Row>
<Row ss:StyleID="s27">
<Cell ss:StyleID="s26"/>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Layout x:CenterHorizontal="1"/>
<Header x:Margin="0.59055118110236227"/>
<Footer x:Margin="0.51181102362204722"
x:Data="&R&"Tahoma,Kurzíva"&8&Z&F [&A], &P/&N, &D"/>
<PageMargins x:Bottom="0.70866141732283472" x:Left="0.51181102362204722"
x:Right="0.51181102362204722" x:Top="0.59055118110236227"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Exp">
<Table ss:ExpandedColumnCount="256" ss:ExpandedRowCount="40" x:FullColumns="1"
x:FullRows="1">
<Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="45.75"/>
<Column ss:AutoFitWidth="0" ss:Width="45.75" ss:Span="254"/>
<Row ss:StyleID="s21">
<Cell ss:Index="11" ss:StyleID="s23"/>
</Row>
<Row ss:Index="10" ss:StyleID="s25">
<Cell ss:StyleID="s24"/>
</Row>
<Row ss:Index="40" ss:StyleID="s25">
<Cell ss:StyleID="s24"/>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Layout x:CenterHorizontal="1"/>
<Header x:Margin="0.59055118110236227"/>
<Footer x:Margin="0.51181102362204722"
x:Data="&R&"Tahoma,Kurzíva"&8&Z&F [&A], &P/&N, &D"/>
<PageMargins x:Bottom="0.70866141732283472" x:Left="0.51181102362204722"
x:Right="0.51181102362204722" x:Top="0.59055118110236227"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="<Template>">
<Table ss:ExpandedColumnCount="256" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1">
<Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="45.75"/>
<Column ss:AutoFitWidth="0" ss:Width="45.75" ss:Span="254"/>
<Row ss:StyleID="s21"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Layout x:CenterHorizontal="1"/>
<Header x:Margin="0.59055118110236227"/>
<Footer x:Margin="0.51181102362204722"
x:Data="&R&"Tahoma,Kurzíva"&8&Z&F [&A], &P/&N, &D"/>
<PageMargins x:Bottom="0.70866141732283472" x:Left="0.51181102362204722"
x:Right="0.51181102362204722" x:Top="0.59055118110236227"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
[-- Attachment #3: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 5+ messages in thread
* Re: XML and Lua/Ctx
2012-11-14 15:52 ` Procházka Lukáš Ing. - Pontex s. r. o.
@ 2012-11-14 16:22 ` luigi scarso
0 siblings, 0 replies; 5+ messages in thread
From: luigi scarso @ 2012-11-14 16:22 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 402 bytes --]
On Wed, Nov 14, 2012 at 4:52 PM, Procházka Lukáš Ing. - Pontex s. r. o. <
LPr@pontex.cz> wrote:
> On Wed, 14 Nov 2012 16:50:50 +0100, luigi scarso <luigi.scarso@gmail.com>
> wrote:
>
> However, this solution cannot be used with Ctx as it causes Ctx to crash.
>>>
>>> Windows , Linux or MacOS ?
>>
>
> WinXP 32b
>
>
hm, I'm still not good enough under windows (but I'm progressing)
[-- Attachment #1.2: Type: text/html, Size: 1016 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 5+ messages in thread
* Re: XML and Lua/Ctx
2012-11-14 15:50 ` luigi scarso
@ 2012-11-14 15:52 ` Procházka Lukáš Ing. - Pontex s. r. o.
2012-11-14 16:22 ` luigi scarso
0 siblings, 1 reply; 5+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-11-14 15:52 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Wed, 14 Nov 2012 16:50:50 +0100, luigi scarso <luigi.scarso@gmail.com> wrote:
>> However, this solution cannot be used with Ctx as it causes Ctx to crash.
>>
> Windows , Linux or MacOS ?
WinXP 32b
--
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4
Tel: +420 244 062 238
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: XML and Lua/Ctx
2012-11-14 15:44 Procházka Lukáš Ing. - Pontex s. r. o.
@ 2012-11-14 15:50 ` luigi scarso
2012-11-14 15:52 ` Procházka Lukáš Ing. - Pontex s. r. o.
0 siblings, 1 reply; 5+ messages in thread
From: luigi scarso @ 2012-11-14 15:50 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 760 bytes --]
On Wed, Nov 14, 2012 at 4:44 PM, Procházka Lukáš Ing. - Pontex s. r. o. <
LPr@pontex.cz> wrote:
> Hello,
>
> I've read that when Ctx is to process a XML file, the whole XML tree is
> loaded first and processed as wanted.
>
> I'd need to process a XML file which represents an Excel workbook saved as
> .xml.
>
> When working in pure Lua, I'm using Expat library (
> http://matthewwild.co.uk/**projects/luaexpat/index.html<http://matthewwild.co.uk/projects/luaexpat/index.html>)
> which allow to create a parser with callbacks (e.g. StartElement(),
> StopElement(), CharacterData()...).
>
> It processes the .xml file on-the-go.
>
> However, this solution cannot be used with Ctx as it causes Ctx to crash.
>
Windows , Linux or MacOS ?
[-- Attachment #1.2: Type: text/html, Size: 1089 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 5+ messages in thread
* XML and Lua/Ctx
@ 2012-11-14 15:44 Procházka Lukáš Ing. - Pontex s. r. o.
2012-11-14 15:50 ` luigi scarso
0 siblings, 1 reply; 5+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-11-14 15:44 UTC (permalink / raw)
To: ConTeXt
[-- Attachment #1: Type: text/plain, Size: 1495 bytes --]
Hello,
I've read that when Ctx is to process a XML file, the whole XML tree is loaded first and processed as wanted.
I'd need to process a XML file which represents an Excel workbook saved as .xml.
When working in pure Lua, I'm using Expat library (http://matthewwild.co.uk/projects/luaexpat/index.html) which allow to create a parser with callbacks (e.g. StartElement(), StopElement(), CharacterData()...).
It processes the .xml file on-the-go.
However, this solution cannot be used with Ctx as it causes Ctx to crash.
How to access a XML file loaded and parsed from within Ctx via Lua?
I attach a simple Excel XML (for those who are familiar with Excel and don't refuse using it).
As an example, I'd need process the attached .xml into a simple Lua table:
----
-- return -- Lua table as a result
{ workbooks =
{ [1] = { name = "1",
-- No more info is necessary so far,
-- I just need to see the way how to access XML elements
},
[2] = { name = "Imp",
},
[3] = { name = "Exp",
},
[4] = { name = "<Template>",
},
}
}
----
Could anyone experienced kindly present a way how to get such table from the attached Excel XML file?
TIA.
Best regards,
Lukas
--
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4
Tel: +420 244 062 238
Fax: +420 244 461 038
[-- Attachment #2: Type: text/plain, Size: 227 bytes --]
This part of mail contained an attachment with prohibited file name:
MIME type: text/xml
File name: Test.xls.xml
File size: 8.59 kB
The attachment was removed by Kerio MailServer 6.6.2
at mail.pontex.cz.
[-- Attachment #3: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 5+ messages in thread
end of thread, other threads:[~2012-11-14 16:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 15:45 XML and Lua/Ctx Procházka Lukáš Ing. - Pontex s. r. o.
-- strict thread matches above, loose matches on Subject: below --
2012-11-14 15:44 Procházka Lukáš Ing. - Pontex s. r. o.
2012-11-14 15:50 ` luigi scarso
2012-11-14 15:52 ` Procházka Lukáš Ing. - Pontex s. r. o.
2012-11-14 16:22 ` luigi scarso
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).