ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Custom XML Export
@ 2015-09-11 14:21 Toby Miller
  2015-09-12  9:53 ` Hans Hagen
  0 siblings, 1 reply; 16+ messages in thread
From: Toby Miller @ 2015-09-11 14:21 UTC (permalink / raw)
  To: ntg-context

I'm using ConTeXt's export to XML feature, but I'd like more control
over the XML output. Is there a way to define a TeX command that will
output a specific tag (<tag>content</tag>) around some text in the output?

Ideally I'd like to write a completely custom XML printer; it would be
very simple, but would allow me to define what tags I want for different
things. Is there a way to change the behaviour of the existing one, or
could you recommend a starting point for writing a new one?

Many thanks,

Toby
___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-11 14:21 Custom XML Export Toby Miller
@ 2015-09-12  9:53 ` Hans Hagen
  2015-09-12 11:37   ` Toby Miller
  0 siblings, 1 reply; 16+ messages in thread
From: Hans Hagen @ 2015-09-12  9:53 UTC (permalink / raw)
  To: ntg-context

On 9/11/2015 4:21 PM, Toby Miller wrote:
> I'm using ConTeXt's export to XML feature, but I'd like more control
> over the XML output. Is there a way to define a TeX command that will
> output a specific tag (<tag>content</tag>) around some text in the output?

\setupbackend[export=yes]

\definehighlight[this]

\starttext
     \startelement[what]
          \this{that}  \input ward
     \stopelement
\stoptext

(there are also ways to add extra properties)

> Ideally I'd like to write a completely custom XML printer; it would be
> very simple, but would allow me to define what tags I want for different
> things. Is there a way to change the behaviour of the existing one, or
> could you recommend a starting point for writing a new one?

the export resembles the structure used in the source and making each 
aspect configurable not only adds much overhead but is also kind of 
useless as one can easily transform xml into other xml; it's no problem 
to add a few more details here or there , but th emain indea behind the 
export is to have standardized and predictable output that then can be 
either rendered using css or converted (for that the raw file is best).

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12  9:53 ` Hans Hagen
@ 2015-09-12 11:37   ` Toby Miller
  2015-09-12 12:00     ` Hans Hagen
  2015-09-12 12:04     ` Henning Hraban Ramm
  0 siblings, 2 replies; 16+ messages in thread
From: Toby Miller @ 2015-09-12 11:37 UTC (permalink / raw)
  To: ntg-context

Thank you! That's exactly what I was looking for.

I have a few other things I'd like to be able to do with this kind of
thing (print '<br />' self-closed tags for example, and add attributes
as you say), but I feel bad about posting to the list for them. Is there
any documentation for these features at all? I couldn't find any
reference to the \startelement command when I looked, but perhaps I'm
looking in the wrong place.

I'll take your advice and not try to adapt the export system. Now that I
can print tags at least I think XML transformation should be able to
deal with everything I need if it comes to it.

Toby

On 12/09/15 10:53, Hans Hagen wrote:
> On 9/11/2015 4:21 PM, Toby Miller wrote:
>> I'm using ConTeXt's export to XML feature, but I'd like more control
>> over the XML output. Is there a way to define a TeX command that will
>> output a specific tag (<tag>content</tag>) around some text in the
>> output?
>
> \setupbackend[export=yes]
>
> \definehighlight[this]
>
> \starttext
>     \startelement[what]
>          \this{that}  \input ward
>     \stopelement
> \stoptext
>
> (there are also ways to add extra properties)
>
>> Ideally I'd like to write a completely custom XML printer; it would be
>> very simple, but would allow me to define what tags I want for different
>> things. Is there a way to change the behaviour of the existing one, or
>> could you recommend a starting point for writing a new one?
>
> the export resembles the structure used in the source and making each
> aspect configurable not only adds much overhead but is also kind of
> useless as one can easily transform xml into other xml; it's no
> problem to add a few more details here or there , but th emain indea
> behind the export is to have standardized and predictable output that
> then can be either rendered using css or converted (for that the raw
> file is best).
>
> 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
> ___________________________________________________________________________________

___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 11:37   ` Toby Miller
@ 2015-09-12 12:00     ` Hans Hagen
  2015-09-12 12:22       ` Toby Miller
  2015-09-12 12:04     ` Henning Hraban Ramm
  1 sibling, 1 reply; 16+ messages in thread
From: Hans Hagen @ 2015-09-12 12:00 UTC (permalink / raw)
  To: ntg-context

On 9/12/2015 1:37 PM, Toby Miller wrote:
> Thank you! That's exactly what I was looking for.
>
> I have a few other things I'd like to be able to do with this kind of
> thing (print '<br />' self-closed tags for example, and add attributes
> as you say), but I feel bad about posting to the list for them. Is there
> any documentation for these features at all? I couldn't find any
> reference to the \startelement command when I looked, but perhaps I'm
> looking in the wrong place.

\setupbackend[export=yes]
\setupexport[properties=yes]

\starttext
      \startelement[test][this=that]whatever\stopelement
\stoptext

arbitrary empty elements are tricky as there is no content then, so that 
needs thinking

(you can of course abuse \startelement

\startelement[br]x\stopelement

and then remove the x from the exported xml. I'll think about it (no 
time now).

Hans


> I'll take your advice and not try to adapt the export system. Now that I
> can print tags at least I think XML transformation should be able to
> deal with everything I need if it comes to it.
>
> Toby
>
> On 12/09/15 10:53, Hans Hagen wrote:
>> On 9/11/2015 4:21 PM, Toby Miller wrote:
>>> I'm using ConTeXt's export to XML feature, but I'd like more control
>>> over the XML output. Is there a way to define a TeX command that will
>>> output a specific tag (<tag>content</tag>) around some text in the
>>> output?
>>
>> \setupbackend[export=yes]
>>
>> \definehighlight[this]
>>
>> \starttext
>>      \startelement[what]
>>           \this{that}  \input ward
>>      \stopelement
>> \stoptext
>>
>> (there are also ways to add extra properties)
>>
>>> Ideally I'd like to write a completely custom XML printer; it would be
>>> very simple, but would allow me to define what tags I want for different
>>> things. Is there a way to change the behaviour of the existing one, or
>>> could you recommend a starting point for writing a new one?
>>
>> the export resembles the structure used in the source and making each
>> aspect configurable not only adds much overhead but is also kind of
>> useless as one can easily transform xml into other xml; it's no
>> problem to add a few more details here or there , but th emain indea
>> behind the export is to have standardized and predictable output that
>> then can be either rendered using css or converted (for that the raw
>> file is best).
>>
>> 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
>> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 11:37   ` Toby Miller
  2015-09-12 12:00     ` Hans Hagen
@ 2015-09-12 12:04     ` Henning Hraban Ramm
  2015-09-12 12:14       ` Hans Hagen
                         ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: Henning Hraban Ramm @ 2015-09-12 12:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2015-09-12 um 17:37 schrieb Toby Miller <tobycmiller@gmail.com>:

> I have a few other things I'd like to be able to do with this kind of
> thing (print '<br />' self-closed tags for example, and add attributes
> as you say), but I feel bad about posting to the list for them. Is there
> any documentation for these features at all? I couldn't find any
> reference to the \startelement command when I looked, but perhaps I'm
> looking in the wrong place.
> 
> I'll take your advice and not try to adapt the export system. Now that I
> can print tags at least I think XML transformation should be able to
> deal with everything I need if it comes to it.

Hi Toby, have a look at

http://wiki.contextgarden.net/XML
http://wiki.contextgarden.net/Export
http://wiki.contextgarden.net/ePub

Since my ePub workflow is now running, I’ll hopefully soon enhance these pages...

There’s also a useful manual in texmf-context/doc/context/documents/general/manuals/epub-mkiv.pdf

Do you know a good XSLT processor except Saxon? Its free version is just too limited.


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:04     ` Henning Hraban Ramm
@ 2015-09-12 12:14       ` Hans Hagen
  2015-09-12 12:21         ` Toby Miller
  2015-09-12 12:14       ` luigi scarso
  2015-09-12 20:53       ` Aditya Mahajan
  2 siblings, 1 reply; 16+ messages in thread
