Discussion:
[NTG-context] TEI to context XML mappings?
Mica Semrick
2016-02-23 21:26:20 UTC
Permalink
Reading the docbook thread earlier today reminded me to ask this:

Is there any feature or script that anyone can share that will read in an XML document and spit out a blank mapping file?

Thanks!

-m
Hans Hagen
2016-02-24 08:20:34 UTC
Permalink
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file


-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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-***@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
_____________________________________________________________________________
Pablo Rodriguez
2016-02-24 09:10:42 UTC
Permalink
Post by Hans Hagen
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file
Just guessing (or that would be useful for me too), a file with the
following scheme:

\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements} % all elements used in document listed here
{xml:*}

\xmlsetsetup{\xmldocument}
{h2[contains(@class,'author')]} % list also all elements
{xml:title:author} % with attributes
\stopxmlsetups

\xmlregistersetup{xml:pandoc}

\startxmlsetups xml:elements % basic configuration for elements
\xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:title:author % basic configuration for attributes
\xmlflush{#1}
\stopxmlsetups

I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.

I hope it helps,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
_______________________________________________
Hans Hagen
2016-02-24 09:52:27 UTC
Permalink
Post by Pablo Rodriguez
Post by Hans Hagen
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file
Just guessing (or that would be useful for me too), a file with the
\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements} % all elements used in document listed here
{xml:*}
\xmlsetsetup{\xmldocument}
{xml:title:author} % with attributes
\stopxmlsetups
\xmlregistersetup{xml:pandoc}
\startxmlsetups xml:elements % basic configuration for elements
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:title:author % basic configuration for attributes
\xmlflush{#1}
\stopxmlsetups
I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.
context --extra=xml --analyze yourfile.xml

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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-***@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
____________________________________________________________________
Thomas A. Schmitz
2016-02-24 10:11:16 UTC
Permalink
Post by Hans Hagen
context --extra=xml --analyze yourfile.xml
Hmm, that sounds great, however, with the latest 'n greatest:

resolvers > modules > 'xml-analyzers' is not found

Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
________________________________________________________________
Hans Hagen
2016-02-24 10:26:55 UTC
Permalink
Post by Thomas A. Schmitz
Post by Hans Hagen
context --extra=xml --analyze yourfile.xml
resolvers > modules > 'xml-analyzers' is not found
i added the files to the beta

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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-***@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
________________________________________________
Thomas A. Schmitz
2016-02-24 12:05:52 UTC
Permalink
Post by Hans Hagen
i added the files to the beta
Great, it works now and is a fantastic tool! I was thinking of writing
something similar myself, but of course, you had already anticipated
this wish... I'll try to see if I can make sense of s-xml-analyzers.lua
and come up with different visualizations (what I had in mind was a
table listing the elements, all elements contained in them and all
attributes used). I don't know if the "blank mapping file" as
conjectured by Pablo is a useful idea, but I guess it would be trivial
to implement that as well.

Thanks and all best

Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
_____________________________________________________________
Hans Hagen
2016-02-24 14:15:56 UTC
Permalink
Post by Thomas A. Schmitz
Post by Hans Hagen
i added the files to the beta
Great, it works now and is a fantastic tool! I was thinking of writing
something similar myself, but of course, you had already anticipated
this wish... I'll try to see if I can make sense of s-xml-analyzers.lua
and come up with different visualizations (what I had in mind was a
table listing the elements, all elements contained in them and all
attributes used). I don't know if the "blank mapping file" as
conjectured by Pablo is a useful idea, but I guess it would be trivial
to implement that as well.
if you need more info i can add it ... one can then generate whatever
table one wants

elements in element .. one level i assume?

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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-***@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
______________________________________________________________________
Thomas A. Schmitz
2016-02-24 14:32:25 UTC
Permalink
Post by Hans Hagen
if you need more info i can add it ... one can then generate whatever
table one wants
elements in element .. one level i assume?
Yes, one level, otherwise things become too complex. And you're right,
it's already there in the "children" element. My question was not so
much about the information but about the visualization. Let's put it in
a slightly different way: the context parser holds the information about
my xml tree as a lua table, right? It would be handy to have a typeset
version of this table, as a, well, table, so we could see how to access
the different parts of it in lua and/or tex code. So I know that my
element is e, I know that it has a table e.at that collects the
different attributes in subtables of the form e.at["attribute"]. I
assume there's also e.text, e.first etc. Would it be possible to typeset
this information for elements.

Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
___________________________________
Hans Hagen
2016-02-24 14:51:42 UTC
Permalink
Post by Thomas A. Schmitz
Post by Hans Hagen
if you need more info i can add it ... one can then generate whatever
table one wants
elements in element .. one level i assume?
Yes, one level, otherwise things become too complex. And you're right,
it's already there in the "children" element. My question was not so
much about the information but about the visualization. Let's put it in
a slightly different way: the context parser holds the information about
my xml tree as a lua table, right? It would be handy to have a typeset
version of this table, as a, well, table, so we could see how to access
the different parts of it in lua and/or tex code. So I know that my
element is e, I know that it has a table e.at that collects the
different attributes in subtables of the form e.at["attribute"]. I
assume there's also e.text, e.first etc. Would it be possible to typeset
this information for elements.
no, there are no such fields

\starttext

\startluacode
local t = xml.load("t:/sources/i-en-xml.xml")
print(table.serialize(t,true,{})) -- you need to call this way
\stopluacode

\stoptext

at : attributes
ns : namespace
rn : remapped namespace
tg : tag (@..@ names indicate special tags)
dt : text

text is a table of strings and elements

(there are a few extra private fields and when applying searched there
are index fields added)

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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-***@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
___________________________________________
Thomas A. Schmitz
2016-02-24 15:57:28 UTC
Permalink
Post by Hans Hagen
no, there are no such fields
\starttext
\startluacode
local t = xml.load("t:/sources/i-en-xml.xml")
print(table.serialize(t,true,{})) -- you need to call this way
\stopluacode
\stoptext
at : attributes
ns : namespace
rn : remapped namespace
dt : text
text is a table of strings and elements
(there are a few extra private fields and when applying searched there
are index fields added)
Ah wonderful, that's already very useful to have! Thanks for pointing it
out!

Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
_____________________________________________________________________
Mica Semrick
2016-02-24 17:32:45 UTC
Permalink
I don't know if the "blank mapping file" as conjectured by Pablo is a useful idea
I find extremely useful. When I go to style some XML file, I don't have to type all of that stuff or study the XML file to find out what elements are contained. This feature will make it extremely easy to get something functional very quickly.

-m
Post by Hans Hagen
i added the files to the beta
Great, it works now and is a fantastic tool! I was thinking of writing
something similar myself, but of course, you had already anticipated
this wish... I'll try to see if I can make sense of s-xml-analyzers.lua
and come up with different visualizations (what I had in mind was a
table listing the elements, all elements contained in them and all
attributes used). I don't know if the "blank mapping file" as
conjectured by Pablo is a useful idea, but I guess it would be trivial
to implement that as well.
Thanks and all best
Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
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
___________________________________________________________________________________
Mica Semrick
2016-02-24 15:34:53 UTC
Permalink
Thank you! And sorry for my poor description.

Best,
Mica
Post by Hans Hagen
Post by Thomas A. Schmitz
Post by Hans Hagen
context --extra=xml --analyze yourfile.xml
resolvers > modules > 'xml-analyzers' is not found
i added the files to the beta
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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!
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
___________________________________________________________________________________
Pablo Rodriguez
2016-02-24 10:32:24 UTC
Permalink
Post by Hans Hagen
Post by Pablo Rodriguez
[...]
I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.
context --extra=xml --analyze yourfile.xml
That’s awesome. Many thanks, Hans.

(Not tested yet.)

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
______________________________________________
m***@silentumbrella.com
2016-02-25 05:04:18 UTC
Permalink
Hi Hans,

I've tried this feature on a very simple TEI XML document.

Issuing the command
context --extra=xml --analyze yourfile.xml
produces context-extra.pdf, which looks much like the file that Thomas
wanted to produce. While this is helpful, I cannot figure out the
command to produce the file that Pablo alluded to; any help would be
great!

My context version is:
$ context --version

mtx-context | ConTeXt Process Management 0.63
mtx-context |
mtx-context | main context file:
/home/user/.context/tex/texmf-context/tex/context/base/mkiv/context.mkiv
mtx-context | current version: 2016.02.24 11:19

Thank you!

-Mica
Post by Hans Hagen
Post by Pablo Rodriguez
Post by Hans Hagen
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file
Just guessing (or that would be useful for me too), a file with the
\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements} % all elements used in document listed here
{xml:*}
\xmlsetsetup{\xmldocument}
{xml:title:author} % with attributes
\stopxmlsetups
\xmlregistersetup{xml:pandoc}
\startxmlsetups xml:elements % basic configuration for elements
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:title:author % basic configuration for attributes
\xmlflush{#1}
\stopxmlsetups
I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.
context --extra=xml --analyze yourfile.xml
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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!
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
___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
______________________________________________________________
Hans Hagen
2016-02-25 09:48:53 UTC
Permalink
Post by m***@silentumbrella.com
Hi Hans,
I've tried this feature on a very simple TEI XML document.
Issuing the command
context --extra=xml --analyze yourfile.xml
produces context-extra.pdf, which looks much like the file that Thomas
wanted to produce. While this is helpful, I cannot figure out the
command to produce the file that Pablo alluded to; any help would be great!
$ context --version
mtx-context | ConTeXt Process Management 0.63
mtx-context |
/home/user/.context/tex/texmf-context/tex/context/base/mkiv/context.mkiv
mtx-context | current version: 2016.02.24 11:19
Thank you!
-Mica
Post by Hans Hagen
Post by Pablo Rodriguez
Post by Hans Hagen
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file
Just guessing (or that would be useful for me too), a file with the
i'm still puzzled what you want
Post by m***@silentumbrella.com
Post by Hans Hagen
Post by Pablo Rodriguez
\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements} % all elements used in document listed here
{xml:*}
you can use

