如何在以下代码中插入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>
Run Code Online (Sandbox Code Playgroud)
<xsl:value-of select="/macro/videoId" /> 实际输出videoId但所有其他事件都没有.
我正在Umbraco CMS中创建一个宏.该参数正确传递到XSLT(因为实际输出其值).如何将此值插入src-attribute?
Dim*_*hev 21
Run Code Online (Sandbox Code Playgroud)<a href="{$videoId}">{$videoId}</a>
你必须<xsl:value-of select="$videoId"/>在这里使用:
<a href="{$videoId}"><xsl:value-of select="$videoId"/></a>
Run Code Online (Sandbox Code Playgroud)
无论何时{$videoId}在属性值中使用AVT(),都必须使用任何select属性除外.
在最后一种情况下,您可以使用:
<xsl:value-of select="/macro/*[name()=$videoId]" />
Run Code Online (Sandbox Code Playgroud)
当所有这些都反映在您的转换中时,它适用于所有情况:
<!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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22051 次 |
| 最近记录: |