2009-07-29 13 views
6

XMLとXSLの両方を含む埋め込みファイルを作成しようとしています。テストはdpawson.co.ukの"XML and XSL in one file"に基づいています。ソースは次のようになります。埋め込みXMLとXSLファイルの操作方法

<?xml-stylesheet type="text/xml" href="#stylesheet"?> 
<!DOCTYPE doc [ 
<!ATTLIST xsl:stylesheet 
    id ID #REQUIRED> 
]> 
<doc> 
<xsl:stylesheet id="stylesheet" 
       version="1.0" 
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <!-- any xsl:import elements --> 
    <xsl:template match="xsl:stylesheet" /> 
    <!-- rest of your stylesheet --> 
</xsl:stylesheet> 

<!-- rest of your XML document --> 
</doc> 

元々は、XMLとXSLファイルを作成しました。 XMLは次のようになります。

<?xml-stylesheet type="text/xsl" href="data.xsl"?> 
<Report> 
    <ReportFor>Test Data</ReportFor> 
    <CreationTime>2009-07-29 05:37:14</CreationTime> 
</Report> 

そしてdata.xslファイルには、次のようになります。私は、XMLとXSLの両方を含む埋め込まれたXMLファイルを作成しようとしているこれらに基づいて

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="/"> 
    <!-- ... --> 
    <xsl:value-of select="Report/ReportFor" /> 
    <!-- ... --> 
    <xsl:value-of select="Report/CreationTime"/> 
    <!-- ... --> 
    </xsl:template> 
</xsl:stylesheet> 

現在、このファイルには、次のようになります。この文書で

<?xml-stylesheet type="text/xsl" href="#stylesheet"?> 
<!DOCTYPE doc [ 
<!ATTLIST xsl:stylesheet 
    id ID #REQUIRED> 
]> 
<doc> 
<xsl:stylesheet id="stylesheet" 
       version="1.0" 
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <!-- any xsl:import elements --> 
    <xsl:template match="xsl:stylesheet" /> 
    <!-- rest of your stylesheet --> 
    <xsl:template match="/"> 
    <!-- ... --> 
    <xsl:value-of select="Report/ReportFor" /> 
    <!-- ... --> 
    <xsl:value-of select="Report/CreationTime"/> 
    <!-- ... --> 
    </xsl:template> 
</xsl:stylesheet> 

<!-- rest of your XML document --> 
<Report> 
    <ReportFor>Test Data</ReportFor> 
    <CreationTime>2009-07-29 05:37:14</CreationTime> 
</Report> 

</doc> 

問題は<xsl:value-of>は、XMLセクションに表示されるデータを取得していないということです。 <xsl:value-of>は埋め込みデータをどのように認識できますか?特別な構文が必要ですか?

+0

を参照してください[http://stackoverflow.com/questions/360628/embed-xsl-into-an-xml-file](http://stackoverflow.com/questions/360628/embed -xsl-into-an-xml-file) – Scoregraphic

+1

私は「XMLをXSLに組み込む」提案を投稿しようとしていましたが、それは既に回答済みです:リンクが優れています。 – Tomalak

答えて

0

"。"演算子は値を取得する?

<xsl:value-of select="Report/ReportFor/."/> 
1

テンプレートの一致属性にdoc要素がありません。代わりにこれを試してみてください:

<xsl:template match="/doc"> 
    <xsl:value-of select="Report/ReportFor" /> 
</xsl:template> 
関連する問題