XSLT:在 html 属性内插入参数值

发布于 2024-08-31 08:58:37 字数 1354 浏览 2 评论 0原文

如何在以下代码中插入 youtubeId 参数:

<?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: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}&amp;hl=en"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/{$videoId}&amp;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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦醒灬来后我 2024-09-07 08:58:37
 {$videoId}

您必须在此处使用

<a href="{$videoId}"><xsl:value-of select="$videoId"/></a>

每当您在属性内使用 AVT ({$videoId}) 时该值必须与任何 select 属性的例外情况一起使用。

在最后一种情况下,您可以使用:

<xsl:value-of select="/macro/*[name()=$videoId]" />

当所有这些都反映在您的转换中时,它在所有情况下都有效

<!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" select="'XXX'"/>
<xsl:template match="/">
 <a href="{$videoId}"><xsl:value-of select="$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><xsl:value-of select="concat($videoId, ' ', $videoId, ' ', $videoId)"/>
 <xsl:value-of select="/macro/*[name()=$videoId]" />
</xsl:template>

</xsl:stylesheet>
 <a href="{$videoId}">{$videoId}</a>

You must use <xsl:value-of select="$videoId"/> here:

<a href="{$videoId}"><xsl:value-of select="$videoId"/></a>

Whenever You are using an AVT ({$videoId}) inside an attribute value this must work with the exception of any select attribute.

In the last case you can use:

<xsl:value-of select="/macro/*[name()=$videoId]" />

When all of these are reflected in your transformation, it works in all cases:

<!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" select="'XXX'"/>
<xsl:template match="/">
 <a href="{$videoId}"><xsl:value-of select="$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><xsl:value-of select="concat($videoId, ' ', $videoId, ' ', $videoId)"/>
 <xsl:value-of select="/macro/*[name()=$videoId]" />
</xsl:template>

</xsl:stylesheet>
梦在夏天 2024-09-07 08:58:37

您可能只想获得一个也能帮助解决此问题的软件包。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文