<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.1"
xmlns:aaa="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:graph="http://zvon.org/graphotron"
xmlns:daVinci="http://zvon.org/graphotron/daVinci"
> 
<xsl:import href="graphotronShare.xsl"/>

<xsl:namespace-alias stylesheet-prefix="aaa" result-prefix="xsl"/>


<xsl:template name="header">
  <xsl:text>[&#xA;</xsl:text>
</xsl:template>

<xsl:template name="footer">
  <xsl:text>&#xA;]</xsl:text>
</xsl:template>

<xsl:template name="xslt-extension">

</xsl:template>

<xsl:template name="printParam">
  <aaa:template match="*" mode="printParam"/>
  <aaa:template match="daVinci:*" mode="printParam" priority="10">
    <aaa:param name="xslt-target-id"/>

    <aaa:text> a("</aaa:text>
    <aaa:value-of select="local-name()"/>
    <aaa:text>","</aaa:text>
    <aaa:call-template name="printParamValue">
      <aaa:with-param name="xslt-target-id" select="$xslt-target-id"/>
      <aaa:with-param name="value" select="."/>
    </aaa:call-template>
    <aaa:text>"), </aaa:text>
  </aaa:template>
</xsl:template>

<xsl:template name="vertex-id">
  <aaa:value-of select="generate-id()"/>
</xsl:template>

<xsl:template name="printNode">
      <aaa:variable name="xxx">
	<aaa:if test="$generate-position='yes'">
	  <aaa:text>\n</aaa:text>
	  <aaa:call-template name="create-generate-position"/>
	</aaa:if>
      </aaa:variable>
      <v>
	<aaa:text>&#xA;l("</aaa:text>
	<xsl:call-template name="vertex-id"/>
	<aaa:text>", n("", [a("OBJECT","</aaa:text>
	<aaa:value-of select='$name'/>
	<aaa:value-of select='$xxx'/>
	<aaa:text>"),</aaa:text>
	<aaa:apply-templates select="$params/*" mode="printParam"/>
	<aaa:text>],</aaa:text>
	<aaa:text>[</aaa:text>

	<xsl:for-each select="/*/graph:edge"> 
	  <aaa:apply-templates select="." mode="createEdge{position()}">
	    <aaa:with-param name="origin"><xsl:call-template name="vertex-id"/></aaa:with-param>
	  </aaa:apply-templates>
	</xsl:for-each> 

	<aaa:text>])),</aaa:text>
      </v>
</xsl:template>

<xsl:template name="call-print-edges"/>

<xsl:template name="printEdge">
  <aaa:text>&#xA;l(</aaa:text>
  <aaa:text>"</aaa:text>
  <aaa:value-of select="concat($edge-id,'-',$origin,'-',$target)"/>
  <aaa:text>",</aaa:text>
  <aaa:text>e("",[</aaa:text>
  <aaa:apply-templates select="$params/*" mode="printParam">
    <aaa:with-param name="xslt-target-id" select="$xslt-target-id"/>
  </aaa:apply-templates>
  <aaa:text>],</aaa:text>
  <aaa:text>r("</aaa:text>
  <aaa:value-of select="$target"/>
  <aaa:text>")</aaa:text>
  <aaa:text>)),</aaa:text>
</xsl:template>

</xsl:stylesheet> 





