Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#11 ESCAPE=XML for XML-legal output (HTML::Template v2.8)

open
nobody
None
5
2006-03-04
2006-03-04
Ralph Bolton
No

HTML::Template can be very useful for producing HTML or
XML output (since they're so closely related). However,
the ESCAPE=HTML facility does not produce XML legal
output, mostly because it does not convert all high-bit
characters and entities.

I have produced a patch which adds "ESCAPE=XML"
functionality to HTML::Template v2.8. In short, the
patch loads HTML::Entities if it's available, and then
uses HTML::Entities::encode_entities_numeric() to
encode strings. The 'numeric' variant is used because
XML only allows for a very small set of symbolic names
for entities.

If HTML::Entities is not available, then ESCAPE=XML
does the same as ESCAPE=HTML currently does.

This same technique could be used for ESCAPE=HTML where
HTML::Entities is available (where is isn't, then the
current functionality could be used as a fall-back). I
haven't done this, as there may be other implications.
The main benefit is of course that all entities would
be converted, which I suspect they really ought to be
(the fact that the &raquo character isn't encoded is
important, as it's used quite a bit - this could be
considered a bug).

All that said, if it's felt that the current behaiour
is okay, then users could use ESCAPE=XML as a
workaround (albeit getting numeric entities, rather
than far nicer symbolic names).

Discussion

  • Ralph Bolton
    Ralph Bolton
    2006-03-04

    Patch to add ESCAPE=XML functionality to HTML::Template v2.8

     
    Attachments