Zapis na serwer na Gecko/Webkit/Opera.
[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="yes"/>\r
11     <!--\r
12         Ten dokument definiuję przekształcenie odwrotne do wl2html\r
13     -->\r
14 \r
15 \r
16     <xsl:template match="comment()"><xsl:copy /></xsl:template>\r
17 \r
18     <!-- libxslt has fuck-ed prorities -->\r
19     <!-- <xsl:template match="@*[not(starts-with(name(), 'x-')) and name() != 'class']">\r
20         <xsl:message>Boom!: <xsl:value-of select="name()" /></xsl:message>\r
21     </xsl:template> -->\r
22 \r
23     <xsl:template match="@*" priority="0" />\r
24 \r
25     <!-- Specjalne reguły dla przypisów -->\r
26     <xsl:template match="*[@x-annotation-box]">\r
27         <xsl:apply-templates select="node()" />\r
28     </xsl:template>\r
29 \r
30     <xsl:template match="*[@x-node]">\r
31         <xsl:element name="{@x-node}" namespace="{@x-ns}">\r
32             <xsl:apply-templates select="@*" />\r
33             <xsl:apply-templates select="node()" />\r
34         </xsl:element>\r
35     </xsl:template>   \r
36 \r
37     <xsl:template match="*[@x-node = 'out-of-flow-text']"><xsl:value-of select="@x-content" /></xsl:template>\r
38 \r
39     <!-- Specjalne reguły dla wersów -->\r
40     <xsl:template match="*[@x-node = 'wers']">\r
41         <xsl:apply-templates select="node()" />\r
42         <xsl:if test="count(following-sibling::*[starts-with(@x-node, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
43     </xsl:template>\r
44 \r
45     <xsl:template match="*[starts-with(@x-node, 'wers_')]">\r
46         <xsl:element name="{@x-node}" namespace="{@x-ns}"><xsl:apply-templates select="@*|node()" /></xsl:element>\r
47         <xsl:if test="count(following-sibling::*[starts-with(@x-node, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
48     </xsl:template>\r
49     \r
50     <xsl:template match="@*[starts-with(name(), 'x-attr-qname-')]">\r
51         <xsl:variable name="attr-id" select="substring-after(name(), 'x-attr-qname-')" />\r
52         <xsl:attribute name="{.}" namespace="{parent::*/@*[name() = concat('x-attr-ns-', $attr-id)]}">\r
53             <xsl:value-of select="parent::*/@*[name() = concat('x-attr-value-', $attr-id)]" />\r
54         </xsl:attribute>\r
55     </xsl:template>\r
56 \r
57     <!-- upper case duplicates for the brain-dead Firefox -->\r
58 \r
59     <xsl:template match="@*[starts-with(name(), 'X-ATTR-QNAME-')]">\r
60         <xsl:variable name="attr-id" select="substring-after(name(), 'X-ATTR-QNAME-')" />\r
61         <xsl:attribute name="{.}" namespace="{parent::*/@*[name() = concat('X-ATTR-NS-', $attr-id)]}">\r
62             <xsl:value-of select="parent::*/@*[name() = concat('X-ATTR-VALUE-', $attr-id)]" />\r
63         </xsl:attribute>\r
64     </xsl:template>\r
65 \r
66     <xsl:template match="*[@X-ANNOTATION-BOX]">\r
67         <xsl:apply-templates select="node()" />\r
68     </xsl:template>\r
69 \r
70     <xsl:template match="*[@X-NODE]">\r
71         <xsl:element name="{@X-NODE}" namespace="{@X-NS}">\r
72             <xsl:apply-templates select="@*" />\r
73             <xsl:apply-templates select="node()" />\r
74         </xsl:element>\r
75     </xsl:template>\r
76 \r
77     <xsl:template match="*[@X-NODE = 'out-of-flow-text']"><xsl:value-of select="@X-CONTENT" /></xsl:template>\r
78 \r
79     <!-- Specjalne reguły dla wersów -->\r
80     <xsl:template match="*[@X-NODE = 'wers']">\r
81         <xsl:apply-templates select="node()" />\r
82         <xsl:if test="count(following-sibling::*[starts-with(@X-NODE, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
83     </xsl:template>\r
84 \r
85     <xsl:template match="*[starts-with(@X-NODE, 'wers_')]">\r
86         <xsl:element name="{@X-NODE}" namespace="{@X-NS}"><xsl:apply-templates select="@*|node()" /></xsl:element>\r
87         <xsl:if test="count(following-sibling::*[starts-with(@X-NODE, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
88     </xsl:template>\r
89 \r
90     \r
91     \r
92     <xsl:template match="*" />\r
93 </xsl:stylesheet>