Layer Packages & PDF's

1511
12
05-15-2012 05:46 AM
adamcampbell
New Contributor II
Morning,

Ive been stabbing away at this problem now for a day and cant get it to work, any help would be much appreciated.

I have a whole bunch of laptops that arent connected to the network to access our servers. On the servers is a ton of pdf information that is linked within our corporate database.

My solution was to create a layer package in ArcGIS, and then open it within ArcExplorer on each of the machines. Within the layer package, I created HTML popups to link to each of the documents. I then took all the pdf files and copied them over to my test machine. (Both my machine and test machine have the test files in the same location on the C: Drive)

No matter what I try, ArcExplorer does not recognize the link in the HTML popup

///file:/C:/xzy/doc.pdf ------- didnt do a thing (I really thought that one would work)

Ive explored the forums and cant find any sort of hyperlink format that works. It seems it wants a UNC path to a server which im not quite sure how to write when referencing a local machine.

Any help would be most appreciated.

Thanks,

Maxac8
0 Kudos
12 Replies
MarkBockenhauer
Esri Regular Contributor
In ArcMap you can use an xsl style  to make this happen in the layer package.

Right click on the layer in ArcMap
Click Properties
On the HTML Popup tab
   Select the radio button for "As a formated page based on a XSL template"
   then Click Load and Load the default template.
[ATTACH=CONFIG]14382[/ATTACH]

If you scroll down in the style you will see a section where it specifies how to determine if an attribute is "hyperlinkable."  You will see things like this:

     <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>

The test for the field value is the important part.  Just add another one or change an existing test to set "c:" as linkable.
<xsl:when test="FieldValue[starts-with(., 'c:')]">
      <a target="_blank">
       <xsl:attribute name="href">
        <xsl:value-of select="FieldValue"/>
       </xsl:attribute>
       <xsl:value-of select="FieldValue"/>
      </a>
     </xsl:when>

Any attribute in your data that begins with c: will be recognized as hyperlinkable.

Mark
0 Kudos
adamcampbell
New Contributor II
That worked perfectly, thank you very much for your help. If anyone ever has a similar problem and isnt using ArcGIS 10.0 (meaning you cant load a default style) you can use the "popup" version location in your program files.

Cheers
0 Kudos
BenCoakley
New Contributor
I can't make this work (using ArcMap 10.1 and ArcGIS Explorer 2500).  I can create the XSLT template fine, and it works fine in ArcMap - when I use the identify tool on a feature with a path to a local PDF, that link is clickable, and clicking on it actually opens the PDF.  But when I export the layer package and open it in ArcGIS Explorer, the PDF link is not clickable.  There are http URLs in other fields that work fine.

Has anything changed since 10.0 that would make this work differently?  Any other possible approaches to the problem I could try?
0 Kudos
MarkBockenhauer
Esri Regular Contributor
It should still work.
Can you send a sample of the XSL that you are using and the path to the file?

thanks,
Mark
0 Kudos
BenCoakley
New Contributor
Sure.  Here's the XSL file:

