Setting output properties in your stylesheets
output_html.properties: Property Default value xalan:entities HTMLEntities Note You can also create your own HTML entity file (mapping characters to entities) or edit src/org/apache/xml/serializer/HTMLEntities.properties and rebuild xalan.jar.
XSLTプロセッサxalan-j を つかってXMLからHTMLへ変換出力するときに、 文字実体参照( > とか & とか)に 変換してくれますが、Netscape Communicator 4.7x などの古い 「実体参照への対応が不完全」なブラウザでは一部の文字実体参照(− とか Ö とか)は表示されない場合があります。
xalan-java 2.6.0 では以下のように xsl:stylesheet で xalan 名前空間を宣言しておいてから、 xsl:output に xalan:entities という プロパティで自分の HTMLEntities.propaerties ファイルをパスで指定すると そのファイルを利用して変換するようになります。
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xalan="http://xml.apache.org/xslt"
>
<xsl:output
method="html"
encoding="EUC-JP"
indent="yes"
xalan:entities="myentities.ent"
/>
myentities.ent は以下のように実体名とコード番号をスペースをはさんで書きます。
quot 34 amp 38 lt 60 gt 62
ただ、このままでは <html xmlns:xalan="http://xml.apache.org/xalan" > と HTMLに書かれてしまいますので、 stylesheet要素に結果ツリーに含めない名前空間をexclude-result-prefixesで指定します。
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xalan="http://xml.apache.org/xslt"
exclude-result-prefixes="xsl xalan"
>
<xsl:output
method="html"
encoding="EUC-JP"
indent="yes"
xalan:entities="myentities.ent"
/>
「新しいブラウザをインストールしてください」とはいえない状況もあるってこと。