From: Hans Hagen @ 2015-09-12 12:14 UTC (permalink / raw)
  To: ntg-context

On 9/12/2015 2:04 PM, Henning Hraban Ramm wrote:
> Am 2015-09-12 um 17:37 schrieb Toby Miller <tobycmiller@gmail.com>:
>
>> I have a few other things I'd like to be able to do with this kind of
>> thing (print '<br />' self-closed tags for example, and add attributes
>> as you say), but I feel bad about posting to the list for them. Is there
>> any documentation for these features at all? I couldn't find any
>> reference to the \startelement command when I looked, but perhaps I'm
>> looking in the wrong place.
>>
>> I'll take your advice and not try to adapt the export system. Now that I
>> can print tags at least I think XML transformation should be able to
>> deal with everything I need if it comes to it.
>
> Hi Toby, have a look at
>
> http://wiki.contextgarden.net/XML
> http://wiki.contextgarden.net/Export
> http://wiki.contextgarden.net/ePub
>
> Since my ePub workflow is now running, I’ll hopefully soon enhance these pages...
>
> There’s also a useful manual in texmf-context/doc/context/documents/general/manuals/epub-mkiv.pdf
>
> Do you know a good XSLT processor except Saxon? Its free version is just too limited.

I must admit that it's years ago that I really looked into it but we use 
xsltproc for generating the website (each time we update the 
distrubution we regenerate the pages). If I had to transform I'd use 
xsltproc.

