Added images treatement

parent 9f37adb5
......@@ -36,6 +36,19 @@
<xslt classpath="lib/saxon9he.jar" in="input/${inputFile}" out="${tmpFolderPath}/${filename}_prepared.xml" style="${xsltFolderPath}/prepare_wiki_to_hdoc.xsl">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<!-- Prepare the ant script that will get our ressources(images )-->
<xslt classpath="lib/saxon9he.jar"
in="${tmpFolderPath}/${filename}_prepared.xml"
out="${tmpFolderPath}/${filename}_ressources.xml" style="${xsltFolderPath}/get_ressources_urls.xsl">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<ant antfile="${tmpFolderPath}/${filename}_ressources.xml"/>
</target>
<!-- Create the hdoc structure of the new file -->
......@@ -65,7 +78,11 @@
<copy todir="${tmpHdocResultFolderPath}/listing" >
<fileset dir="${hdocResultPath}/listing" includes="**"/>
</copy>
<copy todir="${tmpHdocResultFolderPath}/ressources" >
<fileset dir="${hdocResultPath}/ressources" includes="**"/>
</copy>
<!-- Copy of the html file, hdoc needs "container.xml" file, not a html. The html file can be useful to the user -->
<copy file="${hdocResultPath}/${filename}.html" tofile="${tmpHdocResultFolderPath}/content.xml"/>
</target>
......
......@@ -42,6 +42,19 @@
<xslt classpath="lib/saxon9he.jar" in="${inputFile}" out="${tmpFolderPath}/${filename}_prepared.xml" style="${xsltFolderPath}/prepare_wiki_to_hdoc.xsl">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<!-- Prepare the ant script that will get our ressources(images )-->
<xslt classpath="lib/saxon9he.jar"
in="${tmpFolderPath}/${filename}_prepared.xml"
out="${tmpFolderPath}/${filename}_ressources.xml" style="${xsltFolderPath}/get_ressources_urls.xsl">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<ant antfile="${tmpFolderPath}/${filename}_ressources.xml"/>
</target>
<!-- Create the hdoc structure of the new file -->
......@@ -77,6 +90,11 @@
<fileset dir="${hdocResultPath}/tables" includes="**"/>
</copy>
<copy todir="${tmpHdocResultFolderPath}/ressources" >
<fileset dir="${hdocResultPath}/ressources" includes="**"/>
</copy>
<!-- Copy of the html file, hdoc needs "container.xml" file, not a html. The html file can be useful to the user -->
<copy file="${hdocResultPath}/${filename}.html" tofile="${tmpHdocResultFolderPath}/content.xml"/>
</target>
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0"
xmlns:saxon="http://saxon.sf.net/"
extension-element-prefixes="saxon"
>
<!-- This XSL create an ANT script that will download our ressources (images) using the GET TASK-->
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<project name="getRessourcesFiles" basedir="." default="getRessourcesFiles">
<target name="getRessourcesFiles">
<xsl:apply-templates select="//div[@class='thumb tleft' or @class='thumb tright']//img"/>
</target>
</project>
</xsl:template>
<xsl:template match="img" priority="5">
<xsl:param name="dest-rep">${hdocResultPath}/ressources</xsl:param>
<xsl:param name="dest-file">${hdocResultPath}/ressources/<xsl:value-of select="tokenize(@src, '/')[last()]"/></xsl:param>
<mkdir dir="{$dest-rep}"/>
<get src="{@src}" dest="{$dest-file}" />
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -10,6 +10,31 @@
</xsl:copy>
</xsl:template>
<xsl:template match ="/html/body/div/div/div/div[@class='thumb tleft' or @class='thumb tright']" priority="1">
<div class="{@class}">
<xsl:apply-templates select=".//img" />
<xsl:apply-templates select=".//div[@class='thumbcaption']" />
</div>
</xsl:template>
<xsl:template match="img">
<img src="http:{@src}" alt="{@alt}"/>
</xsl:template>
<xsl:template match="div[@class='thumbcaption']">
<p class="thumbcaption">
<xsl:apply-templates select="./text() | .//a/text()" mode="thumbcaption"/>
</p>
</xsl:template>
<xsl:template match="text()" mode="thumbcaption">
<xsl:value-of select="."/>
</xsl:template>
<!-- Scripts are not useful to us -->
<xsl:template match="script"/>
......
......@@ -77,6 +77,13 @@
<!-- Storing current section to know when apply template has to be called in the next parts of the template -->
<xsl:variable name="currentSectionTitle" select="." />
<!-- Apply this template for all elements between the actual title h{2,3,4,5} and the next one -->
<xsl:variable name="nextTitle" select="following-sibling::*[starts-with(name(), 'h')][1]"/>
<xsl:apply-templates select="following-sibling::div[contains(@class,'thumb tleft') or contains(@class,'thumb tright')] intersect $nextTitle/preceding-sibling::*"/>
<!-- If there is text right below the section name, copy it -->
<xsl:if test="not(following-sibling::*[1] intersect following-sibling::h3) and not(following-sibling::*[1] intersect following-sibling::h4) and not(following-sibling::*[1] intersect following-sibling::h5) and not(following-sibling::*[1] intersect following-sibling::h6)">
<div>
......@@ -320,6 +327,24 @@
<sup><xsl:value-of select="."/></sup>
</xsl:template>
<!-- Images -->
<xsl:template match="div[contains(@class,'thumb')]">
<div>
<xsl:apply-templates select=".//img"/>
<xsl:apply-templates select=".//p[@class='thumbcaption']"/>
</div>
</xsl:template>
<xsl:template match="img">
<img src="./ressources/{tokenize(@src, '/')[last()]}" alt="{@alt}"/>
</xsl:template>
<xsl:template match="p[@class='thumbcaption']">
<p> <xsl:value-of select="text()"/> </p>
</xsl:template>
<!-- ===== Ignored content ===== -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment