0

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

dA_uNknOwN
  • 931
  • 2
  • 14
  • 23
  • "Select all images in a directory", XSLT is for processing XML documents, not realy for directories. What did you mean here? Do you have an example input and output XML? –  Dec 19 '13 at 05:34
  • Its the Template Language of SObiPro Directory component of joomla. I wanted to try to filter the selection of all uploaded images in a directory with the fileprefix 'img_' in the name.And only files whoch are exist should display in a slider. what you mean with sample input output ? – dA_uNknOwN Dec 19 '13 at 05:44
  • At the moment shows th slider images that have a form field in sboipro ti upload a image . Ich have 4 possibilities to f(formefield) to upload a image. 2 of them i had really uploaded. 2 of them are not exist. but the slider shows 4 images insteads only 2 . 2 of them are broken links image. – dA_uNknOwN Dec 19 '13 at 05:50
  • If SobiPro uses XSLT, then it must have an XML input document. For example, there must be elements named `entry`, `fields` and `data`, the latter with an attribute called "image". Can you find this? – Mathias Müller Dec 19 '13 at 07:51
  • I guess you selector should be: `entry/fields/*[@type = 'image'][contains( ., 'img_' )]` – Samuel Dec 19 '13 at 08:27

1 Answers1

0

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

Navin Rawat
  • 3,208
  • 1
  • 19
  • 31