http://xmlsoft.org/XSLT/xsltproc2.html

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:04     ` Henning Hraban Ramm
  2015-09-12 12:14       ` Hans Hagen
@ 2015-09-12 12:14       ` luigi scarso
  2015-09-12 12:28         ` Henning Hraban Ramm
  2015-09-12 14:25         ` Hans Hagen
  2015-09-12 20:53       ` Aditya Mahajan
  2 siblings, 2 replies; 16+ messages in thread
From: luigi scarso @ 2015-09-12 12:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1302 bytes --]

On Sat, Sep 12, 2015 at 2:04 PM, Henning Hraban Ramm <texml@fiee.net> wrote:

> Am 2015-09-12 um 17:37 schrieb Toby Miller <tobycmiller@gmail.com>:
>
> > I have a few other things I'd like to be able to do with this kind of
> > thing (print '<br />' self-closed tags for example, and add attributes
> > as you say), but I feel bad about posting to the list for them. Is there
> > any documentation for these features at all? I couldn't find any
> > reference to the \startelement command when I looked, but perhaps I'm
> > looking in the wrong place.
> >
> > I'll take your advice and not try to adapt the export system. Now that I
> > can print tags at least I think XML transformation should be able to
> > deal with everything I need if it comes to it.
>
> Hi Toby, have a look at
>
> http://wiki.contextgarden.net/XML
> http://wiki.contextgarden.net/Export
> http://wiki.contextgarden.net/ePub
>
> Since my ePub workflow is now running, I’ll hopefully soon enhance these
> pages...
>
> There’s also a useful manual in
> texmf-context/doc/context/documents/general/manuals/epub-mkiv.pdf
>
> Do you know a good XSLT processor except Saxon? Its free version is just
> too limited.
>
>
xsltproc for xslt 1.0, but you are looking for xslt 2.0 , right ?

-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 2090 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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:14       ` Hans Hagen
@ 2015-09-12 12:21         ` Toby Miller
  0 siblings, 0 replies; 16+ messages in thread
From: Toby Miller @ 2015-09-12 12:21 UTC (permalink / raw)
  To: ntg-context



