View File | Revision Log | Show Annotations | Download File | View Changeset
/hippo/hippo-documentation/hst_docs/trunk/scripts/jcr2doc.xsl
Revision: 21317
Committed: Thu Jan 14 17:03:06 2010 UTC (10 years, 5 months ago) by rbijlsma
Content type: application/xml
File size: 4469 byte(s)
Log Message:
HSTTWODOCS-242

File Contents

# Content
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 NAME
4
5 DATA
6 Author: R.Bijlsma
7 -->
8
9 <!-- choose version 1.0, 1.1? or 2.0 -->
10 <xsl:transform version='1.0'
11 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
12 xmlns:xs="http://www.w3.org/2001/XMLSchema"
13 xmlns:s='http://www.scholarita.org/structure'
14 xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
15 xmlns:docs="http://www.hippoecm.org/nt/docs/1.2"
16 xmlns:jcr="http://www.jcp.org/jcr/1.0"
17 xmlns:hippostd="http://www.onehippo.org/jcr/hippostd/nt/2.0"
18 xmlns:hippo="http://www.onehippo.org/jcr/hippo/nt/2.0"
19 xmlns:h='http://www.w3.org/1999/xhtml'
20 >
21
22 <xsl:output
23 method="xml"
24 encoding="UTF-8"
25 indent="yes"
26 />
27
28 <!-- __________________________________________________________________________________________ -->
29 <xsl:template match="/">
30 <s:list elem='document'>
31 <xsl:apply-templates/>
32 </s:list>
33 </xsl:template>
34
35 <!-- ___________________________________________________________________________________________ -->
36 <xsl:template match='sv:node[sv:property[@sv:name="jcr:primaryType"]/sv:value="hippostd:html"]'>
37
38 <xsl:variable name='name' select='@sv:name'/>
39 <xsl:element name='{$name}'>
40 <xsl:value-of select='sv:property[@sv:name="hippostd:content"]/sv:value'/>
41 </xsl:element>
42
43 </xsl:template>
44
45 <!-- ___________________________________________________________________________________________ -->
46 <xsl:template match="sv:property">
47 <xsl:variable name='name' select='@sv:name'/>
48 <xsl:element name='{$name}'>
49 <xsl:apply-templates select='@*[not(name()="sv:name" or (name()="sv:type" and .="String")) ]'/>
50 <xsl:choose>
51 <xsl:when test='count(sv:value)&gt;1'>
52 <xsl:for-each select='sv:value'>
53 <xsl:copy-of select='.'/>
54 </xsl:for-each>
55 </xsl:when>
56 <xsl:when test='sv:value=""'>
57 <xsl:text>@empty@</xsl:text>
58 </xsl:when>
59 <xsl:otherwise>
60 <xsl:value-of select='sv:value'/>
61 </xsl:otherwise>
62 </xsl:choose>
63 </xsl:element>
64 </xsl:template>
65
66 <!-- ____________________________________________________________________________________________ -->
67 <xsl:template name="property2attrib">
68 <xsl:variable name='attribname' select='@sv:name'/>
69 <xsl:variable name='sep'>
70 <xsl:choose>
71 <xsl:when test='sv:value[contains(., "; ")]'><xsl:text>:; </xsl:text>
72 <xsl:if test='sv:value[contains(., ":; ")]'>
73 <xsl:message terminate="yes" >
74 ERROR: property value contains '; ' as well as ':; '. Split using other separator not implemented.
75 </xsl:message>
76 </xsl:if>
77 </xsl:when>
78 <xsl:otherwise>; </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
81 <xsl:attribute name='{$attribname}'>
82 <xsl:for-each select='sv:value'>
83 <xsl:choose>
84 <xsl:when test='.=""'>@empty@</xsl:when>
85 <xsl:otherwise><xsl:value-of select='.'/></xsl:otherwise>
86 </xsl:choose>
87 <xsl:if test='position()!=last()'><xsl:value-of select='$sep'/></xsl:if>
88 </xsl:for-each>
89 </xsl:attribute>
90 </xsl:template>
91
92 <!-- ___________________________________________________________________________________________ -->
93 <xsl:template match="sv:node">
94 <xsl:variable name='name' select='@sv:name'/>
95 <xsl:element name='{$name}'>
96 <xsl:apply-templates select='@*[not(name()="sv:name")]'/>
97 <xsl:for-each select='sv:property[@sv:name="hippostd:state" or @sv:name="hippostd:stateSummary" or @sv:name="hippostd:holder" ]'>
98 <xsl:call-template name='property2attrib'/>
99 </xsl:for-each>
100 <xsl:for-each select='sv:property[starts-with(@sv:name, "jcr:") or starts-with(@sv:name, "hippo:") ]'>
101 <xsl:call-template name='property2attrib'/>
102 </xsl:for-each>
103 <s:list elem='property'>
104 <xsl:apply-templates select='sv:property[not(starts-with(@sv:name, "jcr:") or starts-with(@sv:name, "hippo:") or @sv:name="hippostd:state" or @sv:name="hippostd:stateSummary" or @sv:name="hippostd:holder" ) ]'/>
105 </s:list>
106 <xsl:apply-templates select='*[not(self::sv:property)]'/>
107 </xsl:element>
108 </xsl:template>
109
110 <!-- ___________________________________________________________________________________________ -->
111 <xsl:template match="@*|node()[not(self::*)]">
112 <xsl:copy/>
113 </xsl:template>
114
115 <!-- ____________________________________________________________________________________________ -->
116 <xsl:template match="*">
117 <xsl:copy>
118 <xsl:apply-templates select="@*|node()"/>
119 </xsl:copy>
120 </xsl:template>
121
122 <!-- ____________________________________________________________________________________________ -->
123 </xsl:transform>
124

Properties

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