<xsl:template match="tei:forest|tei:eTree|tei:eLeaf">
<xsl:variable name="thistreestyle" select="if (ancestor-or-self::eTree/@rend) then ancestor-or-self::eTree[last()]/@rend else $treestyle"/>
<xsl:choose>
<xsl:when test="$thistreestyle='googlechart'">
<xsl:if test="not(preceding::tei:eTree or preceding::tei:forest)">
<script type="text/javascript" src="https://www.google.com/jsapi"/>
<script type="text/javascript">
google.setOnLoadCallback(drawCharts);
function drawCharts() {
<xsl:for-each select="key('TREES',1)"><xsl:variable name="TREEID" select="generate-id()"/><xsl:text>var data</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>= new google.visualization.DataTable();
data</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>.addColumn('string', 'Person');
data</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>.addColumn('string', 'Parent');
data</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>.addColumn('string', 'Note');
data</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>.addRows([
[{v:'</xsl:text><xsl:value-of select="generate-id()"/><xsl:text>', f:'</xsl:text><xsl:for-each select="tei:label"><xsl:apply-templates/></xsl:for-each><xsl:text>'}, '', ''],
</xsl:text><xsl:for-each select=".//tei:eTree|.//tei:eLeaf"><xsl:text>[{v:'</xsl:text><xsl:value-of select="generate-id()"/><xsl:text>', f:'</xsl:text><xsl:for-each select="tei:label"><xsl:apply-templates/></xsl:for-each><xsl:text>'}, '</xsl:text><xsl:for-each select="parent::tei:*"><xsl:value-of select="generate-id()"/></xsl:for-each><xsl:text>', ''],
</xsl:text></xsl:for-each><xsl:text>]);
var chart</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>= new google.visualization.OrgChart(document.getElementById('chart</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>'));
chart</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>.draw(data</xsl:text><xsl:value-of select="$TREEID"/><xsl:text>, {allowCollapse:true,nodeClass:'teinode',allowHtml:true});
</xsl:text></xsl:for-each>
};
</script>
</xsl:if>
<xsl:if test="not(ancestor::tei:eTree or ancestor::tei:forest)">
<xsl:variable name="TREEID" select="generate-id()"/>
<span id="chart{$TREEID}"/>
</xsl:if>
</xsl:when>
<xsl:when test="$thistreestyle='d3VerticalTree'">
<xsl:choose>
<xsl:when test="not(ancestor::tei:eTree or ancestor::tei:forest)">
<xsl:variable name="maxlabel" select="(max(descendant::tei:label/string-length()))"/>
<xsl:variable name="treewidth" select="max(descendant-or-self::*[self::tei:eTree or self::tei:eLeaf]/(count(tei:eLeaf)+count(tei:eTree))) * 175"/>
<xsl:variable name="treedepth" select="max(descendant::*[(self::tei:eTree or self::tei:eLeaf) and not(tei:eTree or tei:eLeaf)]/count(ancestor-or-self::*[self::tei:eTree or self::tei:eLeaf]))"/>
<xsl:variable name="TREEID" select="generate-id()"/>
<div class="treediagram" style="width:{$treewidth} {@style}" id="viz{$TREEID}"/>
<script type="text/javascript">
<xsl:choose>
<xsl:when test="$maxlabel > 150">
downoffset= 75;
down2offset=5;
yoffset = -75;
treewidth = <xsl:value-of select="$treewidth"/>;
treedepth = <xsl:value-of select="$treedepth * 100"/>;
</xsl:when>
<xsl:when test="$maxlabel > 50">
downoffset= 50;
down2offset=5;
yoffset = -45;
treewidth = <xsl:value-of select="$treewidth"/>;
treedepth = <xsl:value-of select="$treedepth * 100"/>;
</xsl:when>
<xsl:when test="$maxlabel > 10">
downoffset= 40;
down2offset=5;
yoffset = -35;
treewidth = <xsl:value-of select="$treewidth"/>;
treedepth = <xsl:value-of select="$treedepth * 75"/>;
</xsl:when>
<xsl:otherwise>
downoffset= 10;
down2offset=5;
yoffset = -10;
treewidth = <xsl:value-of select="$treewidth"/>;
treedepth = <xsl:value-of select="$treedepth * 40"/>;
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="extray">
<xsl:choose>
<xsl:when test="$maxlabel > 150">150</xsl:when>
<xsl:when test="$maxlabel > 50">100</xsl:when>
<xsl:when test="$maxlabel > 10">50</xsl:when>
<xsl:otherwise>25</xsl:otherwise>
</xsl:choose>
</xsl:variable>
var treeData = {<xsl:call-template name="treelabel"/>};
visMe("#viz<xsl:value-of select="$TREEID"/>",<xsl:value-of select="$extray"/>);
</script>
</xsl:when>
<xsl:otherwise>{
<xsl:call-template name="treelabel"/>
<xsl:text>},
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$thistreestyle='d3DragDropTree'">
<xsl:variable name="TREEID" select="generate-id()"/>
<xsl:choose>
<xsl:when test="not(ancestor::tei:eTree or ancestor::tei:forest)">
<div id="viz{$TREEID}"/>
<script src="dndTree.js"/>
<script type="text/javascript">
treeData = {<xsl:call-template name="treelabel"/>};
dragndrop("#viz<xsl:value-of select="$TREEID"/>");
</script>
</xsl:when>
<xsl:otherwise>{
<xsl:call-template name="treelabel"/>
<xsl:text>} </xsl:text>
<xsl:if test="following-sibling::tei:*">,</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$thistreestyle='d3CollapsableTree'">
<xsl:choose>
<xsl:when test="not(ancestor::tei:eTree or ancestor::tei:forest)">
<xsl:variable name="maxlabel" select="(max(descendant::tei:label/string-length()))"/>
<xsl:variable name="treeheight" select="max(descendant-or-self::*[self::tei:eTree or self::tei:eLeaf]/(count(tei:eLeaf)+count(tei:eTree))) * 155"/>
<xsl:variable name="treewidth" select="count(descendant-or-self::*[self::tei:eTree]) * 130"/>
<xsl:variable name="treedepth" select="max(descendant::*[(self::tei:eTree or self::tei:eLeaf) and not(tei:eTree or tei:eLeaf)]/count(ancestor-or-self::*[self::tei:eTree or self::tei:eLeaf]))"/>
<xsl:variable name="TREEID" select="generate-id()"/>
<div class="treediagram" style="width:{$treewidth} {@style}" id="viz{$TREEID}"/>
<script type="text/javascript">
treeData = {<xsl:call-template name="treelabel"/>};
drawCollapsibleTree("#viz<xsl:value-of select="$TREEID"/>",<xsl:value-of select="$treewidth"/>,<xsl:value-of select="$treeheight"/>);
d3.select(self.frameElement).style("height", "500px");
</script>
</xsl:when>
<xsl:otherwise>{
<xsl:call-template name="treelabel"/>
<xsl:text>} </xsl:text>
<xsl:if test="following-sibling::tei:*">,</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:template> |