On 12/09/15 13:14, Hans Hagen wrote:
> On 9/12/2015 2:04 PM, Henning Hraban Ramm wrote:
>> Am 2015-09-12 um 17:37 schrieb Toby Miller <tobycmiller@gmail.com>:
>>
>>> I have a few other things I'd like to be able to do with this kind of
>>> thing (print '<br />' self-closed tags for example, and add attributes
>>> as you say), but I feel bad about posting to the list for them. Is
>>> there
>>> any documentation for these features at all? I couldn't find any
>>> reference to the \startelement command when I looked, but perhaps I'm
>>> looking in the wrong place.
>>>
>>> I'll take your advice and not try to adapt the export system. Now
>>> that I
>>> can print tags at least I think XML transformation should be able to
>>> deal with everything I need if it comes to it.
>>
>> Hi Toby, have a look at
>>
>> http://wiki.contextgarden.net/XML
>> http://wiki.contextgarden.net/Export
>> http://wiki.contextgarden.net/ePub
>>
>> Since my ePub workflow is now running, I’ll hopefully soon enhance
>> these pages...
>>
>> There’s also a useful manual in
>> texmf-context/doc/context/documents/general/manuals/epub-mkiv.pdf
>>
>> Do you know a good XSLT processor except Saxon? Its free version is
>> just too limited.
>
> I must admit that it's years ago that I really looked into it but we
> use xsltproc for generating the website (each time we update the
> distrubution we regenerate the pages). If I had to transform I'd use
> xsltproc.
>
> http://xmlsoft.org/XSLT/xsltproc2.html
>
> Hans

Thanks for the suggestions. I had found those pages, but I'll keep
watching them for updates.

I hadn't particularly planned how I would do the XML transformation, and
I haven't done it before, but a quick Google would suggest xsltproc too,
and that's what I'll start with if I need to.

Toby
___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:00     ` Hans Hagen
@ 2015-09-12 12:22       ` Toby Miller
  0 siblings, 0 replies; 16+ messages in thread
From: Toby Miller @ 2015-09-12 12:22 UTC (permalink / raw)
  To: ntg-context



On 12/09/15 13:00, Hans Hagen wrote:
> On 9/12/2015 1:37 PM, Toby Miller wrote:
>> Thank you! That's exactly what I was looking for.
>>
>> I have a few other things I'd like to be able to do with this kind of
>> thing (print '<br />' self-closed tags for example, and add attributes
>> as you say), but I feel bad about posting to the list for them. Is there
>> any documentation for these features at all? I couldn't find any
>> reference to the \startelement command when I looked, but perhaps I'm
>> looking in the wrong place.
>
> \setupbackend[export=yes]
> \setupexport[properties=yes]
>
> \starttext
>      \startelement[test][this=that]whatever\stopelement
> \stoptext
>
> arbitrary empty elements are tricky as there is no content then, so
> that needs thinking
>
> (you can of course abuse \startelement
>
> \startelement[br]x\stopelement
>
> and then remove the x from the exported xml. I'll think about it (no
> time now).
>
> Hans

Makes sense! I think I have what I need for the moment; thanks for your
help.

Toby

>
>
>> I'll take your advice and not try to adapt the export system. Now that I
>> can print tags at least I think XML transformation should be able to
>> deal with everything I need if it comes to it.
>>
>> Toby
>>
>> On 12/09/15 10:53, Hans Hagen wrote:
>>> On 9/11/2015 4:21 PM, Toby Miller wrote:
>>>> I'm using ConTeXt's export to XML feature, but I'd like more control
>>>> over the XML output. Is there a way to define a TeX command that will
>>>> output a specific tag (<tag>content</tag>) around some text in the
>>>> output?
>>>
>>> \setupbackend[export=yes]
>>>
>>> \definehighlight[this]
>>>
>>> \starttext
>>>      \startelement[what]
>>>           \this{that}  \input ward
>>>      \stopelement
>>> \stoptext
>>>
>>> (there are also ways to add extra properties)
>>>
>>>> Ideally I'd like to write a completely custom XML printer; it would be
>>>> very simple, but would allow me to define what tags I want for
>>>> different
>>>> things. Is there a way to change the behaviour of the existing one, or
>>>> could you recommend a starting point for writing a new one?
>>>
>>> the export resembles the structure used in the source and making each
>>> aspect configurable not only adds much overhead but is also kind of
>>> useless as one can easily transform xml into other xml; it's no
>>> problem to add a few more details here or there , but th emain indea
>>> behind the export is to have standardized and predictable output that
>>> then can be either rendered using css or converted (for that the raw
>>> file is best).
>>>
>>> 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
>>> ___________________________________________________________________________________
>>>
>>
>> ___________________________________________________________________________________
>>
>> 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
>> ___________________________________________________________________________________
>>
>>
>
>

