Added history to document view
[redakcja.git] / platforma / static / xsl / html2wl_client.xsl
1 <xsl:stylesheet \r
2     version="1.0"\r
3 \r
4     xmlns:html="http://www.w3.org/1999/xhtml"\r
5     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
6     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\r
7     xmlns:dc="http://purl.org/dc/elements/1.1/"\r
8 >\r
9 \r
10     <xsl:output method="xml" encoding="utf-8" indent="no" omit-xml-declaration="yes" />\r
11     <!--\r
12         Ten dokument definiuję przekształcenie odwrotne do wl2html\r
13     -->\r
14 \r
15     <xsl:template match="comment()"><xsl:copy /></xsl:template>\r
16 \r
17     <!-- libxslt has fuck-ed prorities -->\r
18     <!-- <xsl:template match="@*[not(starts-with(name(), 'x-')) and name() != 'class']">\r
19         <xsl:message>Boom!: <xsl:value-of select="name()" /></xsl:message>\r
20     </xsl:template> -->\r
21 \r
22     <xsl:template match="@*" priority="0" />\r
23 \r
24     <!-- Specjalne reguły dla przypisów -->\r
25     <xsl:template match="*[@x-annotation-box]|*[@class='theme-text-list']">\r
26         <xsl:apply-templates select="node()" />\r
27     </xsl:template>\r
28 \r
29     <xsl:template match="*[@x-node]">\r
30         <xsl:element name="{@x-node}" namespace="{@x-ns}">\r
31             <xsl:apply-templates select="@*" />\r
32             <xsl:apply-templates select="node()" />\r
33         </xsl:element>\r
34     </xsl:template>   \r
35         \r
36         <xsl:template match="*[@x-node = 'out-of-flow-text']">\r
37                 <xsl:apply-templates select="child::node()" />\r
38         </xsl:template>\r
39 \r
40     <xsl:template match="*[@x-node = 'out-of-flow-text']/text()"><xsl:value-of select="." /></xsl:template>\r
41 \r
42     <!-- Specjalne reguły dla wersów -->\r
43     <xsl:template match="*[@x-node = 'wers']">\r
44         <xsl:apply-templates select="node()" />\r
45         <xsl:if test="count(following-sibling::*[starts-with(@x-node, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
46     </xsl:template>\r
47 \r
48     <xsl:template match="*[starts-with(@x-node, 'wers_')]">\r
49         <xsl:element name="{@x-node}" namespace="{@x-ns}"><xsl:apply-templates select="@*|node()" /></xsl:element>\r
50         <xsl:if test="count(following-sibling::*[starts-with(@x-node, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
51     </xsl:template>\r
52     \r
53     <xsl:template match="@*[starts-with(name(), 'x-attr-qname-')]">\r
54         <xsl:variable name="attr-id" select="substring-after(name(), 'x-attr-qname-')" />\r
55         <xsl:attribute name="{.}" namespace="{parent::*/@*[name() = concat('x-attr-ns-', $attr-id)]}">\r
56             <xsl:value-of select="parent::*/@*[name() = concat('x-attr-value-', $attr-id)]" />\r
57         </xsl:attribute>\r
58     </xsl:template>\r
59 \r
60     <!-- upper case duplicates for the brain-dead Firefox -->\r
61 \r
62     <xsl:template match="@*[starts-with(name(), 'X-ATTR-QNAME-')]">\r
63         <xsl:variable name="attr-id" select="substring-after(name(), 'X-ATTR-QNAME-')" />\r
64         <xsl:attribute name="{.}" namespace="{parent::*/@*[name() = concat('X-ATTR-NS-', $attr-id)]}">\r
65             <xsl:value-of select="parent::*/@*[name() = concat('X-ATTR-VALUE-', $attr-id)]" />\r
66         </xsl:attribute>\r
67     </xsl:template>\r
68 \r
69     <xsl:template match="*[@X-ANNOTATION-BOX]">\r
70         <xsl:apply-templates select="node()" />\r
71     </xsl:template>\r
72 \r
73     <xsl:template match="*[@X-NODE]">\r
74         <xsl:element name="{@X-NODE}" namespace="{@X-NS}">\r
75             <xsl:apply-templates select="@*" />\r
76             <xsl:apply-templates select="node()" />\r
77         </xsl:element>\r
78     </xsl:template>   \r
79         \r
80         <xsl:template match="*[@X-NODE = 'out-of-flow-text']" priority="1">\r
81                 <xsl:apply-templates select="child::node()" />\r
82         </xsl:template>\r
83     \r
84     <xsl:template match="*[@X-NODE = 'out-of-flow-text']/text()"><xsl:value-of select="." /></xsl:template>\r
85 \r
86     <!-- Specjalne reguły dla wersów -->\r
87     <xsl:template match="*[@X-NODE = 'wers']">\r
88         <xsl:apply-templates select="node()" />\r
89         <xsl:if test="count(following-sibling::*[starts-with(@X-NODE, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
90     </xsl:template>\r
91 \r
92     <xsl:template match="*[starts-with(@X-NODE, 'wers_')]">\r
93         <xsl:element name="{@X-NODE}" namespace="{@X-NS}"><xsl:apply-templates select="@*|node()" /></xsl:element>\r
94         <xsl:if test="count(following-sibling::*[starts-with(@X-NODE, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
95     </xsl:template>\r
96         \r
97     <xsl:template match="*" />\r
98         \r
99     \r
100 </xsl:stylesheet>