Commit c7d43a1d authored by Aghiles's avatar Aghiles
Browse files

gestion des images intégrées partie 1

parent fbe7ba73
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:functx="http://www.functx.com"
xmlns:functx="http://www.functx.com" exclude-result-prefixes="xs" version="2.0" xmlns="http://www.utc.fr/ics/hdoc/xhtml">
exclude-result-prefixes="xs"
version="2.0"
xmlns="http://www.utc.fr/ics/hdoc/xhtml">
<xsl:output method="xhtml" indent="yes"/> <xsl:output method="xhtml" indent="yes"/>
<xsl:preserve-space elements="pre"/> <xsl:preserve-space elements="pre"/>
<xsl:template match="*"/> <xsl:template match="*"/>
<xsl:template match="text()"> <xsl:template match="text()">
<xsl:value-of select="."/> <xsl:value-of select="."/>
</xsl:template> </xsl:template>
<xsl:template match="html"> <xsl:template match="html">
<!-- Schema link --> <!-- Schema link -->
<xsl:processing-instruction name="oxygen">RNGSchema="http://scenari.utc.fr/hdoc/schemas/xhtml/hdoc1-xhtml.rng" type="xml"</xsl:processing-instruction> <xsl:processing-instruction name="oxygen">RNGSchema="http://scenari.utc.fr/hdoc/schemas/xhtml/hdoc1-xhtml.rng" type="xml"</xsl:processing-instruction>
<xsl:text>&#10;</xsl:text> <xsl:text>&#10;</xsl:text>
<!-- html content --> <!-- html content -->
<html> <html>
<head> <head>
...@@ -29,38 +26,43 @@ ...@@ -29,38 +26,43 @@
</body> </body>
</html> </html>
</xsl:template> </xsl:template>
<!-- Head template --> <!-- Head template -->
<xsl:template match="head"> <xsl:template match="head">
<xsl:apply-templates select="title"/> <xsl:apply-templates select="title"/>
<meta charset="utf-8" /> <meta charset="utf-8"/>
<meta name="generator" content="HdocConverter/wikipedia"/> <meta name="generator" content="HdocConverter/wikipedia"/>
<meta name="author" content="Wikipedia"/> <meta name="author" content="Wikipedia"/>
</xsl:template> </xsl:template>
<!-- Body template --> <!-- Body template -->
<xsl:template match="body"> <xsl:template match="body">
<!-- If there is h1 title with firstHeading class, this has to be the first section title --> <!-- If there is h1 title with firstHeading class, this has to be the first section title -->
<xsl:apply-templates select="//h1[1]" mode="introduction"/> <xsl:apply-templates select="//h1[1]" mode="introduction"/>
<!-- Next are all parts of the document: h2 --> <!-- Next are all parts of the document: h2 -->
<xsl:apply-templates select="//h2"/> <xsl:apply-templates select="//h2"/>
</xsl:template> </xsl:template>
<xsl:template match="title"> <xsl:template match="title">
<title><xsl:value-of select="."/></title> <title>
<xsl:value-of select="."/>
</title>
</xsl:template> </xsl:template>
<!-- Beginning of the wikipedia page: introduction paragraph --> <!-- Beginning of the wikipedia page: introduction paragraph -->
<xsl:template match="h1[1]" mode="introduction"> <xsl:template match="h1[1]" mode="introduction">
<section data-hdoc-type="introduction"> <section data-hdoc-type="introduction">
<header> <header>
<h1>Introduction</h1> <h1>Introduction</h1>
</header> </header>
<!-- Introduction text before first h2 (first section) --> <!-- Introduction text before first h2 (first section) -->
<xsl:if test="//p[count(preceding::h2)=0 and not(ancestor::td)]"> <xsl:if test="//p[count(preceding::h2)=0 and not(ancestor::td)]">
<div><xsl:apply-templates select="//p[count(preceding::h2)=0 and not(ancestor::td)]" mode="textOnly"/></div> <div>
<xsl:apply-templates select="//p[count(preceding::h2)=0 and not(ancestor::td)]"
mode="textOnly"/>
</div>
</xsl:if> </xsl:if>
</section> </section>
</xsl:template> </xsl:template>
...@@ -73,41 +75,51 @@ ...@@ -73,41 +75,51 @@
<xsl:attribute name="data-hdoc-type">unit-of-content</xsl:attribute> <xsl:attribute name="data-hdoc-type">unit-of-content</xsl:attribute>
</xsl:if> </xsl:if>
<header> <header>
<h1><xsl:apply-templates select="node()" mode="title"/></h1> <h1>
<xsl:apply-templates select="node()" mode="title"/>
</h1>
</header> </header>
<!-- Storing current section to know when apply template has to be called in the next parts of the template --> <!-- Storing current section to know when apply template has to be called in the next parts of the template -->
<xsl:variable name="currentSectionTitle" select="." /> <xsl:variable name="currentSectionTitle" select="."/>
<!-- Apply this template for all elements between the actual title h{2,3,4,5} and the next one --> <!-- 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: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::*"/> <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"/>--> <!-- <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>
<!--IIICCIIII --> <!--IIICCIIII -->
<xsl:for-each select="following-sibling::* intersect following-sibling::h2[1]/preceding-sibling::*"> <xsl:for-each
<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)"> 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: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 !! --> <!--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>
</xsl:if> </xsl:if>
<!-- Applying template of subsections if any --> <!-- Applying template of subsections if any -->
<xsl:choose> <xsl:choose>
<xsl:when test="self::h2"> <xsl:when test="self::h2">
<!-- h2 can have h3 subsections --> <!-- h2 can have h3 subsections -->
<xsl:apply-templates select="following-sibling::h3 intersect following-sibling::h2[1]/preceding-sibling::h3"/> <xsl:apply-templates
select="following-sibling::h3 intersect following-sibling::h2[1]/preceding-sibling::h3"
/>
</xsl:when> </xsl:when>
<xsl:when test="self::h3"> <xsl:when test="self::h3">
<!-- Apply template to h4 subsections of h3. These h4 are below the current h3: previous h3 of these h4 is current h3. --> <!-- Apply template to h4 subsections of h3. These h4 are below the current h3: previous h3 of these h4 is current h3. -->
<xsl:for-each select="following-sibling::h4 intersect following-sibling::h2[1]/preceding-sibling::h4"> <xsl:for-each
select="following-sibling::h4 intersect following-sibling::h2[1]/preceding-sibling::h4">
<xsl:if test="(preceding-sibling::h3[1] intersect $currentSectionTitle)"> <xsl:if test="(preceding-sibling::h3[1] intersect $currentSectionTitle)">
<xsl:apply-templates select="."/> <xsl:apply-templates select="."/>
</xsl:if> </xsl:if>
...@@ -115,16 +127,20 @@ ...@@ -115,16 +127,20 @@
</xsl:when> </xsl:when>
<xsl:when test="self::h4"> <xsl:when test="self::h4">
<!-- Apply template aux h5 devant qui sont soit avant un h2, soit un h3, soit un h4 --> <!-- Apply template aux h5 devant qui sont soit avant un h2, soit un h3, soit un h4 -->
<xsl:for-each select="following-sibling::h5 intersect following-sibling::h2[1]/preceding-sibling::h5"> <xsl:for-each
<xsl:if test="(preceding-sibling::h3[1] intersect $currentSectionTitle/preceding-sibling::h3[1]) and (preceding-sibling::h4[1] intersect $currentSectionTitle)"> select="following-sibling::h5 intersect following-sibling::h2[1]/preceding-sibling::h5">
<xsl:if
test="(preceding-sibling::h3[1] intersect $currentSectionTitle/preceding-sibling::h3[1]) and (preceding-sibling::h4[1] intersect $currentSectionTitle)">
<xsl:apply-templates select="."/> <xsl:apply-templates select="."/>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
</xsl:when> </xsl:when>
<xsl:when test="self::h5"> <xsl:when test="self::h5">
<!-- Apply template aux h6 devant qui sont soit avant un h2, soit un h3, soit un h4 --> <!-- Apply template aux h6 devant qui sont soit avant un h2, soit un h3, soit un h4 -->
<xsl:for-each select="following-sibling::h6 intersect following-sibling::h2[1]/preceding-sibling::h6"> <xsl:for-each
<xsl:if test="(preceding-sibling::h3[1] intersect $currentSectionTitle/preceding-sibling::h3[1]) and (preceding-sibling::h4[1] intersect $currentSectionTitle/preceding-sibling::h4[1]) and (preceding-sibling::h5[1] intersect $currentSectionTitle)"> select="following-sibling::h6 intersect following-sibling::h2[1]/preceding-sibling::h6">
<xsl:if
test="(preceding-sibling::h3[1] intersect $currentSectionTitle/preceding-sibling::h3[1]) and (preceding-sibling::h4[1] intersect $currentSectionTitle/preceding-sibling::h4[1]) and (preceding-sibling::h5[1] intersect $currentSectionTitle)">
<xsl:apply-templates select="."/> <xsl:apply-templates select="."/>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
...@@ -132,16 +148,20 @@ ...@@ -132,16 +148,20 @@
</xsl:choose> </xsl:choose>
</section> </section>
</xsl:template> </xsl:template>
<!-- Wikipedia h6 is not a section in hdoc: div with h6 title --> <!-- Wikipedia h6 is not a section in hdoc: div with h6 title -->
<xsl:template match="h6"> <xsl:template match="h6">
<div> <div>
<h6><xsl:apply-templates select="node()" mode="titleh6"/></h6> <h6>
<xsl:apply-templates select="node()" mode="titleh6"/>
<xsl:variable name="currentSectionTitle" select="." /> </h6>
<xsl:variable name="currentSectionTitle" select="."/>
<!-- Text of h6 is contained between current h6 and next section title (next h3/h4/h5/h6) --> <!-- Text of h6 is contained between current h6 and next section title (next h3/h4/h5/h6) -->
<xsl:for-each select="following-sibling::* intersect following-sibling::h2[1]/preceding-sibling::*"> <xsl:for-each
<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)"> 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:apply-templates select="." mode="textOnly"/> <xsl:apply-templates select="." mode="textOnly"/>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
...@@ -149,12 +169,12 @@ ...@@ -149,12 +169,12 @@
</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>
</xsl:template> </xsl:template>
<!-- Paragraph template --> <!-- Paragraph template -->
<xsl:template match="p"> <xsl:template match="p">
<div> <div>
...@@ -163,121 +183,151 @@ ...@@ -163,121 +183,151 @@
</xsl:element> </xsl:element>
</div> </div>
</xsl:template> </xsl:template>
<!-- li --> <!-- li -->
<xsl:template match="li" mode="#all"> <xsl:template match="li" mode="#all">
<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">
<p><xsl:apply-templates select="node()" mode="textOnly"/></p>
<p>
<xsl:apply-templates select="node()" mode="textOnly"/>
</p>
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<!--Gestion des images integrées dans le texte-->
<xsl:template match="li[@class='gallerybox']" mode="#all">
<xsl:element name="{local-name()}" namespace="http://www.utc.fr/ics/hdoc/xhtml">
<img src="./ressources/{translate(tokenize(.//img/@src, '/')[last()],'?%','_')}" alt="{.//img/@alt}"/>
</xsl:element>
</xsl:template>
<!-- text followed directly by ul not allowed in li --> <!-- text followed directly by ul not allowed in li -->
<xsl:template match="li[descendant::ul]" mode="#all"> <xsl:template match="li[descendant::ul]" mode="#all">
<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">
<p><xsl:apply-templates select="descendant::node() intersect descendant::ul[1]/preceding-sibling::node()" mode="textOnly"/></p> <p>
<xsl:apply-templates
select="descendant::node() intersect descendant::ul[1]/preceding-sibling::node()"
mode="textOnly"/>
</p>
<xsl:apply-templates select="descendant::ul" mode="textOnly"/> <xsl:apply-templates select="descendant::ul" mode="textOnly"/>
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<!-- dl/dt/dd in each in a div --> <!-- dl/dt/dd in each in a div -->
<xsl:template match="dl[descendant::dt]" mode="#all"> <xsl:template match="dl[descendant::dt]" mode="#all">
<ul><xsl:apply-templates select="dt"/></ul> <ul>
<xsl:apply-templates select="dt"/>
</ul>
</xsl:template> </xsl:template>
<xsl:template match="dl[not(descendant::dt)]" mode="#all"> <xsl:template match="dl[not(descendant::dt)]" mode="#all">
<xsl:apply-templates select="dd"/> <xsl:apply-templates select="dd"/>
</xsl:template> </xsl:template>
<!-- dt contains the title --> <!-- dt contains the title -->
<xsl:template match="dt"> <xsl:template match="dt">
<li> <li>
<p><em><xsl:apply-templates select="node()" mode="titleh6"/></em></p> <p>
<em>
<xsl:apply-templates select="node()" mode="titleh6"/>
</em>
</p>
<!-- Some dt are followed by multiple dd before next dd: make sure to copy text of each dd before next dt --> <!-- Some dt are followed by multiple dd before next dd: make sure to copy text of each dd before next dt -->
<xsl:variable name="currentElement" select="."/> <xsl:variable name="currentElement" select="."/>
<xsl:apply-templates select="following-sibling::dd[preceding-sibling::dt[1] intersect $currentElement]"/> <xsl:apply-templates
select="following-sibling::dd[preceding-sibling::dt[1] intersect $currentElement]"/>
<!-- Some wikipedia articles don't use dd after dt... --> <!-- Some wikipedia articles don't use dd after dt... -->
<xsl:if test="not(following-sibling::dd[1])"> <xsl:if test="not(following-sibling::dd[1])">
<xsl:apply-templates select="../following-sibling::p[1]" mode="textOnly"/> <xsl:apply-templates select="../following-sibling::p[1]" mode="textOnly"/>
</xsl:if> </xsl:if>
</li> </li>
</xsl:template> </xsl:template>
<!-- dd contains the content --> <!-- dd contains the content -->
<xsl:template match="dd"> <xsl:template match="dd">
<p><xsl:apply-templates select="node()"/></p> <p>
<xsl:apply-templates select="node()"/>
</p>
<xsl:apply-templates select="ul|ol" mode="textOnly"/> <xsl:apply-templates select="ul|ol" mode="textOnly"/>
</xsl:template> </xsl:template>
<!-- Rules for title elements (h1, h2...) --> <!-- Rules for title elements (h1, h2...) -->
<xsl:template match="*" mode="title"> <xsl:template match="*" mode="title">
<xsl:apply-templates select="node()" mode="title"/> <xsl:apply-templates select="node()" mode="title"/>
</xsl:template> </xsl:template>
<xsl:template match="*" mode="titleh6" priority="2"> <xsl:template match="*" mode="titleh6" priority="2">
<xsl:value-of select="."/> <xsl:value-of select="."/>
</xsl:template> </xsl:template>
<xsl:template match="b" mode="textOnly"> <xsl:template match="b" mode="textOnly">
<!-- b is not allowed, however em is allowed: replacing all b by em --> <!-- b is not allowed, however em is allowed: replacing all b by em -->
<xsl:element name="em" namespace="http://www.utc.fr/ics/hdoc/xhtml"> <xsl:element name="em" 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>
</xsl:template> </xsl:template>
<!-- b outside p, wrap it into a p (and convert it to em) --> <!-- b outside p, wrap it into a p (and convert it to em) -->
<xsl:template match="b[not(ancestor::p) and not(ancestor::li) and not(ancestor::a)]" mode="textOnly"> <xsl:template match="b[not(ancestor::p) and not(ancestor::li) and not(ancestor::a)]"
<p><em><xsl:apply-templates select="node()" mode="textOnly"/></em></p> mode="textOnly">
<p>
<em>
<xsl:apply-templates select="node()" mode="textOnly"/>
</em>
</p>
</xsl:template> </xsl:template>
<!-- Link elements --> <!-- Link elements -->
<!-- a in title not allowed, only keeping text --> <!-- a in title not allowed, only keeping text -->
<xsl:template match="h2/span/a | h3/span/a | h4/span/a | h5/span/a | h6/span/a" mode="#all"> <xsl:template match="h2/span/a | h3/span/a | h4/span/a | h5/span/a | h6/span/a" mode="#all">
<xsl:value-of select="."/> <xsl:value-of select="."/>
</xsl:template> </xsl:template>
<xsl:template match="a" mode="#all"> <xsl:template match="a" mode="#all">
<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:attribute name="href" select="concat('http://wikipedia.org', @href)"/> <xsl:attribute name="href" select="concat('http://wikipedia.org', @href)"/>
<xsl:value-of select="."/> <xsl:value-of select="."/>
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<!-- Link elements without actual wikipedia page: keeping only their text --> <!-- Link elements without actual wikipedia page: keeping only their text -->
<xsl:template match="a[contains(@class, 'new')]" mode="#all"> <xsl:template match="a[contains(@class, 'new')]" mode="#all">
<xsl:value-of select="."/> <xsl:value-of select="."/>
</xsl:template> </xsl:template>
<!-- Handle Listing --> <!-- Handle Listing -->
<xsl:template match="div[@class='mw-highlight mw-content-ltr']" mode="textOnly"> <xsl:template match="div[@class='mw-highlight mw-content-ltr']" mode="textOnly">
<xsl:apply-templates select="pre" mode="textOnly"/> <xsl:apply-templates select="pre" mode="textOnly"/>
</xsl:template> </xsl:template>
<xsl:template match="pre" mode="textOnly"> <xsl:template match="pre" mode="textOnly">
<xsl:variable name="vUid"> <xsl:variable name="vUid">
<xsl:number level="any" count="pre"/> <xsl:number level="any" count="pre"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="listingContent"> <xsl:variable name="listingContent">
<xsl:copy-of select="@*|node()"/> <xsl:copy-of select="@*|node()"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="listingContentWithoutBadCharacters"> <xsl:variable name="listingContentWithoutBadCharacters">
<xsl:copy-of select="replace($listingContent,'&amp;','&amp;amp;')"/> <xsl:copy-of select="replace($listingContent,'&amp;','&amp;amp;')"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="listingContent2"> <xsl:variable name="listingContent2">
<xsl:value-of select="substring-after($listingContentWithoutBadCharacters,'&#10;')"/> <xsl:value-of select="substring-after($listingContentWithoutBadCharacters,'&#10;')"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="basename"> <xsl:variable name="basename">
<xsl:call-template name="substring-before-last"> <xsl:call-template name="substring-before-last">
<xsl:with-param name="string1" select="$listingContent2" /> <xsl:with-param name="string1" select="$listingContent2"/>
<xsl:with-param name="string2" select="'&#10;'" /> <xsl:with-param name="string2" select="'&#10;'"/>
</xsl:call-template> </xsl:call-template>
</xsl:variable> </xsl:variable>
<object type="application/x-listing" data="listing/listing{$vUid}.xml"> <!--Modifier le application/pdf lorsque le rng sera changé--> <object type="application/x-listing" data="listing/listing{$vUid}.xml">
<!--Modifier le application/pdf lorsque le rng sera changé-->
<xsl:result-document href="listing/listing{$vUid}.xml" method="text"> <xsl:result-document href="listing/listing{$vUid}.xml" method="text">
<xsl:text disable-output-escaping="no"> <xsl:text disable-output-escaping="no">
&lt;sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"&gt; &lt;sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"&gt;
...@@ -291,144 +341,160 @@ ...@@ -291,144 +341,160 @@
</xsl:result-document> </xsl:result-document>
</object> </object>
</xsl:template> </xsl:template>
<xsl:template name="substring-before-last"> <xsl:template name="substring-before-last">
<xsl:param name="string1" select="''" /> <xsl:param name="string1" select="''"/>
<xsl:param name="string2" select="''" /> <xsl:param name="string2" select="''"/>
<xsl:if test="$string1 != '' and $string2 != ''"> <xsl:if test="$string1 != '' and $string2 != ''">
<xsl:variable name="head" select="substring-before($string1, $string2)" /> <xsl:variable name="head" select="substring-before($string1, $string2)"/>
<xsl:variable name="tail" select="substring-after($string1, $string2)" /> <xsl:variable name="tail" select="substring-after($string1, $string2)"/>
<xsl:value-of select="$head" /> <xsl:value-of select="$head"/>
<xsl:if test="contains($tail, $string2)"> <xsl:if test="contains($tail, $string2)">
<xsl:value-of select="$string2" /> <xsl:value-of select="$string2"/>
<xsl:call-template name="substring-before-last"> <xsl:call-template name="substring-before-last">
<xsl:with-param name="string1" select="$tail" /> <xsl:with-param name="string1" select="$tail"/>
<xsl:with-param name="string2" select="$string2" /> <xsl:with-param name="string2" select="$string2"/>
</xsl:call-template> </xsl:call-template>
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<!-- Simple Tables --> <!-- Simple Tables -->
<xsl:template match="table" mode="textOnly"> <xsl:template match="table" mode="textOnly">
<xsl:choose> <xsl:choose>
<!-- Tables that doesn't contain colspan, rowspan or included tables --> <!-- Tables that doesn't contain colspan, rowspan or included tables -->
<xsl:when test="not(descendant::td/@colspan | descendant::td/@rowspan | descendant::table)"> <xsl:when
test="not(descendant::td/@colspan | descendant::td/@rowspan | descendant::table)">
<table> <table>
<xsl:apply-templates select="node()" mode="textOnly"/> <xsl:apply-templates select="node()" mode="textOnly"/>
</table> </table>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:call-template name="TableComplexe"/> <xsl:call-template name="TableComplexe"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<!-- Complexe Tables : create extern Ods files and copy content in it--> <!-- Complexe Tables : create extern Ods files and copy content in it-->
<xsl:template name="TableComplexe"> <xsl:template name="TableComplexe">
<xsl:variable name="tableId"> <xsl:variable name="tableId">
<xsl:number level="any" count="table"/> <xsl:number level="any" count="table"/>
</xsl:variable>