XSLt - Select image contains in filename 'img_'

516 Views Asked by At

Hello i have a question about XSL . I try to select all images in a directory with starts with filename 'img_'. at the moment my code is this:

     <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>

what i tried is this

 <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>

Can anyone help? I hope its the right form to ask here .

Greetings

1

There are 1 best solutions below

1
On

It seems, you just want to filter those images which are present, without breaking any link. So, you should use java extension to make it happen because XSLT only is not sufficient. Use something like:

<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>

I may get further information from http://www.altova.com/list/xsl-list/200906/msg1000300010.html