This tutorial discusses how you can create hyper-linked properties on Bentley Map features. This will allow you to link to any document that can be opened in a browser and includes images, documents, spreadsheets, PDFs and more.
Introduction
When Analyze Element is used, the results are displayed in an HTML dialog that’s is generated from Default.xslt. As noted in the following graphic, the value of the Link property is valid, but is not hyper-linked to the associated image.
The remainder of this tutorial will walk you through the steps to turn a property called Link into a clickable hyperlink in the Analyze Results dialog.
Default.xslt
The default stylesheet used to generate the Analyze Results dialog will be customized to accommodate hyperlinks.
This file is found in the .../XML/XSLT folder in the installation directory (e.g. C:\Program Files\Bentley\Map CONNECT Edition\MapAdvanced\xml\xslt\) and is copied to a shared location defined by the configuration variable MS_GEOXFM_XSL_DIR.
For simplicity, copy the delivered XSLT folder to a your organization folder and add the following line to the CFG file standards.cfg (in your organization folder):
MS_GEOXFM_XSL_DIR = $(_USTN_ORGANIZATION)xslt\
.
The Default.xslt can be customized to change the presentation of the Analyze Results dialog. This will require knowledge of CSS which is a style sheet language used to describe the presentation of HTML elements.
To make feature property called Link a hyperlink, copy the following lines of code and paste it above the last line in copied default.xslt:
<!-- Template to make feature property called LINK a hyperlink -->
<xsl:template match="*">
<xsl:param name="tag"/>
<xsl:element name="tr">
<xsl:attribute name="{$tag}">yes</xsl:attribute>
<xsl:attribute name="class">r<xsl:value-of select="position() mod 2"/></xsl:attribute>
<xsl:attribute name="style">display:block;</xsl:attribute>
<xsl:choose>
<xsl:when test="name()='Link'">
<td><xsl:value-of select="name()"/></td>
<td><a target="_blank"><xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute><xsl:value-of select="."/></a></td></xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="name()"/></td>
<td><xsl:value-of select="."/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
The results of this additional code is seen immediately in the Results dialog.
While this is valid link, the physical location of the JPG is not included in the property value. A quick and easy solution is to load the features into the Data Browser and use the Find and Replace function to append the shared folder to the value.
Once saved, the link opens the correct document in the browser.
An alternate solution to using a property value called Link, is to convert any property that contains http:// in the value to a hyperlink. In this case, the code to add to Default.xslt is as follows:
<!-- Template to make feature property with http in value a hyperlink -->
<xsl:template match="*">
<xsl:param name="tag"/>
<xsl:variable name="PropName">
<xsl:choose>
<xsl:when test="@displayName">
<xsl:value-of select="@displayName"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="PropValue">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:element name="tr">
<xsl:attribute name="{$tag}">yes</xsl:attribute>
<xsl:attribute name="class">r<xsl:value-of select="position() mod 2"/></xsl:attribute>
<xsl:attribute name="style">display:block;</xsl:attribute>
<xsl:choose>
<xsl:when test="contains ($PropValue, 'http')">
<td><xsl:value-of select="name()"/></td>
<td><a target="_blank"><xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute><xsl:value-of select="."/></a></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="$PropName"/></td>
<td><xsl:value-of select="."/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
Conclusion:
In conclusion, it’s a simple process to add clickable properties to your features. While this article illustrated dealing with XFM attributes, the same concept applies to features and attributes stored in Oracle Spatial. Likewise, creating hyperlinks is not restricted to JPG images as shown in this tutorial. If the document can be viewed in a browser, these modifications to default.xslt are applicable.