1

I want to convert a feature class with customized attributes to kmz and want the kmz-file to show 2 levels of subfolders, which I can select/deselect in GE.

Using ArcGIS 10.3 I convert a feature class to kml with Conversion Tools' "Layer To KML". I customize the attributes in only making some fields visible and showing their alias. I prepared a customized HTML Popup "as a formatted page based on an XSL template":

<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"/>
            <tr>
                <td>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#00248F">
                        <tr>
                            <!--<td width="99%" align="right" valign="middle">
                                <table border="0" cellpadding="0" cellspacing="0">
                                    <tr align="left" valign="bottom">
                                    </tr>
                                </table>
                            </td>-->
                                    <!--<td 

                                    width="20%" align="right" valign="middle">
                                        <a href="http://www.testsite.de">
                                        <img src="/Users/name/Desktop/Parallels-Share/test/KMLKRAM_TEMP/test_logo_neg.png" alt="test Logo" width="100" align="right"/>
                                        </a>
                                    </td>-->
                        </tr>
                    </table>
                </td>
            </tr>
        </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}">

                </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>
            <tr>
                <td>
                    <table width="0" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                        <tr>
                            <td width="100%" align="right" valign="middle">
                                <table border="0" cellpadding="0" cellspacing="0">
                                    <tr align="left" valign="bottom">
                                    </tr>
                                </table>
                            </td>
                                    <td 

                                    width="15%" align="right" valign="middle">
                                        <a href="http://www.test.de">
                                        <img src="/Users/name/Desktop/Parallels-Share/test/KMLKRAM_TEMP/test_logo.gif" alt="test Logo" width="100" align="right"/>
                                        <!--<img src="/Users/name/Desktop/Parallels-Share/test/KMLKRAM_TEMP/test_logo_neg.png" alt="test Logo" width="100" align="right"/>-->
                                        </a>
                                    </td>
                        </tr>
                    </table>
                </td>
            </tr>
    </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() ) 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(., '\\')]">
                    <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>

The conversion works fine, so far. The kmz-file is displayed as wished. Now I want to customize the kmz-file more so it shows 2 levels of subfolders, which I can select/deselect. To achieve that, I am adding another attribute field to my feature class named "FolderPath" adding the desired levels as so:

Using Field Calculator (VB Script): "Desired Setting"+"/"+[desired_sett]+"/"+[2nd_desired_sett]

I keep all the attributes' customization as described above. When I export the feature class now, I get the subfolders in the kmz as wished but the attributes are no longer customized and the whole attribute table is shown without aliases. I don't see the mistake I am making here. Is that the appropriate approach to what I try to achieve at all?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.