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"> <entry> <xsl:copy-of select="."/> <xsl:element name="entryImg"> <xsl:attribute name="href"> <xsl:value-of select="concat('file:///Users/MacBook/Desktop/', text(), '.jpeg')"/> </xsl:attribute> </xsl:element> </entry>
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.
In the structure pane the href text looks accurate and the file does exist with the special characters in the location shown.
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.
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.