\xmlsetsetup{#1}

there which is more neutral unless you target a specific xml tree

\xmlsetsetup{#1}{*}{+} % shows
\xmlsetsetup{#1}{*}{-} % hides
Post by m***@silentumbrella.com
Post by Hans Hagen
Post by Pablo Rodriguez
\xmlsetsetup{\xmldocument}
{xml:title:author} % with attributes
\stopxmlsetups
\xmlregistersetup{xml:pandoc}
\startxmlsetups xml:elements % basic configuration for elements
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:title:author % basic configuration for attributes
\xmlflush{#1}
\stopxmlsetups
I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.
\starttext
\startbuffer[bar]
<x>foo
<y class='author1'>one</y>
<y class='author2'>two</y>
</x>
\stopbuffer

\startxmlsetups whatever
\xmlsetsetup{#1}{x}{+}
\xmlsetsetup{#1}{y}{-}
\xmlsetsetup{#1}{y[contains(@class,'author2')]}{+}
\stopxmlsetups
\xmlregistersetup{whatever}
\xmlprocessbuffer{foo}{bar}{}
\stoptext

i think what you want really depends on your expected input
Post by m***@silentumbrella.com
Post by Hans Hagen
context --extra=xml --analyze yourfile.xml
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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!
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
___________________________________________________________________________________
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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-***@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
____________________________________________________________________
Pablo Rodriguez
2016-02-26 07:52:32 UTC
Permalink
Post by Hans Hagen
[...]
i'm still puzzled what you want
Hans,

I’m only guessing (after testing the XML analyzing ability that you
discovered us with a single XML file).

The analysis is important, but after that I have to write the actual
environment.

I think that the basic structure that I sent in
https://mailman.ntg.nl/pipermail/ntg-context/2016/084582.html is useful
to avoid writing myself the environment.

I mean, of course I have to add the relevant commands to handle in
ConTeXt each element. But with the basic scheme, I know which elements
(in the broadest sense) I have to setup.

I want to avoid writing the whole element list in the environment by
hand. But I may be doing wrong (this is totally new to me).

Or do you write (type) each environment from scratch after using the
report generated by ConTeXt?

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-***@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
____________________________________________________
Hans Hagen
2016-02-26 09:00:03 UTC
Permalink
Post by Pablo Rodriguez
Post by Hans Hagen
[...]
i'm still puzzled what you want
Hans,
I’m only guessing (after testing the XML analyzing ability that you
discovered us with a single XML file).
The analysis is important, but after that I have to write the actual
environment.
I think that the basic structure that I sent in
https://mailman.ntg.nl/pipermail/ntg-context/2016/084582.html is useful
to avoid writing myself the environment.
You want to autogenerate that? That could become quite huge (And
probably most would be discarded later anyway of you want all
permutations of elements and attributes)
Post by Pablo Rodriguez
I mean, of course I have to add the relevant commands to handle in
ConTeXt each element. But with the basic scheme, I know which elements
(in the broadest sense) I have to setup.
I want to avoid writing the whole element list in the environment by
hand. But I may be doing wrong (this is totally new to me).
Or do you write (type) each environment from scratch after using the
report generated by ConTeXt?
We just start with the trivial things and then look at the specific
structures. We get either relative simple html like xml or we get quite
complex educational markup, with quite demanding rendering and multiple
products. The good news is that the number of elements is always limited
(analyzing would not really work well because it can be that thousands
of files need to be loaded and merged which itself is not a problem, but
one then always need to interpret what needs to get loaded).

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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-***@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
____________________________________________
Mica Semrick
2016-02-26 15:39:42 UTC
Permalink
Post by Hans Hagen
You want to autogenerate that? That could become quite huge (And
probably most would be discarded later anyway of you want all
permutations of elements and attributes)
Just elements would work for me.

Best,
M
Post by Hans Hagen
Post by Hans Hagen
[...]
i'm still puzzled what you want
Hans,
I’m only guessing (after testing the XML analyzing ability that you
discovered us with a single XML file).
The analysis is important, but after that I have to write the actual
environment.
I think that the basic structure that I sent in
https://mailman.ntg.nl/pipermail/ntg-context/2016/084582.html is
useful
to avoid writing myself the environment.
You want to autogenerate that? That could become quite huge (And
probably most would be discarded later anyway of you want all
permutations of elements and attributes)
I mean, of course I have to add the relevant commands to handle in
ConTeXt each element. But with the basic scheme, I know which
elements
(in the broadest sense) I have to setup.
I want to avoid writing the whole element list in the environment by
hand. But I may be doing wrong (this is totally new to me).
Or do you write (type) each environment from scratch after using the
report generated by ConTeXt?
We just start with the trivial things and then look at the specific
structures. We get either relative simple html like xml or we get quite
complex educational markup, with quite demanding rendering and multiple
products. The good news is that the number of elements is always limited
(analyzing would not really work well because it can be that thousands
of files need to be loaded and merged which itself is not a problem, but
one then always need to interpret what needs to get loaded).
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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!
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
___________________________________________________________________________________
Mica Semrick
2016-06-22 05:12:01 UTC
Permalink
After doing some research, I stumbled upon saxon-lint
(https://github.com/sputnick-dev/saxon-lint), a perl program
capable of using xpath3 expressions.

In the crudest form possible:

!# /bin/bash
for ELM in `saxon-lint.pl --xpath "distinct-values(//*/name())" file.xml`
do
echo -e "\\startxmlsetups xml:$ELM \n\t \\xmlflush{#1} \n \\stopxmlsetups"
done

I still need to write $ELM into an array to make it do the following:

\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements:from:the:variable:elm} % list the results from
saxon-lint
{xml:*}
\stopxmlsetups

That would give me the "blank" mapping file I want, saving me the
trouble of typing out the whole thing every time.

Best,
Mica
Post by Pablo Rodriguez
Post by Hans Hagen
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file
Just guessing (or that would be useful for me too), a file with the
\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements} % all elements used in document listed here
{xml:*}
\xmlsetsetup{\xmldocument}
{xml:title:author} % with attributes
\stopxmlsetups
\xmlregistersetup{xml:pandoc}
\startxmlsetups xml:elements % basic configuration for elements
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:title:author % basic configuration for attributes
\xmlflush{#1}
\stopxmlsetups
I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.
I hope it helps,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@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
_________________________________________________
Mica Semrick
2016-08-14 05:03:37 UTC
Permalink
After doing some research, I stumbled upon saxon-lint (https://github.com/sputnick-dev/saxon-lint), a perl program
capable of using xpath3 expressions.

In the crudest form possible:

!# /bin/bash
for ELM in `saxon-lint.pl --xpath "distinct-values(//*/name())" file.xml`
do
echo -e "\\startxmlsetups xml:$ELM \n\t \\xmlflush{#1} \n \\stopxmlsetups"
done

I still need to write $ELM into an array to make it do the following:

\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements:from:the:variable:elm} % list the results from saxon-lint
{xml:*}
\stopxmlsetups

That would give me the "blank" mapping file I want, saving me the
trouble of typing out the whole thing every time.

Best,
Mica
Post by Pablo Rodriguez
Post by Hans Hagen
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file
Just guessing (or that would be useful for me too), a file with the
\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements} % all elements used in document listed here
{xml:*}
\xmlsetsetup{\xmldocument}
{xml:title:author} % with attributes
\stopxmlsetups
\xmlregistersetup{xml:pandoc}
\startxmlsetups xml:elements % basic configuration for elements
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:title:author % basic configuration for attributes
\xmlflush{#1}
\stopxmlsetups
I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.
I hope it helps,
Pablo
Hans Hagen
2016-08-14 13:38:07 UTC
Permalink
Post by Mica Semrick
After doing some research, I stumbled upon saxon-lint
(https://github.com/sputnick-dev/saxon-lint), a perl program
capable of using xpath3 expressions.
!# /bin/bash
for ELM in `saxon-lint.pl <http://saxon-lint.pl> --xpath
"distinct-values(//*/name())" file.xml`
do
echo -e "\\startxmlsetups xml:$ELM \n\t \\xmlflush{#1} \n \\stopxmlsetups"
done
\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements:from:the:variable:elm} % list the results from saxon-lint
{xml:*}
\stopxmlsetups
That would give me the "blank" mapping file I want, saving me the
trouble of typing out the whole thing every time.
we already have an analyzer:

context --extra=xml --analyze --autopdf music-collection.xml

i'll add a --template option for generating a bunch of setups (not the
most efficient way to define a mapping but anyway)

context --extra=xml --analyze --template --autopdf music-collection.xml
Post by Mica Semrick
Best,
Mica
Post by Pablo Rodriguez
Post by Hans Hagen
Post by Mica Semrick
Is there any feature or script that anyone can share that will read in
an XML document and spit out a blank mapping file?
what is a blank mapping file
Just guessing (or that would be useful for me too), a file with the
\startxmlsetups xml:blank:map % xml:[filename] would be also fine
\xmlsetsetup{\xmldocument}
{xml:elements} % all elements used in document listed here
{xml:*}
\xmlsetsetup{\xmldocument}
{xml:title:author} % with attributes
\stopxmlsetups
\xmlregistersetup{xml:pandoc}
\startxmlsetups xml:elements % basic configuration for elements
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:title:author % basic configuration for attributes
\xmlflush{#1}
\stopxmlsetups
I guess that the usefulness of this is not the actual configuration, but
to know what you have to configure.
I hope it helps,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
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-***@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
_______________________________
Loading...