___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:14       ` luigi scarso
@ 2015-09-12 12:28         ` Henning Hraban Ramm
  2015-09-14  9:12           ` luigi scarso
                             ` (2 more replies)
  2015-09-12 14:25         ` Hans Hagen
  1 sibling, 3 replies; 16+ messages in thread
From: Henning Hraban Ramm @ 2015-09-12 12:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2015-09-12 um 18:14 schrieb luigi scarso <luigi.scarso@gmail.com>:

>> Do you know a good XSLT processor except Saxon? Its free version is just too limited.
> 
> xsltproc for xslt 1.0, but you are looking for xslt 2.0 , right ?

More like 3.0, I guess ;)
No, the only extension from commercial Saxon that I would need are global variables.

I didn’t yet dive into xsltproc’s (libxml2’s) documentation to see what might be possible.

E.g. if I don’t markup all my paragraphs (because it clutters the source too much and is tedious), I get <break />s between the original paragraphs. I could convert these to HTML <p>s like:


<xsl:variable name="within-paragraph">0</xsl:variable >

<xsl:template match="break">
<xsl:if test="within-paragraph = 0">
<xsl:text disable-output-escaping="yes"><![CDATA[</p><p>]]></xsl:text>
</xsl:if>
<xsl:if test="within-paragraph > 0">
<br />
</xsl:if>
</xsl:template>

<xsl:template match="paragraph">
<xsl:variable name="within-paragraph">1</xsl:variable >
<p><xsl:apply-templates/></p>
<xsl:variable name="within-paragraph">0</xsl:variable >
</xsl:template>


Maybe there’s another solution, but I’m not comfortable enough in XSL to see it.


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:14       ` luigi scarso
  2015-09-12 12:28         ` Henning Hraban Ramm
@ 2015-09-12 14:25         ` Hans Hagen
  1 sibling, 0 replies; 16+ messages in thread
From: Hans Hagen @ 2015-09-12 14:25 UTC (permalink / raw)
  To: ntg-context

On 9/12/2015 2:14 PM, luigi scarso wrote:

> xsltproc for xslt 1.0, but you are looking for xslt 2.0 , right ?

