1 | <?xml version="1.0"?> |
---|
2 | <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
3 | xmlns:diag="http://www.loc.gov/zing/srw/diagnostic"> |
---|
4 | |
---|
5 | <!-- |
---|
6 | <purpose>a (wannabe) robust/generic stylesheet to display "static" content (xml) as html. |
---|
7 | it shall operate on the internal xml-files, with special processing of some elements (mainly processing <a>-elements!)</purpose> |
---|
8 | <params> |
---|
9 | <param name=""></param> |
---|
10 | </params> |
---|
11 | <history> |
---|
12 | <change on="2011-09-01" type="created" by="vr">based on test2view</change> |
---|
13 | |
---|
14 | </history> |
---|
15 | --> |
---|
16 | |
---|
17 | <xsl:include href="cmd_commons.xsl"/> |
---|
18 | |
---|
19 | <!--<xsl:param name="title" select="if (//div[1][@class='title']) then concat('CMDRSB: ', //div[1][@class='title']) else 'CMDRSB docs'" />--> |
---|
20 | <xsl:param name="title" select="if (//div[1][@class='title']) then //div[1][@class='title'] else ''" /> |
---|
21 | |
---|
22 | |
---|
23 | <!--<xsl:output method="html" encoding="UTF-8"/>--> |
---|
24 | |
---|
25 | <xsl:template name="continue-root"> |
---|
26 | <xsl:apply-templates /> |
---|
27 | </xsl:template> |
---|
28 | |
---|
29 | <xsl:template match="a[contains(@class,'template')]"> |
---|
30 | |
---|
31 | <xsl:choose> |
---|
32 | <xsl:when test="@href='query-input'"> |
---|
33 | <xsl:call-template name="query-input" /> |
---|
34 | </xsl:when> |
---|
35 | <xsl:when test="@href='query-list'"> |
---|
36 | <xsl:call-template name="query-list" /> |
---|
37 | </xsl:when> |
---|
38 | <xsl:when test="@href='detail-space'"> |
---|
39 | <xsl:call-template name="detail-space" /> |
---|
40 | </xsl:when> |
---|
41 | <xsl:when test="@href='public-space'"> |
---|
42 | <xsl:call-template name="public-space" /> |
---|
43 | </xsl:when> |
---|
44 | <xsl:when test="@href='user-space'"> |
---|
45 | <xsl:call-template name="user-space" /> |
---|
46 | </xsl:when> |
---|
47 | <xsl:otherwise> |
---|
48 | <xsl:copy-of select="." /> |
---|
49 | </xsl:otherwise> |
---|
50 | </xsl:choose> |
---|
51 | </xsl:template> |
---|
52 | |
---|
53 | <xsl:template match="a[contains(@class,'query') or contains(@class,'request')]"> |
---|
54 | |
---|
55 | <xsl:variable name="specific_prefix" select="if (contains(@href,'query')) then 'search/htmlpage/' else ''" /> |
---|
56 | |
---|
57 | <xsl:variable name="target_url" > |
---|
58 | <xsl:choose> |
---|
59 | <xsl:when test="@class='request count'"> |
---|
60 | <xsl:copy-of select="concat($base_url,@href)" /> |
---|
61 | </xsl:when> |
---|
62 | <xsl:when test="@class='query count'"> |
---|
63 | <xsl:copy-of select="concat($base_url, 'search/xml/', @href)" /> |
---|
64 | </xsl:when> |
---|
65 | <xsl:when test="@class='request'"> |
---|
66 | <xsl:copy-of select="concat($base_url, @href)" /> |
---|
67 | </xsl:when> |
---|
68 | |
---|
69 | <xsl:when test="@class='query'"> |
---|
70 | <xsl:copy-of select="concat($base_url, 'search/htmltable/', @href)" /> |
---|
71 | </xsl:when> |
---|
72 | <xsl:when test="starts-with(@href,'http:')"> |
---|
73 | <xsl:copy-of select="." /> |
---|
74 | </xsl:when> |
---|
75 | <!-- if it is just a simple a-element (not marked explicitly with 'request' or 'query' class, just pass it through - do not resolve--> |
---|
76 | <xsl:otherwise> |
---|
77 | <!-- <xsl:copy-of select="document(concat($base_url, @href))" />--> |
---|
78 | <xsl:copy-of select="." /> |
---|
79 | </xsl:otherwise> |
---|
80 | </xsl:choose> |
---|
81 | </xsl:variable> |
---|
82 | |
---|
83 | <xsl:variable name="data" > |
---|
84 | <xsl:choose> |
---|
85 | <xsl:when test="doc-available($target_url)" > |
---|
86 | <xsl:choose> |
---|
87 | <xsl:when test="contains(@class,'request') or contains(@class, 'query')"> |
---|
88 | <xsl:copy-of select="document($target_url)" /> |
---|
89 | </xsl:when> |
---|
90 | <xsl:otherwise > |
---|
91 | <xsl:copy-of select="." /> |
---|
92 | </xsl:otherwise> |
---|
93 | |
---|
94 | </xsl:choose> |
---|
95 | </xsl:when> |
---|
96 | <xsl:otherwise> |
---|
97 | <diagnostics> |
---|
98 | <diag:diagnostic> |
---|
99 | <diag:message>Document not available!</diag:message> |
---|
100 | </diag:diagnostic> |
---|
101 | </diagnostics> |
---|
102 | </xsl:otherwise> |
---|
103 | </xsl:choose> |
---|
104 | </xsl:variable> |
---|
105 | |
---|
106 | <div class="cmds-ui-block" > |
---|
107 | <xsl:if test="not(contains(@class,'no-header'))" > |
---|
108 | <div class="ui-widget-header"> |
---|
109 | <xsl:value-of select="@class" />: <xsl:copy-of select="." /> [<a href="{concat($base_url,$specific_prefix,@href)}" ><xsl:value-of select="@href" /></a>] |
---|
110 | </div> |
---|
111 | </xsl:if> |
---|
112 | |
---|
113 | <div class="ui-widget-content"> |
---|
114 | <xsl:choose> |
---|
115 | <xsl:when test="exists($data/diagnostics)"> |
---|
116 | <span class="error" > |
---|
117 | <xsl:value-of select="$data/diagnostics/diag:diagnostic/diag:message" /> |
---|
118 | </span> |
---|
119 | </xsl:when> |
---|
120 | <xsl:when test="@class='request count'"> |
---|
121 | root: <xsl:value-of select="$data/*/name()" />|<xsl:value-of select="count($data//*)" />| |
---|
122 | </xsl:when> |
---|
123 | <xsl:when test="@class='query count'"> |
---|
124 | <xsl:value-of select="$data//numberOfRecords" /> |
---|
125 | </xsl:when> |
---|
126 | |
---|
127 | <!-- <xsl:when test="@class='query'"> |
---|
128 | <xsl:variable name="data" select="document(concat($base_url,'recordset/htmltable/', @href))" /> |
---|
129 | <xsl:copy-of select="$data" /> |
---|
130 | </xsl:when> --> |
---|
131 | <xsl:otherwise> |
---|
132 | <!-- <xsl:apply-templates select="$data" mode="process-result"/>--> |
---|
133 | <xsl:copy-of select="$data" /> |
---|
134 | </xsl:otherwise> |
---|
135 | </xsl:choose> |
---|
136 | |
---|
137 | </div> |
---|
138 | </div> |
---|
139 | </xsl:template> |
---|
140 | |
---|
141 | <xsl:template match="*|@*"> |
---|
142 | <xsl:copy> |
---|
143 | <xsl:apply-templates select="node()|@*" /> |
---|
144 | </xsl:copy> |
---|
145 | </xsl:template> |
---|
146 | |
---|
147 | <xsl:template match="*|@*" mode="process-result" > |
---|
148 | <xsl:copy> |
---|
149 | <xsl:apply-templates select="node()|@*" mode="process-result" /> |
---|
150 | </xsl:copy> |
---|
151 | </xsl:template> |
---|
152 | |
---|
153 | <!-- |
---|
154 | <diagnostics> |
---|
155 | <diagnostic xmlns="http://www.loc.gov/zing/srw/diagnostic"> |
---|
156 | <uri>info:srw/diagnostic/1/1</uri> |
---|
157 | <message>Exception occurred: Connection refused: connect</message> |
---|
158 | --> |
---|
159 | <xsl:template match="diagnostics" mode="process-result" > |
---|
160 | <div class="error" > |
---|
161 | <xsl:value-of select="diag:diagnostic/diag:message" /> |
---|
162 | </div> |
---|
163 | </xsl:template> |
---|
164 | |
---|
165 | |
---|
166 | </xsl:stylesheet> |
---|
167 | |
---|