XSLT:在 html 属性内插入参数值
如何在以下代码中插入 youtubeId 参数:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:YouTube="urn:YouTube"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library YouTube">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="videoId"/>
<xsl:template match="/">
<a href="{$videoId}">{$videoId}</a>
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/{$videoId}&hl=en"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/{$videoId}&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed>
</object>$videoId {$videoId} {$videoId}
<xsl:value-of select="/macro/videoId" />
</xsl:template>
</xsl:stylesheet>
实际上输出 videoId,但所有其他情况都不会。
我正在 Umbraco CMS 中创建一个宏。该参数已正确传递到 XSLT(因为实际上输出了其值)。 如何将此值插入到 src 属性中?
How can I insert the youtubeId parameter in the following code :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:YouTube="urn:YouTube"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library YouTube">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="videoId"/>
<xsl:template match="/">
<a href="{$videoId}">{$videoId}</a>
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/{$videoId}&hl=en"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/{$videoId}&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed>
</object>$videoId {$videoId} {$videoId}
<xsl:value-of select="/macro/videoId" />
</xsl:template>
</xsl:stylesheet>
<xsl:value-of select="/macro/videoId" />
actually outputs the videoId but all other occurences do not.
I am creating a macro in Umbraco CMS. The parameter is correctly passed into the XSLT (because actually outputs its value). How can I insert this value into the src-attribute?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在此处使用
:每当您在属性内使用 AVT (
{$videoId}
) 时该值必须与任何select
属性的例外情况一起使用。在最后一种情况下,您可以使用:
当所有这些都反映在您的转换中时,它在所有情况下都有效:
You must use
<xsl:value-of select="$videoId"/>
here:Whenever You are using an AVT (
{$videoId}
) inside an attribute value this must work with the exception of anyselect
attribute.In the last case you can use:
When all of these are reflected in your transformation, it works in all cases:
您可能只想获得一个也能帮助解决此问题的软件包。
http://our.umbraco.org 很棒,并且一直在添加软件包。
快速搜索会显示一些选项:
http://our.umbraco.org/projects/标签/youtube#projectList
You may want to just get a package that helps with this as well.
http://our.umbraco.org is awesome and packages are being added all the time.
A quick search reveals a few options:
http://our.umbraco.org/projects/tag/youtube#projectList