<?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" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
 <xsl:variable name="ignoreFieldNames" select="'|OBJECTID|Shape|Shape_Length|Shape_Area|ATTACHMENTID|REL_OBJECTID|CONTENT_TYPE|ATT_NAME|DATA_SIZE|DATA|'"/>
 <xsl:variable name="headerRowColor" select="'#9CBCE2'"/>
 <xsl:variable name="alternateRowColor" select="'#D4E4F3'"/>
 <xsl:template match="/">
  <html>
   <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
   </head>
   <body style="margin:0px 0px 0px 0px;overflow:auto;background:#FFFFFF;">
    <table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-collapse:collapse;padding:3px 3px 3px 3px">
     <tr style="text-align:center;font-weight:bold;background:{$headerRowColor}">
      <td>
       <xsl:value-of select="FieldsDoc/Title" />
      </td>
     </tr>
     <xsl:apply-templates select="FieldsDoc/Attachments" />
     <tr>
      <td>
       <table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-spacing:0px; padding:3px 3px 3px 3px">
        <xsl:choose>
         <xsl:when test="FieldsDoc/Fields/Field/FieldName">
          <xsl:apply-templates select="FieldsDoc/Fields/Field/FieldName[not(contains($ignoreFieldNames, concat(concat('|', text()), '|')))]/.." />
         </xsl:when>
         <xsl:otherwise>
          <xsl:apply-templates select="FieldsDoc/Fields/Field" />
         </xsl:otherwise>
        </xsl:choose>
       </table>
      </td>
     </tr>
    </table>
   </body>
  </html>
 </xsl:template>

 <xsl:template match="Attachments">
  <xsl:variable name="imageCount" select="count(Attachment/ContentType[contains(., 'image')])"/>
  <xsl:variable name="attachmentCount" select="count(Attachment)"/>
  <tr bgcolor="{$headerRowColor}">
   <td>
    <table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-spacing:0px; padding:3px 3px 3px 3px">
     <xsl:variable name="imageSrc" select="Attachment/ContentType[contains(., 'image')]/../FilePath"/>
     <xsl:if test="$imageSrc">
      <tr align="center">
       <td>
        <a target="_blank" href="{$imageSrc}">
         <img src="{$imageSrc}" width="275px" border="0"/>
        </a>
       </td>
      </tr>
      <tr align="center">
       <td>
        <xsl:value-of select="Attachment/ContentType[contains(., 'image')]/../Name" />
       </td>
      </tr>
     </xsl:if>
     <xsl:if test="($attachmentCount &gt; $imageCount) or not($imageCount = 1)">
      <tr align="center">
       <td>
        <table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-spacing:0px; padding:3px 3px 3px 3px">
         <xsl:for-each select="Attachment[position() mod 2 = 1]">
          <tr align="left" bgcolor="white">
           <xsl:if test="(position() +1) mod 2">
            <xsl:attribute name="bgcolor">
             <xsl:value-of select="$alternateRowColor"/>
            </xsl:attribute>
           </xsl:if>
           <td>
            <a target="_blank">
             <xsl:attribute name="href">
              <xsl:value-of select="FilePath"/>
             </xsl:attribute>
             <xsl:value-of select="Name" />
            </a>
           </td>
           <td>
            <a target="_blank">
             <xsl:attribute name="href">
              <xsl:value-of select="following-sibling::Attachment/FilePath"/>
             </xsl:attribute>
             <xsl:value-of select="following-sibling::Attachment/Name" />
            </a>
           </td>
          </tr>
         </xsl:for-each>
        </table>
       </td>
      </tr>
     </xsl:if>
    </table>
   </td>
  </tr>
 </xsl:template>

 <xsl:template match="Field">
  <tr>
   <xsl:if test="(position() +1) mod 2">
    <xsl:attribute name="bgcolor">
     <xsl:value-of select="$alternateRowColor"/>
    </xsl:attribute>
   </xsl:if>
   <xsl:if test="FieldName">
    <td>
     <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(., 's:')]">
<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="FieldValue[starts-with(., '&lt;img ')]">
      <xsl:value-of select="FieldValue" disable-output-escaping="yes" />
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="FieldValue"/>
     </xsl:otherwise>
    </xsl:choose>
   </td>
  </tr>
 </xsl:template>
</xsl:stylesheet>


Sample file path:
S:\BP User Shared Folders\Dale\~New System for Laptop Use\Curb Cards\East Shore Dr.  #1731.pdf


Here's what it looks like in ArcMap:

[ATTACH=CONFIG]26324[/ATTACH]

And here's what it looks like in ArcGIS Explorer:

[ATTACH=CONFIG]26325[/ATTACH]

That file path is legacy in nature, and it would be easy to make a new one without the blanks and "~" character.  Getting rid of the "#" character would be harder, but not impossible.

Thanks,
--Ben
0 Kudos
MarkBockenhauer
Esri Regular Contributor
Ben,

It is case sensitive on the match for the drive letter in the XSL.
In the XSL you are using a lower case 's:' and the attribute is 'S:'

Change the case in the XSL and it should work.

Mark
0 Kudos
BenCoakley
New Contributor
That did the trick, thanks!  I was fooled by the fact that it was working in ArcMap.

--Ben
0 Kudos
MichaelGlassman2
New Contributor III
Mark,
You seem to have a pretty good handle on the HTML popups in ArcMap. I am having difficulty changing the file path of my html popup based on the unique ID of each polygon I have. I need a way to use XSL to pull the ID number from the polygon that is clicked and then to output the ID number in a way that I can plug it into the file path I am using.
I am using iframes and the source (src) value for each polygon needs to slightly different. For example: "C:\Users\Me\Documents\" +UniqueID + ".html"
I cannot seem to get the code quite right. Any guidance you could give me would be appreciated.
0 Kudos
MarkBockenhauer
Esri Regular Contributor
If you load the default style and use the following between the bold tags   <xsl:choose> and <xsl:when test="FieldValue[starts-with(., 'www.')]">  It will use the ID value as part of the URL string and the attribute in the "default popup style" will be link-able.

   <xsl:choose>
<xsl:when test="FieldName[starts-with(., 'FID')]">
<b>
<a target="_blank">
<xsl:attribute name="href">
file:///C:/Users/me/documents/<xsl:value-of select="FieldValue"/>.html
</xsl:attribute>
<xsl:value-of select="FieldValue"/>
</a>
</b>
</xsl:when>

     <xsl:when test="FieldValue[starts-with(., 'www.')]">
0 Kudos