2012-11-25 54 views
0

我遇到了一些巨大的問題,這些問題是如何從導入兩個XML並組合數據的XSL輸出乾淨的XML。在XSL中輸出來自組合XML的XML

我試圖找到更多關於<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>的信息,我認爲這是我的解決方案,但我沒有得到如何將它全部放入一個實體XML文件。當我從服務器腳本調用它時,它看起來不錯,但它有一些HTML標籤和其他我不想要的東西,我想這是因爲它仍然是XSL。

這是我的代碼:

<?xml version="1.0" encoding="UTF-8" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> 

    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 

    <xsl:param name="source-producenter" select="'Producers.xml'"/> 
    <xsl:param name="source-positioner" select="'positioner.xml'"/> 
    <xsl:variable name="producenter" select="document($source-producenter)"/> 
    <xsl:variable name="Workbook" select="document($source-positioner)"/> 

    <xsl:template match="/"> 
    <Producers> 
     <xsl:for-each select="$producenter//producer"> 
     <producer> 

      <id> 
      <xsl:value-of select="id"/> 
      </id> 

      <name> 
      <xsl:value-of select="name"/> 
      </name> 

      <address><xsl:value-of select="address"/></address> 

      <postalcode> 
      <xsl:value-of select="postalcode"/> 
      </postalcode> 

      <city> 
      <xsl:value-of select="city"/> 
      </city> 

      <site> 
      <xsl:value-of select="site"/> 
      </site> 

      <pic> 
      <xsl:value-of select="img"/> 
      </pic> 
      <!--Store id from producent into storeId xsl variable --> 
      <xsl:variable name="storedId" select="id"/> 
      <!--Using filter to get correct Cells for latitude and longitude and checks if text() in number is equal to our storedId variable--> 
      <xsl:variable name="selected" 
      select="$Workbook//ss:Cell[@ss:Index='2']/ss:Data[@ss:Type='Number' and text() = $storedId]"/> 
      <!--Gets the filtered values--> 
      <latitude> 
      <xsl:value-of select="$selected//../../ss:Cell[2]/ss:Data"/> 
      </latitude> 
      <longitude> 
      <xsl:value-of select="$selected//../../ss:Cell[3]/ss:Data"/> 
      </longitude> 
     </producer> 
     </xsl:for-each> 
    </Producers> 
    </xsl:template> 
</xsl:stylesheet> 

我所有並欣賞答案,預先感謝您!

+0

請編輯問題並提供:1.準確的兩個XML文檔(請儘可能小)。 2.將這些轉換應用於這兩個XML分析時所得到的確切結果。 3.你得到的結果有什麼問題。 4.準確的結果(對於這兩個指定的XML文檔)你想得到。 –

回答

0

如果您要轉換由MSExcel生成的XML(線索是某些元素的ss:前綴),請注意Excel使用@ss:Index屬性的方式。連續的單元省略了該屬性,但爲了跳過空白的介入單元,後續的單元具有@ss:索引。重構部分填充的單元矩陣的幾何是相當痛苦的。我不明白這是否與你的挑戰有關。