2015-01-09 79 views
0

我已經得到了以下兩個XML文件:編碼XSLT XML

在我的XSLT從獲取其內容的XML:

<?xml-stylesheet type='text/xsl' href='report.xsl'? encoding='UTF-8'? version="1.0"> 

<configuration version="1.0"> 
    <profession id="DENT"> 
    <applicationType id="DENT AGREE_STD_DS_TRAINING_PLAN"> 
     <discipline id="306"/> 
     <document id="DIPL"/> 
     <document id="STGEPL"/> 
    </applicationType> 
    </profession> 

    <description type="profession" id="MED"> 
    <documentation language="NL">Geneesheer</documentation> 
    <documentation language="FR">Médicin</documentation> 
    </description> 

的XSTL文件:

<?xml version="1.0" encoding="UTF-8"?> 

<xsl:template match="/"> 
    <html> 
     <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
      <title>TS 
       <xsl:value-of select="//ts/@name"/> 
      </title> 
      <style> 
       body {background-color: #202020; color:white;font-family: verdana;} 
       h1 {color: white; font-size:24} 
       h2 {color: #606060; font-size:18} 
       h3 {color: #B40404; font-size:16} 
       p {font-size:16} 
       tr.passed td{background-color: green; color: white} 
       .passed {background-color: green; color: white} 
       tr.failed td{background-color: red; color:white} 
       .failed {background-color: red; color:white} 
       tr.blocked td{background-color: gold} 
       .blocked {background-color: gold} 
       a {color:#CEE3F6} 
      </style> 
     </head> 
     <body> 
      <h1>XSD</h1> 
      <div id="xsd"></div> 
      <h1>Structure document</h1> 
      <ul> 
       <xsl:apply-templates select="/configuration/profession"/> 
      </ul> 

      <ul> 
       <xsl:apply-templates select="/configuration/description"/> 
      </ul> 

      <div> 
       Some content! 
      </div> 
     </body> 
    </html> 
</xsl:template> 

<xsl:template match="//profession"> 
    <li> 
     <p> 
      <a href=""> 
       Profession: 
       <xsl:value-of select="@id"/> 
      </a> 
     </p> 
     <ul> 
      <xsl:apply-templates select="./applicationType"/> 
     </ul> 
    </li> 

</xsl:template> 

<xsl:template match="//applicationType"> 
    <li> 
     <p> 
      <a href=""> 
       Application type: 
       <xsl:value-of select="@id"/> 
      </a> 
     </p> 
     <ul> 
      <xsl:apply-templates select="./discipline"/> 
      <xsl:apply-templates select="./document"/> 
     </ul> 
    </li> 
</xsl:template> 

<xsl:template match="//discipline"> 
    <li> 
     <p> 
      <a href=""> 
       Discipline: 
       <xsl:value-of select="@id"/> 
      </a> 
     </p> 
    </li> 
</xsl:template> 


<xsl:template match="//document"> 
    <li> 
     <p> 
      <a href=""> 
       Document: 
       <xsl:value-of select="@id"/> 
      </a> 
     </p> 
    </li> 
</xsl:template> 

<xsl:template match="//description"> 
    <li> 
     <p> 
      <a href=""> 
       description: 
       <xsl:value-of select="@type"/> 
      </a> 
     </p> 
    </li> 
</xsl:template> 

所以沒有什麼特別之處,但你可以看到我要打開瀏覽器的XML,我可以做到這一點,但問題是編碼。我認爲UTF-8支持具有重音符的字符(請參閱médicin)。但是當我打開它時,它給了我一個錯誤。

任何想法我做錯了什麼,或者我應該選擇什麼編碼?

回答

0

好吧..我在記事本中創建了文件(因爲它只是一個拷貝過去),但文件本身沒有用UTF-8編碼。我用記事本++將它保存下來,並且沒問題。