Skip to main content
Inspiring
June 21, 2010
Question

Image not found to default image at Import Xml

  • June 21, 2010
  • 2 replies
  • 1425 views

Hi all,

I have a problem when importing an xml-file.

When an image cannot be found, indesign asks to select the file.

I want to disable this and place a default "no_image.jpg" instead of the image.

I don't want to sit and select the default image for every image in the xml that can't be found.

I'm using Adobe indesign CS4 with javascript.

Can someone point me in the right direction?

Thanks in advance.

Glen

This topic has been closed for replies.

2 replies

chagrin
Participant
January 15, 2015

Could it be done with a script, during import?

Bal_GlenAuthor
Inspiring
October 7, 2010

Did it in a separate xslt before loading it into Indesign.

Kasyan Servetsky
Legend
October 7, 2010

Could you post the code just in case?  Some of us may encounter this problem some day — it would be good to know the solution.

Kasyan

Bal_GlenAuthor
Inspiring
October 8, 2010

Kasyan, I agree with you!

So this is what i did in xslt.

First I added the following namespace to the stylesheet.

xmlns:file="http://www.jclark.com/xt/java/java.io.File"

This is not supported by indesign, you have to do this with a parser. I used saxon to parse the xml.

And this is the part for the existing file lookup.

If the file exists the image is placed as a href, if it doesn't exist i put the name of the image between brackets. In this case we can see in which image doesn't exist.

<xsl:choose>
     <xsl:when test="file:exists(file:new(string($imagefile)))">                                         
          <xsl:element name="Articleimage">
               <xsl:attribute name="href">file://../images/<xsl:value-of select="Properties/Property[@field = 9]"/></xsl:attribute>
          </xsl:element>
      </xsl:when>
      <xsl:otherwise>
          <xsl:text>[</xsl:text><xsl:value-of select="Properties/Property[@field = 9]"/><xsl:text>]</xsl:text>
      </xsl:otherwise>
</xsl:choose>

I hope it helps for others.

Good luck!

Glen