XSLT 中的 JavaScript 键值生成



我正在尝试通过XSL生成这样的输出:

<script>
    var quickCatalogueCategories = {
        for each values do {
            '{title}': 'http://www.news.com/{search key}',
        }
    };
</script>

问题是我正在获得输出,但是在每个标题之后,我应该获得url,而不是在所有标题之后,我都获得了URL。即使在 URL 之后,我也应该只有一个键,但连续显示所有四个键。

你能告诉我如何解决它吗?

尝试实现这样的输出:

<script>
    var quickCatalogueCategories = {
        '{What's New}':'http: //www.news.com/{news}',
        '{Featured}':'http: //www.news.com/{featured}',
        '{Most Delivered}':'http: //www.news.com/{most-delivered}',
        '{Online Only}':'http: //www.news.com/{online-only}',
    }
</script> 

试试这段代码

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- Skin: Default XSL -->
    <!--xsl:include href="http://www.interwoven.com/livesite/xsl/HTMLTemplates.xsl"/-->
    <!--xsl:include href="http://www.interwoven.com/livesite/xsl/StringTemplates.xsl"/-->
    <xsl:template match="/">
        <!-- TODO put section -->
        <script>
            var quickCatalogueCategories={
            <xsl:for-each select="//Datum[@Name='Catalog']//CatalogContainer">
                <!-- you are already in the node, just select the value of the children -->
                <xsl:text>&#x9;'{</xsl:text><xsl:value-of select="CatalogKey"/><xsl:text>'}</xsl:text>:'http://www.news.com/{'<xsl:value-of select="CatalogView"/>}',}
            </xsl:for-each>
            }            
        </script>
    </xsl:template>
</xsl:stylesheet>

最新更新