How to render DotML

徘徊边缘 提交于 2019-12-02 07:04:26

DotML is an alternative XML-based syntax for the dot language used to drive the GraphViz program. The normal way of using it is to convert the DotML to dot, and then run GraphViz to generate SVG. The way I do it (from Ant) is here:

  <target name="dot-files" depends="merge-catalog" if="build.spec" unless="spec.exists">
    <xslt in="${merged-spec.xml}" out="${dist.dir}/Overview.html" style="style/xslt-diff.xsl" 
      force="yes" classpathref="saxon9.classpath">
      <factory name="net.sf.saxon.TransformerFactoryImpl">
        <attribute name="http://saxon.sf.net/feature/initialMode" value="make-dot-files"/>
      </factory>
      <param name="baseline" expression="${baseline}"/>
      <param name="show.diff.markup.string" expression="0"/>
    </xslt>    
  </target>

  <target name="diagrams" description="Process all the diagrams in the img directory"
    depends="dot-files">
    <foreach target="diagram" param="diagram">
      <path>
        <fileset dir="${dist.dir}/img">
          <include name="*.dot"/>
        </fileset>
      </path>
    </foreach>
  </target>

  <target name="diagram">
    <echo message="Converting diagram ${diagram}"/>
    <basename property="name" file="${diagram}" suffix=".dot"/>
    <echo message="  to ${dist.dir}/img/${name}.svg"/>
    <!-- Requires "dot" to be on the path. dot is part of GraphViz. Location might be GraphViz2.24/bin/dot-->
    <exec executable="dot">
      <arg line="-o${dist.dir}/img/${name}.raw.svg -Tsvg ${diagram} "/>
    </exec>

    <xslt in="${dist.dir}/img/${name}.raw.svg" out="${dist.dir}/img/${name}.svg" style="style/tidy-graphviz-svg.xsl" 
      force="yes" classpathref="saxon9.classpath"/>   
  </target>

My case is a bit different because I'm starting with a document that contains multiple diagrams in an XML vocabulary that first needs to be transformed to DotML.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!