Index: main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 26136)
+++ main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 26139)
@@ -65,4 +65,5 @@
 			<xsl:when test="@docType='simple'">
 				<div id="gs-document">
+					<xsl:call-template name="documentPre"/>
 					<xsl:call-template name="wrappedSectionImage"/>
 					<div id="gs-document-text">
@@ -589,17 +590,35 @@
 		<div id="jsonNodes" style="display:none;">
 			<xsl:text>[</xsl:text>
-			<xsl:for-each select="//documentNode">
-				<xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
-					<xsl:text>{</xsl:text>
-					<xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text>
-					<xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>
-					<xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
-					<xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
-					<xsl:text>}</xsl:text>
-					<xsl:if test="not(position() = count(//documentNode))">
-						<xsl:text>,</xsl:text>
-					</xsl:if>
-				</xsl:if>
-			</xsl:for-each>
+			<xsl:choose>
+				<!-- HIERARCHICAL DOCUMENTS -->
+				<xsl:when test="count(//documentNode) > 0">
+					<xsl:for-each select="//documentNode">
+						<xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
+							<xsl:text>{</xsl:text>
+							<xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text>
+							<xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>
+							<xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
+							<xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
+							<xsl:text>}</xsl:text>
+							<xsl:if test="not(position() = count(//documentNode))">
+								<xsl:text>,</xsl:text>
+							</xsl:if>
+						</xsl:if>
+					</xsl:for-each>
+				</xsl:when>
+				<!-- SIMPLE DOCUMENTS -->
+				<xsl:otherwise>
+					<xsl:for-each select="/page/pageResponse/document">
+						<xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
+							<xsl:text>{</xsl:text>
+							<xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@selectedNode"/><xsl:text disable-output-escaping="yes">",</xsl:text>
+							<xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>
+							<xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
+							<xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
+							<xsl:text>}</xsl:text>
+						</xsl:if>
+					</xsl:for-each>
+				</xsl:otherwise>
+			</xsl:choose>
 			<xsl:text>]</xsl:text>
 		</div>