for regular transformations that's good enough

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:04     ` Henning Hraban Ramm
  2015-09-12 12:14       ` Hans Hagen
  2015-09-12 12:14       ` luigi scarso
@ 2015-09-12 20:53       ` Aditya Mahajan
  2015-09-14  9:57         ` Henning Hraban Ramm
  2 siblings, 1 reply; 16+ messages in thread
From: Aditya Mahajan @ 2015-09-12 20:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sat, 12 Sep 2015, Henning Hraban Ramm wrote:

> Do you know a good XSLT processor except Saxon? Its free version is just 
> too limited.

Why not just use your favorite programming language; most languages have a 
decent XML parsing library?

Aditya
___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:28         ` Henning Hraban Ramm
@ 2015-09-14  9:12           ` luigi scarso
  2015-09-14 18:09           ` Jan Tosovsky
       [not found]           ` <00cd01d0ef18$6f13da50$4d3b8ef0$@tosovsky@email.cz>
  2 siblings, 0 replies; 16+ messages in thread
From: luigi scarso @ 2015-09-14  9:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 493 bytes --]

On Sat, Sep 12, 2015 at 2:28 PM, Henning Hraban Ramm <texml@fiee.net> wrote:

> Am 2015-09-12 um 18:14 schrieb luigi scarso <luigi.scarso@gmail.com>:
>
> >> Do you know a good XSLT processor except Saxon? Its free version is
> just too limited.
> >
> > xsltproc for xslt 1.0, but you are looking for xslt 2.0 , right ?
>
> More like 3.0, I guess ;)
>

Saxonica has also an opensource java/c# xslt 2.0
http://www.saxonica.com/products/latest.xml

(xslt 3.0 is still a draft right ?)

-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 1137 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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 20:53       ` Aditya Mahajan
@ 2015-09-14  9:57         ` Henning Hraban Ramm
  0 siblings, 0 replies; 16+ messages in thread
From: Henning Hraban Ramm @ 2015-09-14  9:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2015-09-13 um 02:53 schrieb Aditya Mahajan <adityam@umich.edu>:

>> Do you know a good XSLT processor except Saxon? Its free version is just too limited.
> 
> Why not just use your favorite programming language; most languages have a decent XML parsing library?

Yes of course (mine is Python). I don’t know why I stick to shell scripts so much.
It’s maybe just that "everyone and his dog" suggests XSLT to transform XML files.


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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] 16+ messages in thread

* Re: Custom XML Export
  2015-09-12 12:28         ` Henning Hraban Ramm
  2015-09-14  9:12           ` luigi scarso
@ 2015-09-14 18:09           ` Jan Tosovsky
       [not found]           ` <00cd01d0ef18$6f13da50$4d3b8ef0$@tosovsky@email.cz>
  2 siblings, 0 replies; 16+ messages in thread
From: Jan Tosovsky @ 2015-09-14 18:09 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

[-- Attachment #1: Type: text/plain, Size: 2269 bytes --]

On 2015-09-12 Henning Hraban Ramm wrote:
> Am 2015-09-12 um 18:14 schrieb luigi scarso <luigi.scarso@gmail.com>:
> 
> > Do you know a good XSLT processor except Saxon? Its free version is
> > just too limited.
> > 
> > xsltproc for xslt 1.0, but you are looking for xslt 2.0 , right ?
> 
> No, the only extension from commercial Saxon ...
 
XSLT 1.0 is capable to handle anything (turing machine).
XSLT 2.0 brings some syntactic sugar.
XSLT 3.0 supports streaming.
 
If you need 2.0 features, you can use Saxon-B 9.1.0.8 (free, but not
maintained any more).

> ... I would need are global variables.

In pure XSLT any variable is fixed and its value cannot be changed. There
are, however, different approaches how to accomplish this. Most common is
defining template parameters and passing the proper values via them, see
below.

> E.g. if I don’t markup all my paragraphs (because it clutters the
> source too much and is tedious), I get <break />s between the original
> paragraphs. I could convert these to HTML <p>s like:
> 
> 
> <xsl:variable name="within-paragraph">0</xsl:variable >
> 
> <xsl:template match="break">
> <xsl:if test="within-paragraph = 0">
> <xsl:text disable-output-escaping="yes"><![CDATA[</p><p>]]></xsl:text>
> </xsl:if>
> <xsl:if test="within-paragraph > 0">
> <br />
> </xsl:if>
> </xsl:template>
> 
> <xsl:template match="paragraph">
> <xsl:variable name="within-paragraph">1</xsl:variable >
> <p><xsl:apply-templates/></p>
> <xsl:variable name="within-paragraph">0</xsl:variable >
> </xsl:template>


<xsl:template match="your-element" name="your-element">
   <!-- default value -->
   <xsl:param name="within-paragraph" select="0"/>
   <!-- your code -->
</xsl:template>

<xsl:apply-templates select="your-element">
   <!-- overriding a default value -->
   <xsl:with-param name="within-paragraph" select="1">
</xsl:apply-templates>


Btw, istead of 
<xsl:text disable-output-escaping="yes"><![CDATA[</p><p>]]></xsl:text>

you can write 
<p/>


> Maybe there’s another solution, but I’m not comfortable enough in XSL
> to see it.

Yes, functional programming requires different approaches, but I undestand
it can be tough. As for me in early stages :-)

Jan

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 3138 bytes --]

[-- 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] 16+ messages in thread

* Re: Custom XML Export
       [not found]           ` <00cd01d0ef18$6f13da50$4d3b8ef0$@tosovsky@email.cz>
