2011-01-06 6 views
1

xssltを使ってレンダリングされたXML文書にrss-doctypeを追加しようとしています。ルート要素を変更するにはどうすればよいですか?xsltを使用してhtmlからrssにDojoタイプのルート要素を変更しますか?

<!DOCTYPE html PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "about:legacy-compat"> 

私が希望:(参照あなたがDTDを含める必要が

<xsl:output 
method="xml" 
version="1.0" 
encoding="UTF-8" 
doctype-public="-//Netscape Communications//DTD RSS 0.91//EN" 
indent="yes" 
/> 
+0

あなたは '<!DOCTYPE'を生成するだけですか?ノードを変更するには? –

+0

良い質問、+1。私の答えは完全な解決策を見てください。 –

答えて

1

:ここ

<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "about:legacy-compat"> 

は私の出力ノードである

これ

は、それが現在のように見えるものです http://www.stylusstudio.com/xsllist/200405/post70520.htmlと回答 http://www.stylusstudio.com/xsllist/200405/post90520.html David Carlisleがこれを指摘しています)。以下は、正しい構文です - あなたはここでDTD

<xsl:output method="xml" indent="yes" encoding="UTF-8" 
doctype-system="http://foo.org/dont.know.the.dtd" 
doctype-public="-//Netscape Communications//DTD RSS 0.91//EN"/> 
0

を見つける必要があります簡単な例です(使用しない)任意のXML文書がこの変換で処理されたときに、

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output method="xml" indent="yes" 
doctype-system="http://www.silmaril.ie/software/rss2.dtd" 
doctype-public="-//Netscape Communications//DTD RSS 0.91//EN"/> 
<xsl:template match="/"> 
    <rss> 
    <channel/> 
    </rss> 
</xsl:template> 
</xsl:stylesheet> 

必要な正しい結果が生成されます

<!DOCTYPE rss 
    PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://www.silmaril.ie/software/rss2.dtd"> 
<rss> 
    <channel/> 
</rss> 
関連する問題