*目次 [#le8e42e0] #contents *目的 [#l85657bf] ブラウザごとというか、ベンダーごとのXSLの仕様の違いをまとめる。 **動機 [#y1c01d0e] シェアは現象傾向にある某ブラウザへの対応依頼があった。 *W3Cの仕様 [#wea09a72] http://www.w3.org/TR/xslt 参考データとかが書いてある。 *さまざまなXSLの実装 [#q5675bfb] **XSLのWiki [#ta9a8078] http://en.wikipedia.org/wiki/XML_template_engine wikiを見ると、ほんとうにいろいろな実装があるものだと思う。 ***Sablotron [#v1c8a8a7] SablotronがGETとかが扱えるようで良さげだったので、リンクをはっておく。 http://www.gingerall.org/sablotron.html **確認対象 [#tdbaed65] とりあえず、シェアの多そうなところだけ見てみる。 |Microsoft|| |Mozila|TransforMiiX.| |Safari|| **Microsoft [#le36e9f2] ***参考文献 [#ib838987] http://msdn.microsoft.com/ja-jp/library/aa468550.aspx **firefox [#i1c37333] ***TransforMiiX(firefoxがお手本にしているXSLT) [#w1f72cc9] http://www.mozilla.org/projects/xslt/ ***Tutorial [#x9636f59] http://nwalsh.com/docs/tutorials/xsl/xsl/slides.html 今は無きSunの2000年度のドキュメント! あたらしいのは、載っていないのかな? ***FAQ [#t244055e] https://developer.mozilla.org/en/XSL_Transformations_in_Mozilla_FAQ ***単体でTransforMiiXを起動させる方法 [#i568f784] https://developer.mozilla.org/en/Building_TransforMiiX_standalone ***firefoxの困った実装点 [#v267b3cd] Firefoxで disable-output-escaping="yes" 上記の仕様がXSLの仕様として決まっているにも関わらず、対応していない。 *disable-output-escaping [#z35f292e] disable-output-escapingの問題に特化したページ http://www.dpawson.co.uk/xsl/sect2/N2215.html ***とりあえずの対応方法 [#l0bb440b] <xsl:copy-of> を使って、生成済みのエレメントを複製する方法が書いてあった。(気にするケースはすくないと思うが、この場合、タグ要素は正規化される) ***firefox開発者の言い訳 [#r6c62587] FAQに言い訳が書いてある。 https://developer.mozilla.org/en/XSL_Transformations_in_Mozilla_FAQ ***バグ番号98168 [#s1bd5edc] 既に、バグとして起票済みで、たくさんの人が困っているもよう https://bugzilla.mozilla.org/show_bug.cgi?id=98168 直せばいいのに。。。 ***考察 [#x86817da] メリットとしては、ことごとく、特殊な文字は、エスケープしてしまうので、データによってレイアウトが崩れる心配は減る。 デメリット、<xsl:element>で要素を生成するしか手だてはないのだが、<hoge></hoge>という出力をしたくても、<hoge/>というタグの形式に正規化されてしまう。一見、問題ないように思えるのだが、とある、かつて一世風靡したブラウザのとあるタグが、<hoge/>を正常に認識せず、<hoge></hoge>という形式しか対応していないというのがあって、対応させられた思いがある。 これを防ぐ方法として、output-disable-encoding="yes"が使えないので、こまっていた件がある *属性値テンプレートという記述方法 [#x7796b00] http://ykr414.com/xml/xml05.html *ブラウザでの切り替え方法 [#h81d3069] **system-property [#e1e6f376] サンプルコード Version number: <xsl:value-of select="system-property('xsl:version')" /> Vendor: <xsl:value-of select="system-property('xsl:vendor')" /> Vendor URL: <xsl:value-of select="system-property('xsl:vendor-url')" /> ***使用例 [#jd5b8ecc] <xsl:if test="system-property('xsl:vendor')='Transformiix'"> <!-- Mozilla specific markup --> </xsl:if> <xsl:if test="system-property('xsl:vendor')='Microsoft'"> <!-- IE specific markup --> </xsl:if> ***MSXSLのバージョンでの切り替え [#vaa8e950] 参照元:firefoxのFAQ <xsl:if xmlns:msxsl="urn:schemas-microsoft-com:xslt" test="system-property('msxsl:version')=3"> <!-- MSXML3 specific markup --> </xsl:if> このサンプルでもしマイクロソフトのブラウザなどを使っている場合は、 <xsl:value-of select="system-property('xsl:vendor')" /> の値は Microsoft となる。 *参考文献 [#a90c1e26] http://www.devguru.com/technologies/xslt/quickref/xslt_function_systemproperty.html **たのしいXML [#w6132b7b] http://www6.airnet.ne.jp/manyo/xml/index.html *確認用のXML [#a7e87068] **その1 [#x03d12ab] <?xml version="1.0" > <object> <foo> <bar> hoge </bar> </foo> </object> *確認用のXSL [#a21f305d] **最小 [#t12d4f7c] <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <div> fuga </div> 正しいHTMLではないが、<div>タグで囲むと一応表示してくれた。 IEとfirefoxで確認した。 **HTML風 [#re9babc0] <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>SAMPLE</title> </head> <body> <div>fuga</div> </body> </html> </xsl:template>