@ 2015-09-15  4:11             ` Henning Hraban Ramm
  0 siblings, 0 replies; 16+ messages in thread
From: Henning Hraban Ramm @ 2015-09-15  4:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2015-09-15 um 00:09 schrieb Jan Tosovsky <j.tosovsky@email.cz>:

> XSLT 1.0 is capable to handle anything (turing machine).
> XSLT 2.0 brings some syntactic sugar.
> XSLT 3.0 supports streaming.
> 
> If you need 2.0 features, you can use Saxon-B 9.1.0.8 (free, but not
> maintained any more).

Thank you, I’ll first try xsltproc.

>> ... I would need are global variables.
> 
> In pure XSLT any variable is fixed and its value cannot be changed. There
> are, however, different approaches how to accomplish this. Most common is
> defining template parameters and passing the proper values via them, see
> below.
> 
>> E.g. if I don’t markup all my paragraphs (because it clutters the
>> source too much and is tedious), I get <break />s between the original
>> paragraphs. I could convert these to HTML <p>s like:
>> 
>> 
>> <xsl:variable name="within-paragraph">0</xsl:variable >
>> 
>> <xsl:template match="break">
>> <xsl:if test="within-paragraph = 0">
>> <xsl:text disable-output-escaping="yes"><![CDATA[</p><p>]]></xsl:text>
>> </xsl:if>
>> <xsl:if test="within-paragraph > 0">
>> <br />
>> </xsl:if>
>> </xsl:template>
>> 
>> <xsl:template match="paragraph">
>> <xsl:variable name="within-paragraph">1</xsl:variable >
>> <p><xsl:apply-templates/></p>
>> <xsl:variable name="within-paragraph">0</xsl:variable >
>> </xsl:template>
> 
> 
> <xsl:template match="your-element" name="your-element">
>   <!-- default value -->
>   <xsl:param name="within-paragraph" select="0"/>
>   <!-- your code -->
> </xsl:template>
> 
> <xsl:apply-templates select="your-element">
>   <!-- overriding a default value -->
>   <xsl:with-param name="within-paragraph" select="1">
> </xsl:apply-templates>

Thank you very much!


> Btw, istead of 
> <xsl:text disable-output-escaping="yes"><![CDATA[</p><p>]]></xsl:text>
> 
> you can write 
> <p/>

No, </p><p> ist not <p></p>!

I want to get from

text text text
<break />
text text text

(when I don’t use \start/stopparagraph)

to

<p>
text text text
</p>
<p>
text text text
</p>

But *if* there is paragraph markup, <break /> should become <br />. That’s why I tried to use a status variable to know if there was a explicit paragraph start.


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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] 16+ messages in thread

end of thread, other threads:[~2015-09-15  4:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-11 14:21 Custom XML Export Toby Miller
2015-09-12  9:53 ` Hans Hagen
2015-09-12 11:37   ` Toby Miller
2015-09-12 12:00     ` Hans Hagen
2015-09-12 12:22       ` Toby Miller
2015-09-12 12:04     ` Henning Hraban Ramm
2015-09-12 12:14       ` Hans Hagen
2015-09-12 12:21         ` Toby Miller
2015-09-12 12:14       ` luigi scarso
2015-09-12 12:28         ` Henning Hraban Ramm
2015-09-14  9:12           ` luigi scarso
2015-09-14 18:09           ` Jan Tosovsky
     [not found]           ` <00cd01d0ef18$6f13da50$4d3b8ef0$@tosovsky@email.cz>
2015-09-15  4:11             ` Henning Hraban Ramm
2015-09-12 14:25         ` Hans Hagen
2015-09-12 20:53       ` Aditya Mahajan
2015-09-14  9:57         ` Henning Hraban Ramm

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).