0

您好,我有一个关于 XSL 的问题。我尝试选择以文件名“img_”开头的目录中的所有图像。目前我的代码是这样的:

     <div class="flex-container">
       <div class="flexslider">
          <ul class="slides">
             <xsl:for-each select="entry/fields/*[@type = 'image']">

                   <img>
                     <xsl:attribute name="src">
                        <xsl:value-of select="data/@image"/>
                     </xsl:attribute>
                   </img>
                </li>
             </xsl:for-each>
          </ul>
       </div>
    </div>

我试过的是这个

 <div class="flex-container">
<div class="flexslider">
   <ul class="slides">
     <xsl:for-each select="entry/fields/*[@type = 'image' contains( ., 'img_' )]">
    <li>
     <img>
       <xsl:attribute name="src">
          <xsl:value-of select="data/@image"/>
         </xsl:attribute>
       </img>
     </li>
       </xsl:for-each>
     </ul>
  </div>
</div>

任何人都可以帮忙吗?我希望它是正确的形式在这里问。

问候

4

1 回答 1

0

看来,您只想过滤那些存在的图像,而不破坏任何链接。因此,您应该使用 java 扩展来实现它,因为仅 XSLT 是不够的。使用类似的东西:

<xsl:template match=file">
<xsl:variable name="file" select="resolve-uri(@name, base-uri(.))"
as="xs:string"/>
<xsl:if test="not(file:exists(file:new($file)))">
          <xsl:value-of select="@name"/><xsl:message>file missing /
incorrect name</xsl:message>
</xsl:if>
</xsl:template>

我可以从http://www.altova.com/list/xsl-list/200906/msg1000300010.html获得更多信息

于 2013-12-19T10:13:17.277 回答