find_content.xsl 2.21 KB
Newer Older
1
2
<?xml version="1.0" encoding="UTF-8"?>
<!--find_content.xsl creates a ANT file prepare_hdoc.ant-->
3
<xsl:stylesheet
4
5
6
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:h="urn:utc.fr:ics:hdoc:container"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
7
8
9
10

	<xsl:param name="BaseDirectory" required="yes" as="xs:string"/>
  <xsl:param name="TempDirectory" required="yes" as="xs:string"/>

11
    <xsl:output method="xml" indent="yes"/>
12

13
    <xsl:template match="h:container">
14
        <project name="hdoc_to_pdf" basedir=".." default="main">
15
16
17
18
19
            <target name="main">
                <xsl:apply-templates/>
            </target>
        </project>
    </xsl:template>
20

21
22
23
    <xsl:template match="h:rootfiles">
        <xsl:apply-templates/>
    </xsl:template>
24

25
26
27
    <xsl:template match="h:rootfile">
        <xsl:variable name="path" select="@full-path"/>

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
        <xsl:analyze-string select="$path" regex="\.?[-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+)?$">
            <xsl:matching-substring>
            <echo message="MATCHING TEST  :"/>
            <echo>
                <xsl:attribute name="message"><xsl:value-of select="."/></xsl:attribute>
            </echo>
            <xsl:variable name="filename">
                <xsl:value-of select="."/>
            </xsl:variable>

            <xsl:variable name="dirpath" select="concat($TempDirectory, '/', substring($path, 1, string-length($path) - string-length($filename) - 1))"/>

            <echo message="Path : {$path}"/>
            <echo message="Filename : {$filename}"/>
            <echo message="Dirpath : {$dirpath}"/>

            <copy file="{$BaseDirectory}/css/main.css" tofile="{$dirpath}/main.css"/>

            <xslt in="{$TempDirectory}/{$path}" out="{$TempDirectory}/hdoc_nsless.xhtml" style="xsl/ns_remover.xsl" classpath="./lib/saxon9he.jar"/>
            <xslt in="{$TempDirectory}/hdoc_nsless.xhtml" out="{$TempDirectory}/flat_hdoc.xhtml" style="xsl/hdoc_flattenizer.xsl" classpath="./lib/saxon9he.jar"/>
            <xslt in="{$TempDirectory}/flat_hdoc.xhtml" out="{$TempDirectory}/final.xhtml" style="xsl/last_transformer.xsl" classpath="./lib/saxon9he.jar"/>

            </xsl:matching-substring>
        </xsl:analyze-string>

53
54
    </xsl:template>
</xsl:stylesheet>