<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:vcg="http://zvon.org/graphotron/vcg"
> 
<xsl:namespace-alias stylesheet-prefix="aaa" result-prefix="xsl"/>

<xsl:include href="graphotronShare.xsl"/>

<xsl:template name="header">
  <xsl:param name="params"/>
  <xsl:text>graph: {&#xA;</xsl:text>

  <xsl:if test="$params/node()">
    <aaa:variable name="eee"> 
      <xsl:copy-of select="$params"/> 
    </aaa:variable> 
    <aaa:apply-templates select="$eee" mode="printParam"/> 
  </xsl:if> 
</xsl:template> 

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

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

    <aaa:if test="not(local-name()='backedge' or local-name()='nearedge' or local-name()='bentnearedge')">
      <aaa:variable name="quote">
	<aaa:if test="starts-with(local-name(),'info') or local-name()='label' or local-name()='title'">
	  <aaa:text>"</aaa:text>
	</aaa:if>
      </aaa:variable>

      <aaa:value-of select="concat(' ',local-name())"/>
      <aaa:text>:</aaa:text>
      <aaa:value-of select="$quote"/>
      <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:value-of select="$quote"/>
    </aaa:if>
  </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>node: {title:"</aaa:text>
	<xsl:call-template name="vertex-id"/>
	<aaa:text>" label:"</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>}&#xA;</aaa:text>
      </v>
</xsl:template>

<xsl:template name="call-print-edges">
  <aaa:apply-templates select="$xxx/e" mode="printText"/>
</xsl:template>


<xsl:template name="printEdge">
  
  <aaa:choose>
    <aaa:when test="$params/vcg:backedge">
      <aaa:text>back</aaa:text>
    </aaa:when>
    <aaa:when test="$params/vcg:nearedge">
      <aaa:text>near</aaa:text>
    </aaa:when>
    <aaa:when test="$params/vcg:bentnearedge">
      <aaa:text>bentnear</aaa:text>
    </aaa:when>
  </aaa:choose>
  <aaa:text>edge: {sourcename:"</aaa:text>
  <aaa:value-of select="$origin"/>
  <aaa:text>" targetname:"</aaa:text>
  <aaa:value-of select="$target"/>
  <aaa:text>" </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>}&#xA;</aaa:text>
</xsl:template>
</xsl:stylesheet> 












