source: products/quintagroup.transmogrifier.simpleblog2quills/trunk/quintagroup/transmogrifier/simpleblog2quills/blogentry-document.xsl @ 1244

Last change on this file since 1244 was 612, checked in by crchemist, 17 years ago

reverting erroneous commit [368] (svn merge -r 368:367 http://svn/products/qPloneComments/tags/2.0)

File size: 3.8 KB
Line 
1<xsl:stylesheet version="1.0" 
2     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3     xmlns:at="http://plone.org/ns/archetypes/"
4     xmlns:cmf="http://cmf.zope.org/namespaces/default/"
5     xmlns:dc="http://purl.org/dc/elements/1.1/">
6
7<xsl:template match="/">
8    <xsl:for-each select="*">
9        <!-- matched 'metadata' element and we copy it -->
10        <xsl:copy select=".">
11            <xsl:for-each select="*|text()">
12                <xsl:choose>
13                    <!-- do some special with 'field' elements -->
14                    <xsl:when test="name()='field'">
15                        <xsl:apply-templates select="." />
16                    </xsl:when>
17                    <!-- change value of 'cmf:type' attribute -->
18                    <xsl:when test="name()='cmf:type'">
19                        <xsl:apply-templates select="." />
20                    </xsl:when>
21                    <!-- do some special with 'cmf:workflow_history' element -->
22                    <xsl:when test="name()='cmf:workflow_history'">
23                        <xsl:copy select=".">
24                            <xsl:apply-templates select="cmf:workflow" />
25                        </xsl:copy>
26                    </xsl:when>
27                    <!-- copy all other elements -->
28                    <xsl:otherwise>
29                        <xsl:copy-of select="."/>
30                    </xsl:otherwise>
31                </xsl:choose>
32            </xsl:for-each>
33        </xsl:copy>
34    </xsl:for-each>
35</xsl:template>
36
37<xsl:template match="at:field">
38    <xsl:choose>
39        <!-- next fields are omitted -->
40        <xsl:when test="@name='alwaysOnTop'" />
41        <xsl:when test="@name='sendTrackBackURLs'" />
42        <!-- change field's name attribute from 'body' to 'text' -->
43        <xsl:when test="@name='body'">
44            <xsl:copy select=".">
45                <xsl:attribute name="name">text</xsl:attribute>
46                <xsl:value-of select="." />
47            </xsl:copy>
48        </xsl:when>
49        <!-- change field's name attribute form 'categories' to 'subject' -->
50        <xsl:when test="@name='categories'">
51            <dc:subject>
52                <xsl:value-of select="."/>
53            </dc:subject>
54        </xsl:when>
55        <!-- copy all other elements -->
56        <xsl:otherwise>
57            <xsl:copy-of select="."/>
58        </xsl:otherwise>
59    </xsl:choose>
60</xsl:template>
61
62<xsl:template match="cmf:type">
63    <xsl:copy select=".">
64        <xsl:text>Document</xsl:text>
65    </xsl:copy>
66</xsl:template>
67
68<xsl:template match="cmf:workflow">
69    <xsl:copy select=".">
70        <!-- rename 'id' attribute -->
71        <xsl:attribute name="id">simple_publication_workflow</xsl:attribute>
72        <xsl:for-each select="*|text()">
73            <xsl:choose>
74                <!-- do some special with 'cmf:workflow_history' element -->
75                <xsl:when test="name()='cmf:history'">
76                    <xsl:copy select=".">
77                        <xsl:apply-templates select="cmf:var" />
78                    </xsl:copy>
79                </xsl:when>
80                <!-- copy all other elements -->
81                <xsl:otherwise>
82                    <xsl:copy-of select="."/>
83                </xsl:otherwise>
84            </xsl:choose>
85        </xsl:for-each>
86    </xsl:copy>
87</xsl:template>
88
89<xsl:template match="cmf:var">
90    <xsl:choose>
91        <xsl:when test="@value='draft'">
92            <xsl:copy select=".">
93                <xsl:attribute name="id">review_state</xsl:attribute>
94                <xsl:attribute name="type">str</xsl:attribute>
95                <xsl:attribute name="value">private</xsl:attribute>
96                <xsl:value-of select="." />
97            </xsl:copy>
98        </xsl:when>
99        <!-- copy all other elements -->
100        <xsl:otherwise>
101            <xsl:copy-of select="."/>
102        </xsl:otherwise>
103    </xsl:choose>
104</xsl:template>
105
106</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.