On Thu, Aug 31, 2000 at 10:09:29AM +0200, Petr Cimprich wrote:
> Hi,
>
> Output other than utf-8 is generated thanks to iconv library, which is present
> by default in most (Unix) systems. When using the html output method, the 0.43
> adds a corresponding META tag to the HEAD section of resulting document, so that
> browsers display it correctly.
>
> In other words, using <xsl:output method="html"/ encoding="your_encoding"> is
> enough, you do NOT have to include a literal META tag in the same stylesheet
> (for 0.43 or later). Such a inclusion results in a duplicate META declaration,
> where the second one is ignored by browsers.
>
> The html output method is selected by default if the document element of the
> result tree is <html>, so <xsl:output encoding="your_encoding"> should be
> sufficient to encode and display your HTML correctly. It works for me with
> iso-8859-2.
I had the same problem but the xsl:output did not work for me because I
did not have the iconv library. I did a quick and dirty hack that
postprocesses the output of sabcmd with a Python script using recode
(see below).
BTW: I read something about a Python integration of Sablotron but could
not find anything on the server (yet?). Where is it and what exactly is
planned here?
--
Guenter Radestock, Universitaetsbibliothek Karlsruhe
[EMAIL PROTECTED]
http://www.ubka.uni-karlsruhe.de/~guenter
----------
#!/usr/local/bin/python
#things to do (maybe in 3000...):
# - don't read everything into memory
# - support other encodings
import sys, re, string, os
text = sys.stdin.read()
m = re.match(r'<\?xml(\s+version=(\'[^\']*\'|"[^"]*"))?(\s+encoding=(\'[^\']*\'|
"[^"]*"))?', text)
if m:
if m.group(3):
if string.lower(m.group(4)[1:-1]) == 'utf-8':
sys.stdout.write(text[:m.start(4)])
sys.stdout.write('"ISO-8859-1"')
sys.stdout.flush()
of = os.popen('recode UTF-8..ISO_8859-1', 'w')
of.write(text[m.end(4):])
else:
sys.stdout.write(text)
else:
sys.stdout.write(text[:m.end(0)])
sys.stdout.write(' encoding="ISO-8859-1" ')
sys.stdout.flush()
of = os.popen('recode UTF-8..ISO_8859-1', 'w')
of.write(text[m.end(0):])
else:
sys.stdout.write(text)