ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: inlining pretty-printed XML
@ 2003-02-14 12:04 Guy Worthington
  2003-02-16  9:03 ` Guy Worthington
  0 siblings, 1 reply; 5+ messages in thread
From: Guy Worthington @ 2003-02-14 12:04 UTC (permalink / raw)


I've looked at the verb-XML module, and verb-ini module, and have 
have seen hints that it may be possible to typeset XML code snippets,
such as   <table>  into the main text.

Is it possible to inline such XML expressions into the main text,
using the same color setup as has been defined in the verb-XML macros?

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

* Re: inlining pretty-printed XML
  2003-02-14 12:04 inlining pretty-printed XML Guy Worthington
@ 2003-02-16  9:03 ` Guy Worthington
  2003-02-17  1:14   ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Guy Worthington @ 2003-02-16  9:03 UTC (permalink / raw)


I'm seem to be using this mailing list as private correspondence, I'll
try to keep my posting down in future.  But..

Following up on my question on how to inline XML code, I vaguely
remember reading that the TeX primitive \par, has no effect in
restricted horizontal mode, (I think that's what it's called, anyways
the horizontal mode that's not paragraph mode).  So on that
assumption, I forced the verbatim pretty printer to operate inside an
\hbox, with the following code:

--------------------------------------------------

%output=pdf
\definetyping [XMLtag] [option=XML]
\setuptyping [XMLtag] [before={\ \hbox\bgroup},
                       after={\egroup\ },
                       palet=colorpretty]
    
\setupcolors[state=start]

\starttext

This is a 
\startXMLtag 
<TABLE/> 
\stopXMLtag
tag inline; and this is a comment 
\startXMLtag
<!-- comment -->
\stopXMLtag

\startXML
<!-- This is displayed XML -->
<TABLE/>
\stopXML    

\stoptext

--------------------------------------------------

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

* Re: Re: inlining pretty-printed XML
  2003-02-16  9:03 ` Guy Worthington
@ 2003-02-17  1:14   ` Hans Hagen
  2003-02-18 13:23     ` Guy Worthington
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2003-02-17  1:14 UTC (permalink / raw)


At 05:03 PM 2/16/2003 +0800, Guy Worthington wrote:
>I'm seem to be using this mailing list as private correspondence, I'll
>try to keep my posting down in future.  But..
>
>Following up on my question on how to inline XML code, I vaguely
>remember reading that the TeX primitive \par, has no effect in
>restricted horizontal mode, (I think that's what it's called, anyways
>the horizontal mode that's not paragraph mode).  So on that
>assumption, I forced the verbatim pretty printer to operate inside an
>\hbox, with the following code:
>
>--------------------------------------------------
>
>%output=pdf
>\definetyping [XMLtag] [option=XML]
>\setuptyping [XMLtag] [before={\ \hbox\bgroup},
>                        after={\egroup\ },
>                        palet=colorpretty]
>
>\setupcolors[state=start]
>
>\starttext
>
>This is a
>\startXMLtag
><TABLE/>
>\stopXMLtag
>tag inline; and this is a comment
>\startXMLtag
><!-- comment -->
>\stopXMLtag
>
>\startXML
><!-- This is displayed XML -->
><TABLE/>
>\stopXML
>
>\stoptext

did you try:

\setupcolors[state=start]

\definetype[typeXML][option=XML,palet=colorpretty]

test \typeXML{<what/>} test

\startXML
<what>
\stopXML

(ps i just found out that the palet is not predefined here, but the 
previous code should work ok)

Another nice one is:

%\setupXMLfile[level=2]
%\showXMLlin[here,there]
%\showXMLwrd[whow]

(ign,lin,wrd,par,txt,nop,emp)

\startbuffer
<here> <there> <whow> oeps </whow> </there> </here>
\stopbuffer

\showXMLbuffer

there is also \showXMLfile

i'll add an

\showXMLtext{<here> <there> <whow> oeps </whow> </there> </here>}
\showXMLtext{<here><there><whow>oeps</whow></there></here>}

this trickery is used in:

texexec --pdf --use=xml-01 somexmlfile [--mode=packed,wide]  : use 
pdftotext afterwards and you'll have a prettier xml file
texexec --pdf --use=xml-02 somexmlfile                       : pretty print 
(recognized xsd, rlg, xml, exa)

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

* Re: inlining pretty-printed XML
  2003-02-17  1:14   ` Hans Hagen
@ 2003-02-18 13:23     ` Guy Worthington
  2003-02-18 14:55       ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Guy Worthington @ 2003-02-18 13:23 UTC (permalink / raw)


Hans Hagen wrote:

> [to inline xml] try:

> \setupcolors[state=start]
>
> \definetype[typeXML][option=XML,palet=colorpretty]
>
> test \typeXML{<what/>} test

The code works, and, as usual, you've upstaged me with a much cleaner
interface.

> Another nice one is:
> 
> %\setupXMLfile[level=2]
> %\showXMLlin[here,there]
> %\showXMLwrd[whow]
> 
> (ign,lin,wrd,par,txt,nop,emp)
> 
> \startbuffer
> <here> <there> <whow> oeps </whow> </there> </here>
> \stopbuffer
> 
> \showXMLbuffer
> 
> there is also \showXMLfile

Hans, you make life hard.  I've been playing around with this, this
afternoon, it's like magic.  But now I've got to rethink how I
format XML to exploit the pretty-printing capability, especially how I
should group elements.

> this trickery is used in:
>
> $ texexec --pdf --use=xml-01 somexmlfile [--mode=packed,wide]  
>
> use pdftotext afterwards and you'll have a prettier xml file

Do you wake up in the morning and think to yourself I'll build a
better version of lgrind?  This I can use immediately.  Thankyou.

> $ texexec --pdf --use=xml-02 somexmlfile  
>
> pretty print (recognized xsd, rlg, xml, exa)

And it also comes in colour.

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

* Re: Re: inlining pretty-printed XML
  2003-02-18 13:23     ` Guy Worthington
@ 2003-02-18 14:55       ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2003-02-18 14:55 UTC (permalink / raw)


At 09:23 PM 2/18/2003 +0800, Guy Worthington wrote:

>Hans, you make life hard.  I've been playing around with this, this
>afternoon, it's like magic.  But now I've got to rethink how I
>format XML to exploit the pretty-printing capability, especially how I
>should group elements.

Say that you use relax ng, have the following def's in, say, eximple.rng:

<?xml version="1.0" ?>

<?context-block begin grammar ?>

<grammar xmlns="http://relaxng.org/ns/structure/1.0">

<?context-block end grammar ?>

<?context-block begin framework ?>

<start>
   <choice>
     <ref name="request"/>
     <ref name="reply"/>
   </choice>
</start>

<?context-block end framework ?>

.....

<?context-block begin grammar ?>

</grammar>

<?context-block end grammar ?>

then you can say:

\definefilesynonym [eximple] [eximple.rng]

and later on pick up the components:

\showRNGcomponent[eximple][framework]

saves you some work and make documentation in a separate file easier

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

end of thread, other threads:[~2003-02-18 14:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-14 12:04 inlining pretty-printed XML Guy Worthington
2003-02-16  9:03 ` Guy Worthington
2003-02-17  1:14   ` Hans Hagen
2003-02-18 13:23     ` Guy Worthington
2003-02-18 14:55       ` Hans Hagen

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