XSL html5嵌入视频无法正常工作

时间:2013-08-21 12:01:17

标签: xml html5 xslt html5-video

有人能帮帮我吗?我是xsl / xml进程的新手,我不确定我做错了什么... 我有这个代码生成一个带有视频的html:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" extension-element-prefixes="xalan" exclude-result-prefixes="xalan">

    <xsl:variable name="StyleSheet"><xsl:text>html</xsl:text></xsl:variable>
    <xsl:variable name="product" select="//...//someting..."/>
    <xsl:template match="/">
    <html>
     <head>
      <title><xsl:value-of select="$product"/></title>
       <BASE HREF="https://....com"/>
       <LINK REL="stylesheet" TYPE="text/css" HREF="/style/rbc_new.css">
       </LINK>
     </head>

     <body bgcolor="white">
       <DIV>
        <table width="670" border="0" bgcolor="#ffffff">
         <tr>
          <td>
    <!--
           This type of report is not available in HTML format. Please check the PDF version.
    -->
    VIDEO UPLOADED *:
          </td>
         </tr>

                                        <tr>
                                            <td valign="top" class="rbc_color1_font_10">

                                                <xsl:variable name="video" select="concat(some file)"/>
                                                <xsl:variable name="video2" select="other file">

 <!--  THIS IS FOR Html4 & older versions and this one works -->

    <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="480" height="360" codebase="http://www.microsoft.com/Windows/MediaPlayer/">
    <param name="Filename" value="{$video}"/>
    <param name="AutoStart" value="false"/>
    <param name="ShowControls" value="true"/>
    <param name="BufferingTime" value="2"/>
    <param name="ShowStatusBar" value="true"/>
    <param name="AutoSize" value="true"/>
    <param name="InvokeURLs" value="false"/>
    <embed src="{$video}" type="application/x-mplayer2" autostart="0" enabled="1" showstatusbar="1" showdisplay="1" showcontrols="1" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0" width="480" height="360"></embed>
    </object>  
    <!--this is for html5 and this one does not work -->
    <video width="320" height="240" controls>
       <source src="{$video}" type="video/mp4">
        Your browser does not support the video tag.
     </video> 
        </td>

我做错了什么?我应该像这样使用XSL版本,使用html5(它有任何影响吗?)并且它仍然会运行html4类型吗?:

<xsl:output
     method="xml"
     doctype-system="about:legacy-compat"
     encoding="UTF-8"
     indent="yes" />

先谢谢你。

1 个答案:

答案 0 :(得分:0)

XSLT样式表必须是格式良好的XML,而不是:

<video width="320" height="240" controls>

处理“无价值”HTML属性的常用方法是设置controls="controls"。但是,由于HTML4中未定义此类,因此XSLT序列化程序可能无法识别它,并且将输出controls="controls"而不是controls。希望浏览器接受这个等价物。