[GIS] ArcGIS 10 HTML popup code for images

arcgis-10.0arcgis-desktopxsl

I'm diving into using the HTML popup in ArcGIS 10 and I'm trying to figure out how I can get an image to appear. I have a point file that contains the field "Coll" that has a image name with no extension ("100015"). All the images are stored in a directory ("T:\SEFIS2010_GVdata\SEFIS Video"). I can make an image appear in the popup using this XSL code

<xsl:when test="FieldName[starts-with(., 'Coll')]">
    <img src="T:\SEFIS2010_GVdata\SEFIS Video\100015.jpg"/>
</xsl:when>

but what is the syntax to append the directory, the FieldName, and the ".jpg" extension?

Best Answer

This was the code I ended up using inside one of the XSL samples.

<xsl:when test="FieldName[starts-with(., 'Coll')]">
    <xsl:variable name="imageName" select="FieldValue"/>
    <img src="T:\SEFIS2010_GVdata\SEFIS Video\{$imageName}.jpg" width="192" height="108"/>
</xsl:when>

Edit This is the full XSL code where this is used

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="/">
        <html>
            <head>
                <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
            </head>
            <body>
                <xsl:variable name="nameCol" select="FieldsDoc/Fields/Field/FieldName"/>
                    <table border="1" width="300" cellpadding="5" cellspacing="0">
                        <tr bgcolor="#9cbce2">
                            <xsl:if test="string-length($nameCol) != 0">
                                <th width="50%" align="left">Field Name</th>
                            </xsl:if>
                            <th width="50%" align="left">Field Value</th>
                        </tr>
                        <xsl:variable name="index" select="1"/>
                        <xsl:for-each select="FieldsDoc/Fields/Field">
                            <tr>
                                <xsl:if test="string-length($nameCol) != 0">
                                    <td bgcolor="#D4e4f3">
                                    <xsl:value-of select="FieldName"/>
                                    </td>
                                </xsl:if>
                                <td>
                                    <xsl:choose>
                                        <xsl:when test="FieldValue[starts-with(., 'www.')]">
                                            <a target="_blank"><xsl:attribute name="href">http://<xsl:value-of select="FieldValue"/>
                                            </xsl:attribute><xsl:value-of select="FieldValue"/>
                                            </a>
                                        </xsl:when>
                                        <xsl:when test="FieldValue[starts-with(., 'http:')]">
                                            <a target="_blank"><xsl:attribute name="href"><xsl:value-of select="FieldValue"/>
                                            </xsl:attribute><xsl:value-of select="FieldValue"/>
                                            </a>  
                                        </xsl:when>
                                        <xsl:when test="FieldValue[starts-with(., 'https:')]">
                                            <a target="_blank"><xsl:attribute name="href"><xsl:value-of select="FieldValue"/>
                                            </xsl:attribute><xsl:value-of select="FieldValue"/>
                                            </a>  
                                        </xsl:when>
                                        <xsl:when test="FieldValue[starts-with(., '\\')]">
                                            <a target="_blank"><xsl:attribute name="href"><xsl:value-of select="FieldValue"/>
                                            </xsl:attribute><xsl:value-of select="FieldValue"/>
                                            </a>  
                                        </xsl:when>
                                        <xsl:when test="FieldName[starts-with(., 'Coll')]">
                                            <xsl:variable name="imageName" select="FieldValue"/>
                                            <img src="T:\SEFIS2010_GVdata\SEFIS Video\{$imageName}.jpg" width="192" height="108"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="FieldValue"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </td>
                            </tr>
                        </xsl:for-each>
                    </table>
                <br/>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
Related Question