If you wanted to be even fancier, you could do this to automatically set
the Content-Type header based on that XML declaration:

proc xml {args} {
    set contentType "text/xml"
    foreach onearg $args {
        if {[regexp {^encoding=\"(.*)\"$} $onearg - charset]} {
            append contentType "; charset=$charset"
            break
        }
    }
    headers type $contentType
    puts "<\?xml [join $args] \?\>"
}



On Wed, Jul 25, 2012 at 12:05 AM, Jeff Lawson <j...@bovine.net> wrote:

> Technically, Rivet doesn't validate the character that immediately follows
> <?, other than ensuring it is not <?=
>
> The "xml" that immediately follows the opening sequence is being executed
> as the command name.  You don't even need to modify the source to Rivet
> itself to define a proc in the global init script that was like this:
>
> <?
> proc xml {args} {
>     puts "<\?xml [join $args] \?\>"
> }
> ?>
>
> Then when Rivet encounters this sequence, it would execute the "xml" proc
> and just output the tag as you intended.
>
> <?xml version="1.0" encoding="UTF-8"?>
>
>
>
>
> On Tue, Jul 24, 2012 at 11:51 PM, Nagarajan Chinnasamy <
> nagarajanchinnas...@gmail.com> wrote:
>
>> Leaving aside what php does with this tag, isn't it a good practice for
>> any template engine to *emit* the patterns that it does not recognize?
>>
>> I don't know how <? tag is tokenized in Rivet. If we say, Rivet
>> recognizes the patterns "<?" and "<?=", then any other pattern of "<?xxxx"
>> should be emitted out as is....IMHO
>>
>> Best Regards,
>> Nagu.
>>
>>
>>
>> On Mon, Jul 23, 2012 at 12:11 PM, Jeff Lawson <j...@bovine.net> wrote:
>>
>>> As you know, the "<?" tag is also used by PHP (in its default short tag
>>> mode), so Rivet is not unique in choosing it. In any case, the choice was
>>> already made for the project long ago.
>>>
>>> You can also compile Rivet to use different tags if you really want to
>>> make your configuration even more non-standard... :)
>>>
>>>  -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
>>>
>>>
>>>
>>>
>>> On Sun, Jul 22, 2012 at 11:08 PM, Nagarajan Chinnasamy <
>>> nagarajanchinnas...@gmail.com> wrote:
>>>
>>>> Thanks Massimo & Jeff.
>>>>
>>>> However, from a user's perspective, my take on this issue  is that
>>>> Rivet should not hijack the entire "<?" tag to itself, especially  when
>>>> "<?xml" is a widely-used standard practice. Even before its sent to tcl
>>>> interpretter, why not just emit the whole tag when its not recognized by
>>>> rivet? As it was suggested, having a "<?rivet" tag may also help.
>>>>
>>>> This point leads me to the imagination of having a template that has
>>>> all different things embedded (xml, tcl code, php code etc.). This may need
>>>> a super-template-processing-module as an apache module that dispatches a
>>>> <?xxx block to the right template-processing-module based on configuration
>>>> directives.
>>>>
>>>> Best Regards,
>>>> Nagu.
>>>>
>>>>
>>>>
>>>> On Mon, Jul 23, 2012 at 5:13 AM, Jeff Lawson <j...@bovine.net> wrote:
>>>>
>>>>> If you need to output the XML declaration, you can output it with
>>>>> enough escaping:
>>>>>
>>>>> <?= "\<\?xml version=\"1.0\" encoding=\"UTF-8\"\?\>" ?>
>>>>>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
>>>>>       
>>>>> "http://www.w3.org/TR/xhtml11/**DTD/xhtml11.dtd<http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>
>>>>>  [1]">
>>>>>  ...
>>>>>
>>>>> I agree that it is a little bit of a pain to do, but PHP has the same
>>>>> trouble with that character sequence and requires an equivalent 
>>>>> workaround.
>>>>>
>>>>>
>>>>>
>>>>>  On Sun, Jul 22, 2012 at 5:13 PM, Massimo Manghi <
>>>>> massimo.man...@unipr.it> wrote:
>>>>>
>>>>>>
>>>>>> no way, the <? sequence invariably is parsed by the Rivet parser as
>>>>>> the beginning of a Tcl script section embedded in the template. You have 
>>>>>> to
>>>>>> remove it.
>>>>>>
>>>>>> Years ago someone suggested to support a different style of embedding
>>>>>> using <?rivet ...?> as tag for the specific reason of not messing up with
>>>>>> XML files. The proposal was filed as as bug #5553, it was acknowledged as
>>>>>> such, but was closed as 'wontfix' anyway. Time for resuming this issue?
>>>>>>
>>>>>>  regards
>>>>>>
>>>>>>  -- Massimo
>>>>>>
>>>>>>
>>>>>> On 2012-07-22 20:05, Nagarajan Chinnasamy wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> The "<?xml" tag that is part of a simple xhtml document (saved as
>>>>>>> .rvt
>>>>>>> template)  I generated from Amaya W3Cs editor throws error when
>>>>>>> browsed:
>>>>>>>
>>>>>>>  <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
>>>>>>>>       
>>>>>>>> "http://www.w3.org/TR/xhtml11/**DTD/xhtml11.dtd<http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>[1]">
>>>>>>>> <html 
>>>>>>>> xmlns="http://www.w3.org/1999/**xhtml<http://www.w3.org/1999/xhtml>[2]">
>>>>>>>>
>>>>>>>> <head>
>>>>>>>>   <meta http-equiv="content-type" content="text/html;
>>>>>>>> charset=UTF-8" />
>>>>>>>>   <title>My First RVT</title>
>>>>>>>>   <meta name="generator" content="Amaya, see
>>>>>>>> http://www.w3.org/Amaya/ [3]" />
>>>>>>>>
>>>>>>>> </head>
>>>>>>>> <body>
>>>>>>>> <h1>My First RVT</h1>
>>>>>>>> </body>
>>>>>>>> </html>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ------------------------------**------------------------------**
>>>>>> ---------
>>>>>> To unsubscribe, e-mail: 
>>>>>> rivet-dev-unsubscribe@tcl.**apache.org<rivet-dev-unsubscr...@tcl.apache.org>
>>>>>> For additional commands, e-mail: rivet-dev-h...@tcl.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Reply via email to