xsltproc instead of xalan

Status
Nicht offen für weitere Antworten.

dand_dd

Mitglied
I want to transform xml to html with a build.xml ant file from eclipse How to modify the build.xml ant file to work with xsltproc.exe instead of using xalan?

actually build.xml

[XML]<?xml version="1.0"?>
<!--
- Author: Lars Vogel
-->
<project name="docbook-src" >

<description>
This Ant buildhtml.xml file is used to transform DocBook XML to html output
</description>

<!--
- Configure basic properties that will be used in the file.
-->
<property name="docbook.xsl.dir" value="docbook-xsl-1.72.0" />
<property name="doc.dir" value="output" />
<property name="src" value="src" />
<property name="html.stylesheet" value="${docbook.xsl.dir}/html/docbook.xsl" />
<property name="xalan.lib.dir" value="lib/xalan-j_2_7_0" />

<!--
- Sets up the classpath for the Xalan and Xerces implementations
- that are to be used in this script, since the versions that ship
- with Ant may be out of date.
-->
<path id="xalan.classpath">
<fileset dir="${xalan.lib.dir}" id="xalan.fileset">
<include name="xalan.jar" />
<include name="xercesImpl.jar" />
<include name="serializer.jar" />
</fileset>
</path>

<target name="build-html" description="Generates HTML files from DocBook XML">
<xslt style="${html.stylesheet}" extension=".html" basedir="${src}" destdir="${doc.dir}">
<classpath refid="xalan.classpath" />
<include name="**/*book.xml" />
<include name="**/*article.xml" />
<param name="html.stylesheet" expression="style.css" />
</xslt>
<!-- Copy the stylesheet to the same directory as the HTML files -->
<copy todir="${doc.dir}">
<fileset dir="lib">
<include name="style.css" />
</fileset>
</copy>
</target>

</project>
[/XML]

I have to modify docbook to the new version docbook-5.0 and "docbook-xsl-1.72.0" to "docbook-xsl-1.74.3" and instead of "xalan-j_2_7_0" i must use just xsltproc.exe.

Can anyone help me?

Thanks!
 

dand_dd

Mitglied
Thank you for the answer.

I have written the following build.xml to transform a xml file into a html file:

[XML]<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
30.07.2009 11:24:26

BuildXML
description


====================================================================== -->
<project name="BuildXML" default="infopool3">
<description>
description
</description>

<!-- xsltproc file directory -->
<property name="xslt.processor" location="c:\Win16App\TC\XML\XslProcessing\bin\"/>
<property name="xslt.processor" value="xsltproc.exe"/>

<!-- xslt docbook file directory -->
<property name="docbook.xslt.home" location="c:\Win16App\TC\XML\docbook-xsl-1.74.3\"/>

<!-- xsl template for HTML generation -->
<property name="html.stylesheet" location="${docbook.xslt.home}html\docbook.xsl"/>

<!-- XML files directory -->
<property name="docbook.xml.dir" location="./resource/XML"/>

<!-- Buil directory -->
<property name="build.dir" location="./resource/xml"/>

<!-- input file name -->
<property name="docbook.input.file" value="infopool3.xml"/>

<property location="./tmp" name="build.dir" />

<!-- =================================
target: infopool3
================================= -->
<target name="infopool3">
<antcall target="html.exec">
<param name="file" value="${build.dir}/${docbook.input.file}" />
</antcall>
</target>

<!-- - - - - - - - - - - - - - - - - -
target: depends
- - - - - - - - - - - - - - - - - -->
<target name="html.exec">
<echo message="File: ${file}" />
<exec executable="xsltproc">
<arg value="-o d:\eclipse-ant\resource\xml\infopool3.html c:\Win16App\TC\XML\docbook-xsl-1.74.3\html\docbook.xsl d:\eclipse-ant\resource\xml\infopool3.xml" />
</exec>
</target>

</project>
[/XML]

But it's not working.

I think here is the problem, but i don't know how to resolve it:
[XML]<target name="html.exec">
<echo message="File: ${file}" />
<exec executable="xsltproc">
<arg value="-o d:\eclipse-ant\resource\xml\infopool3.html c:\Win16App\TC\XML\docbook-xsl-1.74.3\html\docbook.xsl d:\eclipse-ant\resource\xml\infopool3.xml" />
</exec>
</target>[/XML]

Can you help me?

Thanks

Dan
 

mvitz

Top Contributor
Maybe you should try:

[XML]<target name="html.exec">
<echo message="File: ${file}" />
<exec executable="xsltproc">
<arg line="-o d:/eclipse-ant/resource/xml/infopool3.html c:/Win16App/TC/XML/docbook-xsl-1.74.3/html/docbook.xsl d:/eclipse-ant/resource/xml/infopool3.xml" />
</exec>
</target>[/XML]
 

dand_dd

Mitglied
Thanks, it is working. I have tried the last days all variants include yours, but now it's working.
This build is just for one files. How to transform all the xml files from one folder? It is possible?

Thank you!

Dan
 

mvitz

Top Contributor
1) Download: Download ANT Contrib from SourceForge.net an put to jar the lib directory from your Ant installation.

Backup all needed files :D

Test with this example file:
[XML]<?xml version="1.0" encoding="UTF-8" ?>
<project name="test" default="test" basedir=".">

<property name="xml.dir" value="d:/eclipse-ant/resource/xml" />
<property name="docbook.xsl" value="c:/Win16App/TC/XML/docbook-xsl-1.74.3/html/docbook.xsl" />

<target name="test">
<ac:for param="xml.file" xmlns:ac="antlib:net.sf.antcontrib">
<path><fileset dir="${xml.dir}" includes="*.xml" /></path>
<sequential>

<ac:propertyregex property="html.file" input="@{xml.file}" regexp="(.*)\.xml" select="\1.html" />

<echo>Converting '@{xml.file}' to '${html.file}'</echo>

<exec executable="xsltproc">
<arg line="-o ${html.file} ${docbook.xsl} @{xml.file}" />
</exec>

</sequential>
</ac:for>
</target>

</project>[/XML]

Hope this helps.
 
Status
Nicht offen für weitere Antworten.

Neue Themen


Oben