相关疑难解决方法(0)

XSLT模板和递归

我是XSLT的新手,在尝试格式化具有递归节点的XML文档时遇到了一些问题.

我的XML代码:

希望我的XML显示:

  • 所有<item>都嵌套着<items>
  • 项可以只有属性或子节点
  • <item>嵌套节点的级别可能非常深
<?xml version="1.0" encoding="utf-8" ?> 
- <items>
  <item groupID="1" name="Home" url="//" /> 
- <item groupID="2" name="Guides" url="/Guides/">
- <items>
- <item groupID="26" name="Online-Poker-Guide" url="/Guides/Online-Poker-Guide/">
- <items>
- <item>
  <id>107</id> 
- <title>
- <![CDATA[ Poker Betting - Online Poker Betting Structures
  ]]> 
  </title>
- <url>
- <![CDATA[ /Guides/Online-Poker-Guide/online-poker-betting-structures
  ]]> 
  </url>
  </item>
- <item>
  <id>114</id> 
- <title>
- <![CDATA[ Beginners&#39; Poker - Poker Hand Ranking
  ]]> 
  </title>
- <url>
- <![CDATA[ /Guides/Online-Poker-Guide/online-poker-hand-ranking
  ]]> …
Run Code Online (Sandbox Code Playgroud)

xslt

16
推荐指数
2
解决办法
3万
查看次数

XSLT for-each循环,基于变量的过滤器

我有以下XSLT

<xsl:param name="productsId" select="/macro/productsId" />
<xsl:param name="type" select="/macro/type" /> <!-- value1, value2, value3 -->

<xsl:template match="/">
    <xsl:if test="$productsId > 0">
        <xsl:variable name="products" select="umbraco.library:GetXmlNodeById($productsId)" />
        <div id="carousel-wrap">
          <ul id="carousel">
          <xsl:for-each select="$products/Product [select only Product with attribute value1, value2 or value3 based on /macro/type]">
            <li id="p-{@id}">
              <xsl:variable name="title">
                <xsl:choose>
                  <xsl:when test="string-length(productHeading) > 0">
                    <xsl:value-of select="productHeading" />
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="@nodeName" />
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:variable>
              <a href="{umbraco.library:NiceUrl(@id)}">
                <!-- Image -->
                <xsl:if test="productImage > 0">
                  <xsl:variable name="productImage" select="umbraco.library:GetMedia(productImage, 0)" />
                  <img src="/ImageGen.ashx?image={$productImage/umbracoFile}&amp;height=131" />
                </xsl:if> …
Run Code Online (Sandbox Code Playgroud)

xml xslt xpath umbraco

0
推荐指数
1
解决办法
8720
查看次数

标签 统计

xslt ×2

umbraco ×1

xml ×1

xpath ×1