RE: [xsl] Critique/comments sought: XML/XSLT website documentatio n project

Subject: RE: [xsl] Critique/comments sought: XML/XSLT website documentatio n project
From: David.Pawson@xxxxxxxxxxx
Date: Fri, 19 Sep 2003 09:54:58 +0100
> You mean there are hooks to use graphviz from XSLT? Any examples out 
> there? 
just playing,

xml

<dg height="11" width="8.5" title="Initial Testing of dg \n Dave Pawson">
  <cluster id="cluster1" label="Group1" color="ivory">
    <node shape="circle" label="Start Here" fontsize="12" id="start"/>
    <node label="Process" id="process" color="yellow"/>
  </cluster>
  <node shape="circle" label="Start Here" fontsize="12" id="start"/>
  <node label="Process" id="process" color="yellow"/>
  <connect source="start" target="process" color="maroon"
lineStyle="dotted"/>
 
  <connect source="process" target="midpoint" label="On occasion"/>
  <node id="midpoint" connectTo="mid2" lineStyle="dashed"/>
  <node id="mid2"/>
  <node id="mid3"/>
  <connect source="process" target="mid2"/>
  <connect source="mid2" target="mid3"/>
  <connect source="mid3" target="end"/>
  <node shape="circle" id="end" label="END" color="chocolate"/>

</dg>



xslt 
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet[
  <!ENTITY nl "<xsl:text> &#x0A;&#x0D;</xsl:text>" >
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.1">

  <xsl:key name="labels" match="node" use="@label"/>
  <xsl:output method="text"  indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="dg">
    digraph G {
    <xsl:if test="@title">label="<xsl:value-of select="@title"/>"; </xsl:if>
  <xsl:if test="@height">size="<xsl:value-of
select="@height"/>,<xsl:value-of select="@width"/>"; </xsl:if>
    <xsl:choose>
      <xsl:when test="@font">font="<xsl:value-of select="@font"/>"
</xsl:when>
      <xsl:otherwise> font="Arial" </xsl:otherwise>
    </xsl:choose>
;
    <xsl:if test="child::cluster">
      compound=true;
    </xsl:if>
        <xsl:apply-templates/>
}
  </xsl:template>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>


  <xsl:template match="cluster">
    <xsl:value-of select="concat('subgraph cluster',@id)"/>
{<xsl:if test="@label">label="<xsl:value-of select="@label"/>";</xsl:if>
<xsl:if test="@color">color="<xsl:value-of select="@color"/>"</xsl:if>;
style=filled;
    <xsl:apply-templates/>}
  </xsl:template>



  <xsl:template match="node">
    <xsl:if test="not(@id) or @id=''">
      <xsl:message terminate="yes">
        No id provided:terminating. <xsl:value-of select="@*"/>
      </xsl:message>
    </xsl:if>
&nl;&nl;<xsl:value-of select="@id"/>
<xsl:if test="@shape">&nl;[shape="<xsl:value-of select="@shape"/>"
]</xsl:if>
<xsl:if test="@label">[label="<xsl:value-of select="@label"/>" ]</xsl:if>
<xsl:if test="@color">[color="<xsl:value-of select="@color"/>"]</xsl:if>
<xsl:if test="@fontsize">[fontsize="<xsl:value-of
select="@fontsize"/>"]</xsl:if>
<xsl:if test="@lineStyle">[style="<xsl:value-of
select="@lineStyle"/>"]</xsl:if>;&nl;

<xsl:if test="@connectTo">
<xsl:value-of select="@id"/> -> <xsl:value-of select="@connectTo"/>;&#x0A;
</xsl:if>
  </xsl:template>

  <xsl:template match="connect">
    &nl;<xsl:value-of select="@source"/> -> <xsl:value-of select="@target"/>
    <xsl:if test="@color">[color="<xsl:value-of select="@color"/>"]</xsl:if>
    <xsl:if test="@weight">[weight="<xsl:value-of
select="@weight"/>"]</xsl:if>
    <xsl:if test="@lineStyle">[style="<xsl:value-of
select="@lineStyle"/>"]</xsl:if>
    <xsl:if test="@label">[label="<xsl:value-of
select="@label"/>"]</xsl:if>;
  </xsl:template>

  <xsl:template match="*">
    <xsl:message>   *****<xsl:value-of select="name(..)"/>/<xsl:value-of
    select="name()"/>****** </xsl:message>
</xsl:template>


</xsl:stylesheet>

- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread