开发者

embed video player using xslt

in my xml data there is a node containing the embed script for a video player

how do i put this into my xsl file

xml part with ''video-player'':

<post>
<video-player><span id="video_player_6108595387">[<a href="http://www.adobe.com/shockwave/downlo开发者_运维问答ad/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Flash 10</a> is required to watch video.]</span><script type="text/javascript">renderVideo("video_player_6108595387",'http://mydomain.tumblr.com/video_file/6108595387/tumblr_lm64ngkwu81qjb4vj',400,225,'poster=http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lm64ngkwu81qjb4vj_frame1.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lm64ngkwu81qjb4vj_frame2.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lm64ngkwu81qjb4vj_frame3.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lm64ngkwu81qjb4vj_frame4.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lm64ngkwu81qjb4vj_frame5.jpg')</script></video-player>

my xsl failed attempt to use the ''video-player'':

<div><xsl:value-of select="video-player" disable-output-escaping="yes"/></div>

using the node with the ''audio-player'' works fine.

xml part with audio player:

<audio-player><embed type="application/x-shockwave-flash" src="http://assets.tumblr.com/swf/audio_player.swf?audio_file=http://www.tumblr.com/audio_file/5046352702/tumblr_lkffpeQVub1qjb4vj&color=FFFFFF" height="27" width="207" quality="best"></embed></audio-player>

xsl using ''audio-player''

<div><xsl:value-of select="audio-player" disable-output-escaping="yes"/></div>


You are apparently trying to copy the <video-player> element, with its contents (<span> etc.), to the output HTML. To do this, use <xsl:copy-of> instead of <xsl:value-of>. The latter evaluates its argument as a string, taking the concatenation of all descendant text nodes. The former copies the element/child structure of its argument.

So you need:

<div><xsl:copy-of select="video-player" /></div>

I would suggest not using disable-output-escaping unless you know what you're doing. It usually is a sign that someone doesn't understand the difference between markup and document structure, so they're using a hammer to drive in a screw.

Your sample XSL using <xsl:value-of> to copy <audio-player> should output only the text content of the <audio-player> element, i.e. nothing at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