2012-02-27 65 views
1

即時爲網站做一個快速更新,但xslt不是我的東西,它似乎與代碼我看代碼生成的代碼失敗 - 已包括兩個以下:xml xsl template with html/js內部失敗

當前代碼:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]> 
<xsl:stylesheet 
    version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:msxml="urn:schemas-microsoft-com:xslt" 
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" 
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib "> 


<xsl:output method="xml" omit-xml-declaration="yes"/> 

<xsl:param name="currentPage"/> 

<xsl:template match="/"> 

<xsl:if test="string-length($currentPage/mp4videoLinkId) > 0"> 
    <xsl:variable name="videoID" select="$currentPage/mp4videoLinkId" /> 
    <xsl:variable name="srtID" select="$currentPage/mp4videoSRTId" /> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
    <script src="flowplayer-3.2.6.min.js"></script> 
    <script src="flowplayer.ipad-3.2.2.min.js"></script> 

    <!-- player container--> 
    <a href="{$videoID}" style="display:block;width:473px;height:310px;" id="ipad"></a> 

    <script type="text/javascript"> 
    $f("ipad", "flowplayer-3.2.7.swf",{ 
    clip: { 
     autoPlay: false, 
     url: '{$videoID}', 

     // this is the Timed Text file with captions info 
     captionUrl: '{$srtID}' 
    }, 
    plugins: { 

     captions: { 
     url: 'flowplayer.captions-3.2.3.swf', 

     // pointer to a content plugin (see below) 
     captionTarget: 'content' 
     }, 

     // configure a content plugin to look good for our purpose 
     content: { 
     url:'flowplayer.content-3.2.0.swf', 
     bottom: 25, 
     width: '80%', 
     height:40, 
     backgroundColor: 'transparent', 
     backgroundGradient: 'none', 
     borderRadius: 4, 
     border: 0, 
     textDecoration: 'outline', 
     style: { 
      body: { 
      fontSize: 14, 
      fontFamily: 'Arial', 
      textAlign: 'center', 
      color: '#ffffff' 
      } 
     } 
     } 
    } 
    }).ipad(); 
    </script> 
</xsl:if> 

</xsl:template> 

</xsl:stylesheet> 

產生源: (你可以看到它打破了代碼,而不是關閉,然後顯示{$標籤})我失去了什麼?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" /><script src="flowplayer-3.2.6.min.js" /><script src="flowplayer.ipad-3.2.2.min.js" /><a href="mp4/assist-mi-car-parking.mp4" style="display:block;width:473px;height:310px;" id="ipad" /><script type="text/javascript"> 
    $f("ipad", "flowplayer-3.2.7.swf",{ 
    clip: { 
     autoPlay: false, 
     url: '{$videoID}', 

     // this is the Timed Text file with captions info 
     captionUrl: '{$srtID}' 
    }, 
    plugins: { 

     captions: { 
     url: 'flowplayer.captions-3.2.3.swf', 

     // pointer to a content plugin (see below) 
     captionTarget: 'content' 
     }, 

     // configure a content plugin to look good for our purpose 
     content: { 
     url:'flowplayer.content-3.2.0.swf', 
     bottom: 25, 
     width: '80%', 
     height:40, 
     backgroundColor: 'transparent', 
     backgroundGradient: 'none', 
     borderRadius: 4, 
     border: 0, 
     textDecoration: 'outline', 
     style: { 
      body: { 
      fontSize: 14, 
      fontFamily: 'Arial', 
      textAlign: 'center', 
      color: '#ffffff' 
      } 
     } 
     } 
    } 
    }).ipad(); 
    </script> 

回答

0

的AVT (Attribute Value Template) convention in XSLT僅被定義爲屬性值 - 因爲該功能的名稱明確表示。

作爲文本節點的一部分的大括號中的表達式未評估。需要使用<xsl:value-of>指令。

替換

url: '{$videoID}', 

url: '<xsl:value-of select="$videoID"/>', 

類似地替換

captionUrl: '{$srtID}' 

有:

captionUrl: '<xsl:value-of select="$srtID"/>' 
+0

很大,那現在顯示的數據!然而,它仍然只包括jquery,沒有看到螢火蟲之後,在源代碼中,它不關閉,我認爲這可以防止休息顯示..... – 2012-02-27 17:10:27

+0

@JamesBrandon:您的XSLT轉換可能有其他錯誤 - 你需要展示一個完整的(儘可能小的以便重現問題)XML文檔,一個完整的(儘可能小但重現問題)XSLT轉換,你得到的完整結果,你想要的完整結果*獲得以及該轉換必須實施的任何規則。至於這個問題,已經完全回答了。請爲其他問題提出一個新問題,並提供所有必要的信息來重現這個新問題。 – 2012-02-27 17:16:06