Next in thread → Next in month →

Re: [docbook-apps] Graphs in docbook?

From
Dave Pawson <>
Date
2009-07-22T15:35:14+00:00
ID
Thread
Re: [docbook-apps] Graphs in docbook?
And using a macrodef with ant, it's easy to generate n svg files.


  <!-- ================================================= -->
<!--   Macro definition to run xslt 2, n times-->
<!--  ================================================== -->

<macrodef name="call-xslt2" backtrace="true">
    <attribute name="source"/>
    <attribute name="output"/>
    <sequential>
       <java classname="${xslt2_processor}"
	fork="yes"
	dir="${basedir}"
	failonerror="true">

     <classpath refid="xslt2.processor.classpath" />
     <jvmarg 
line="-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration"/>
     <jvmarg 
line="-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>
     <jvmarg 
line="-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl"/> 

     <arg value="-l"/>
     <arg value="-o"/>
     <arg value="@{output}"/>
     <arg line="-x org.apache.xml.resolver.tools.ResolvingXMLReader"/>
     <arg line="-y org.apache.xml.resolver.tools.ResolvingXMLReader"/>
     <arg line="-r org.apache.xml.resolver.tools.CatalogResolver "/>
     <arg line="${basedir}/@{source} ${use_xygr2svg_xsl} " />
   </java>
       </sequential>
</macrodef>


<!--  -->
  <!-- Process XML through to SVG  -->
  <!--  -->
  <target name="genSVG">
    <echo>Generate SVG from 4 XML files.</echo>


    <!-- Now run the xslt script to generate the SVG, using 
http://code.google.com/p/graph2svg/ -->
    <!-- Currently there are 4 separate xml source files.
	aprilbm.xml
	maybm.xml
	junebm.xml
	julybm.xml
	
    -->
    <!-- For each one, the docbook source needs to accommodate it
	
	as in

<mediaobject>
   <imageobject>
     <imagedata fileref="graphics/xxx.1.svg" format="SVG"
     contentwidth="150mm"/>
     </imageobject>
     <textobject>
     <phrase>Alt text description</phrase></textobject>
     <caption><para>Graph title</para></caption>
     </mediaobject>
</mediaobject>
  -->

    <!-- Call up the macro as needed-->
    <echo>Generate aprilbm.svg</echo>
    <call-xslt2
        source="aprilbm.xml"
        output="aprilbm.svg"/>

    <echo>Generate maybm.svg</echo>
    <call-xslt2
        source="maybm.xml"
        output="maybm.svg"/>


    <echo>Generate junebm.svg</echo>
    <call-xslt2
        source="junebm.xml"
        output="junebm.svg"/>


    <echo>Generate julybm.svg</echo>
    <call-xslt2
        source="julybm.xml"
        output="julybm.svg"/>


  </target>


Nice solution!




regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk
Next in thread → Next in month →