added images inside text for wiki_to_hdoc

parent c173dd22
...@@ -15,21 +15,19 @@ ...@@ -15,21 +15,19 @@
<project name="getRessourcesFiles" basedir="." default="getRessourcesFiles"> <project name="getRessourcesFiles" basedir="." default="getRessourcesFiles">
<target name="getRessourcesFiles"> <target name="getRessourcesFiles">
<xsl:apply-templates select="//div[@class='thumb tleft' or @class='thumb tright']//img"/> <xsl:apply-templates select="//img"/>
</target> </target>
</project> </project>
</xsl:template> </xsl:template>
<xsl:template match="img" priority="5"> <xsl:template match="img" priority="5">
<xsl:param name="dest-rep">${hdocResultPath}/ressources</xsl:param> <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> <xsl:param name="dest-file">${hdocResultPath}/ressources/<xsl:value-of select="translate(tokenize(@src, '/')[last()],'?%','_')"/></xsl:param>
<mkdir dir="{$dest-rep}"/> <mkdir dir="{$dest-rep}"/>
<get src="{@src}" dest="{$dest-file}" /> <get src="{@src}" dest="{$dest-file}" />
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
\ No newline at end of file
...@@ -11,11 +11,9 @@ ...@@ -11,11 +11,9 @@
</xsl:template> </xsl:template>
<xsl:template match ="/html/body/div/div/div/div[@class='thumb tleft' or @class='thumb tright']" priority="1"> <xsl:template match ="/html/body/div/div/div/div[@class='thumb tleft' or @class='thumb tright']" priority="1">
<div class="{@class}"> <div class="{@class}">
<xsl:apply-templates select=".//img" /> <xsl:apply-templates select=".//img" />
<xsl:apply-templates select=".//div[@class='thumbcaption']" /> <xsl:apply-templates select=".//div[@class='thumbcaption']" />
</div> </div>
</xsl:template> </xsl:template>
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<xsl:apply-templates select="following-sibling::div[contains(@class,'thumb tleft') or contains(@class,'thumb tright')] intersect $nextTitle/preceding-sibling::*"/> <xsl:apply-templates select="following-sibling::div[contains(@class,'thumb tleft') or contains(@class,'thumb tright')] intersect $nextTitle/preceding-sibling::*"/>
<!-- <xsl:apply-templates select="following-sibling::p/img"/>-->
<!-- If there is text right below the section name, copy it --> <!-- 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)"> <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> <div>
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
<xsl:for-each select="following-sibling::* intersect following-sibling::h2[1]/preceding-sibling::*"> <xsl:for-each select="following-sibling::* intersect following-sibling::h2[1]/preceding-sibling::*">
<xsl:if test="not(preceding-sibling::h3 intersect $currentSectionTitle/following-sibling::h3) and not($currentSectionTitle/following-sibling::h4 intersect preceding-sibling::h4) and not($currentSectionTitle/following-sibling::h5 intersect preceding-sibling::h5) and not($currentSectionTitle/following-sibling::h6 intersect preceding-sibling::h6) and not(self::h3) and not(self::h4) and not(self::h5) and not(self::h6)"> <xsl:if test="not(preceding-sibling::h3 intersect $currentSectionTitle/following-sibling::h3) and not($currentSectionTitle/following-sibling::h4 intersect preceding-sibling::h4) and not($currentSectionTitle/following-sibling::h5 intersect preceding-sibling::h5) and not($currentSectionTitle/following-sibling::h6 intersect preceding-sibling::h6) and not(self::h3) and not(self::h4) and not(self::h5) and not(self::h6)">
<xsl:apply-templates select="." mode="textOnly"/> <xsl:apply-templates select="." mode="textOnly"/>
<!--To add images it took me almost 1h and a half I believe strongly that the structure of this page can be changed and made easy !! -->
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
</div> </div>
...@@ -148,7 +149,7 @@ ...@@ -148,7 +149,7 @@
</xsl:template> </xsl:template>
<!-- Text elements not surrounded by div --> <!-- Text elements not surrounded by div -->
<xsl:template match="p|span|i|ul|ol" mode="textOnly"> <xsl:template match="p|span|i|ul|ol" mode="textOnly" >
<xsl:element name="{local-name()}" namespace="http://www.utc.fr/ics/hdoc/xhtml"> <xsl:element name="{local-name()}" namespace="http://www.utc.fr/ics/hdoc/xhtml">
<xsl:apply-templates select="node()" mode="textOnly"/> <xsl:apply-templates select="node()" mode="textOnly"/>
</xsl:element> </xsl:element>
...@@ -387,15 +388,16 @@ ...@@ -387,15 +388,16 @@
<!-- Images --> <!-- Images -->
<xsl:template match="div[contains(@class,'thumb')]"> <xsl:template match="div[contains(@class,'thumb')]">
<div> <div>
<xsl:apply-templates select=".//img"/> <xsl:apply-templates select=".//img" mode="textOnly"/>
<xsl:apply-templates select=".//p[@class='thumbcaption']"/> <xsl:apply-templates select=".//p[@class='thumbcaption']"/>
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="img"> <xsl:template match="img" mode="textOnly">
<img src="./ressources/{tokenize(@src, '/')[last()]}" alt="{@alt}"/> <img src="./ressources/{translate(tokenize(@src, '/')[last()],'?%','_')}" alt="{@alt}"/>
</xsl:template> </xsl:template>
<xsl:template match="p[@class='thumbcaption']"> <xsl:template match="p[@class='thumbcaption']">
<p> <xsl:value-of select="text()"/> </p> <p> <xsl:value-of select="text()"/> </p>
</xsl:template> </xsl:template>
......
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