View File | Revision Log | Show Annotations | Download File | View Changeset
/hippo/hippo-documentation/hst_docs/trunk/scripts/basic2doc.xsl
Revision: 21417
Committed: Tue Jan 26 17:00:05 2010 UTC (10 years, 5 months ago) by rbijlsma
Content type: application/xml
File size: 7395 byte(s)
Log Message:
HSTTWODOCS-242

File Contents

# Content
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 NAME
4 :: Transform a wiki page (after tidy to xhtml), to a readable form of the Hippo XML format.
5
6 DATA
7 Author: R.Bijlsma
8 -->
9
10 <!--
11 TODO In the wiki wordt tt gebruikt voor code, waarom niet code?
12 Misschien een foutje van iemand? Of is het standaard?
13 -->
14
15 <!-- choose version 1.0, 1.1? or 2.0 -->
16 <xsl:transform version='1.0'
17 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
18 xmlns:xs="http://www.w3.org/2001/XMLSchema"
19 xmlns:s='http://www.scholarita.org/structure'
20 xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
21 xmlns:docs="http://www.hippoecm.org/nt/docs/1.2"
22 xmlns:jcr="http://www.jcp.org/jcr/1.0"
23 xmlns:hippostd="http://www.onehippo.org/jcr/hippostd/nt/2.0"
24 xmlns:hippo="http://www.onehippo.org/jcr/hippo/nt/2.0"
25 xmlns:h='http://www.w3.org/1999/xhtml'
26 >
27
28
29 <xsl:param name='filename' select='"unnamed_doc"'/>
30 <xsl:variable name='docname' select='translate($filename, "+", "_")'/>
31
32
33 <xsl:output
34 method="xml"
35 encoding="UTF-8"
36 indent="yes"
37 />
38
39
40 <!-- _______________________________________________________-->
41 <xsl:template match="h:*" mode='value'>
42 <xsl:variable name='name' select='concat("h:", local-name())'/>
43 <xsl:element name='{$name}'>
44 <xsl:apply-templates select='@*|node()' mode='value'/>
45 </xsl:element>
46 </xsl:template>
47
48
49 <!-- _______________________________________________________-->
50 <xsl:template name="fulldoc">
51 <xsl:param name='name' select='$docname'/>
52 <xsl:param name='title' select='h:h1/h:a/node()'/>
53
54 <xsl:if test='count($title)!=1'>
55 <xsl:message>
56 Error: Wrong number of document titles: <xsl:value-of select='count($title)'/>!
57 </xsl:message>
58 </xsl:if>
59
60 <xsl:element name='{$name}'>
61 <xsl:attribute name='jcr:primaryType'>hippo:handle</xsl:attribute>
62 <xsl:attribute name='jcr:mixinTypes'>hippo:hardhandle</xsl:attribute>
63 <xsl:attribute name='jcr:uuid'>412ca52e-dc7e-4969-b9fe-89411bb48b93</xsl:attribute>
64 <s:list elem="property"/>
65 <xsl:element name='{$name}'>
66 <xsl:attribute name='hippostd:holder'>admin</xsl:attribute> <!-- TODO Verander naar wiki? Als rest gelukt. -->
67 <xsl:attribute name='hippostd:state'>unpublished</xsl:attribute>
68 <xsl:attribute name='hippostd:stateSummary'>new</xsl:attribute>
69 <xsl:attribute name='jcr:primaryType'>docs:full</xsl:attribute>
70 <xsl:attribute name='jcr:mixinTypes'>hippo:harddocument</xsl:attribute>
71 <xsl:attribute name='jcr:uuid'>5c04ef5f-1006-4692-9974-c2b00826936a</xsl:attribute>
72 <s:list elem="property">
73 <docs:audience count='any'/>
74 <docs:component count='any'/>
75 <docs:difficulty>@empty@</docs:difficulty>
76 <docs:expire_version>@empty@</docs:expire_version>
77 <docs:new_in_version>@empty@</docs:new_in_version>
78 <docs:title><xsl:apply-templates mode='title' select='$title'/></docs:title> <!-- TODO: if not found, then no @empty@ so no sv:value, so is invalid in jcr. Now added space. -->
79 <docs:type>Howto</docs:type>
80 <docs:written_for_version>@empty@</docs:written_for_version>
81 </s:list>
82 <docs:short_description/>
83 <docs:goal>
84 <xsl:for-each select='docs:goal'>
85 <xsl:apply-templates mode='value'/>
86 </xsl:for-each>
87 </docs:goal>
88 <docs:intro>
89 <h:html><h:body>
90 <xsl:for-each select='key("sectioncontent", generate-id(h:h2[text()="Introduction"][1]))'>
91 <xsl:apply-templates/>
92 </xsl:for-each>
93 </h:body></h:html>
94 </docs:intro>
95 <xsl:variable name='sectiontitles' select='h:h2[text()!="Introduction"]'/>
96 <xsl:for-each select='$sectiontitles'>
97 <docs:section jcr:primaryType="docs:section">
98 <s:list elem="property">
99 <docs:title><xsl:apply-templates mode='title' select='*[not(self::a)]|text()'/></docs:title> <!-- Added space -->
100 <docs:todo/>
101 </s:list>
102 <docs:intro/>
103 <!--
104 <docs:one_step jcr:primaryType="docs:step">
105 <s:list elem="property">
106 <docs:category>category</docs:category>
107 <docs:name>Step name</docs:name>
108 </s:list>
109 <docs:icon jcr:primaryType="hippo:facetselect" hippo:docbase="d6f70acd-3f4d-4943-b1f1-dd3c6a599937" hippo:facets="" hippo:modes="" hippo:values="">
110 <s:list elem="property"/>
111 </docs:icon>
112 <docs:explanation><h:html><h:body>TODO</h:body></h:html></docs:explanation>
113 </docs:one_step>
114 <docs:one_screenshot jcr:primaryType="docs:screenshot">
115 <s:list elem="property">
116 <docs:alt>@empty@</docs:alt>
117 <docs:bottompx>@empty@</docs:bottompx>
118 <docs:heightpx>@empty@</docs:heightpx>
119 <docs:leftpx>@empty@</docs:leftpx>
120 <docs:new_in_version>@empty@</docs:new_in_version>
121 <docs:toppx>@empty@</docs:toppx>
122 <docs:widthpx>@empty@</docs:widthpx>
123 </s:list>
124 <docs:imagelink jcr:primaryType="hippo:facetselect" hippo:docbase="cafebabe-cafe-babe-cafe-babecafebabe" hippo:facets="" hippo:modes="" hippo:values="">
125 <s:list elem="property"/>
126 </docs:imagelink>
127 <docs:caption><h:html><h:body>TODO</h:body></h:html></docs:caption>
128 </docs:one_screenshot>
129 -->
130 <docs:closing><h:html><h:body>
131 <xsl:apply-templates mode='value' select='key("sectioncontent", generate-id(.))'/>
132 </h:body></h:html></docs:closing>
133 </docs:section>
134 </xsl:for-each>
135
136 <!--
137 <docs:next jcr:primaryType="docs:link">
138 <s:list elem="property">
139 <docs:description>Next document description</docs:description>
140 <docs:url>@empty@</docs:url>
141 </s:list>
142 <docs:documentlink jcr:primaryType="hippo:facetselect" hippo:docbase="cafebabe-cafe-babe-cafe-babecafebabe" hippo:facets="" hippo:modes="" hippo:values="">
143 <s:list elem="property"/>
144 </docs:documentlink>
145 </docs:next>
146 <docs:alternative jcr:primaryType="docs:link">
147 <s:list elem="property">
148 <docs:description>Alternative document description</docs:description>
149 <docs:url>@empty@</docs:url>
150 </s:list>
151 <docs:documentlink jcr:primaryType="hippo:facetselect" hippo:docbase="cafebabe-cafe-babe-cafe-babecafebabe" hippo:facets="" hippo:modes="" hippo:values="">
152 <s:list elem="property"/>
153 </docs:documentlink>
154 </docs:alternative>
155 -->
156 </xsl:element>
157 </xsl:element>
158 </xsl:template>
159
160 <!-- _______________________________________________________ -->
161 <xsl:template match="@*|*">
162 <xsl:message>
163 ERROR: What to do with the node:
164 <xsl:for-each select='ancestor-or-self::*'>
165 <xsl:value-of select='name()'/>
166 <xsl:if test='position()!=last()'>.</xsl:if>
167 </xsl:for-each>?
168 </xsl:message>
169 </xsl:template>
170
171
172 <!-- _______________________________________________________ -->
173 <xsl:template match='text()[not(ancestor::p) and normalize-space(.)=""]' mode='value'>
174 </xsl:template>
175
176 <!-- _______________________________________________________ -->
177 <xsl:template match="@*|node()[not(self::*)]" mode='value'>
178 <xsl:copy/>
179 </xsl:template>
180
181
182 <!-- _______________________________________________________ -->
183 <xsl:template match="*" mode='value'>
184 <xsl:copy>
185 <xsl:apply-templates select="@*|node()" mode='value'/>
186 </xsl:copy>
187 </xsl:template>
188
189 <!-- _______________________________________________________ -->
190 </xsl:transform>
191

Properties

Name Value
svn:eol-style native
svn:keywords Id