1 Reply Latest reply on Jun 17, 2013 12:06 PM by absqua

    [JS][CS5/6] XML image href filename character encoding?


      I've got an XML file that I'm importing with an XSLT transformation and one of the items transformed is to create an image element using the value in the name element like so


        <xsl:template match="name">
        <xsl:copy-of select="."/>
        <xsl:element name="entryImg">
        <xsl:attribute name="href">
        <xsl:value-of select="concat('file:///Users/MacBook/Desktop/', text(), '.jpeg')"/>


      This works great for name elements with text values like Androgen Receptor but for name elements with text values like d'Annexin where characters like ' are used INDD cannot find the image when I place the XML on the page.


      Screen Shot 2013-06-15 at 5.52.16 PM.png


      In the structure pane the href text looks accurate and the file does exist with the special characters in the location shown.

      Screen Shot 2013-06-15 at 5.46.49 PM.png


      Is this an encoding issue? Is there something I can do in XSLT, INDD, or JS so that even images with filenames that use special characters place correctly? I'm working on both mac and PC (not sure if encoding would be unique to the platform).


      Any insight is greatly appreciated.



        • 1. Re: [JS][CS5/6] XML image href filename character encoding?
          absqua Level 4

          You probably want to pass the filename through a url encoder, such as the global JS encodeURI() function. A normal apostrophe (U0027) shouldn't need to be encoded, but a right single quote (U2019) will. I don't think XSLT 1.0, which InDesign uses, has a built-in function to do it, but I bet someone out there has built a named template for XSLT 1.0 that you could pass the value through.