comparison software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/queryDocument.xsl @ 25:e9fe3186670c default tip

letzter Stand eingecheckt
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 21 May 2013 10:19:32 +0200
parents
children
comparison
equal deleted inserted replaced
23:e845310098ba 25:e9fe3186670c
1 <?xml version="1.0"?>
2
3 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
5 <xsl:output method="xhtml" encoding="utf-8"/>
6
7 <xsl:param name="query"></xsl:param>
8 <xsl:param name="flags"></xsl:param>
9 <xsl:param name="outputFormat"></xsl:param>
10
11 <xsl:variable name="apos">'</xsl:variable>
12 <xsl:variable name="xpathQuery">
13 <xsl:choose>
14 <xsl:when test="$flags = ''"><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ')]')"/></xsl:when>
15 <xsl:otherwise><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]')"/></xsl:otherwise>
16 </xsl:choose>
17 </xsl:variable>
18 <xsl:variable name="queryResult" select="saxon:evaluate($xpathQuery)" xmlns:saxon="http://saxon.sf.net/"/>
19 <xsl:variable name="queryResultSize"><xsl:value-of select="count($queryResult)"/></xsl:variable>
20 <xsl:variable name="queryResultPageSize" select="20"/>
21 <xsl:variable name="queryResultPages">
22 <xsl:choose>
23 <xsl:when test="$queryResultSize = 0"><xsl:value-of select="count($queryResult)"/></xsl:when>
24 <xsl:otherwise><xsl:value-of select="$queryResultSize idiv $queryResultPageSize + 1"/></xsl:otherwise>
25 </xsl:choose>
26 </xsl:variable>
27 <xsl:variable name="pageBreaks" select="saxon:evaluate('//*:pb')" xmlns:saxon="http://saxon.sf.net/"/>
28 <xsl:variable name="queryResultHtml">
29 <xsl:choose>
30 <xsl:when test="$outputFormat = 'html'">
31 <table>
32 <thead>
33 <tr>
34 <th align="left" valign="top">
35 <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">No.</button>
36 </th>
37 <th align="left" valign="top">
38 <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Path</button>
39 </th>
40 <th align="left" valign="top">
41 <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Hit</button>
42 </th>
43 <th align="left" valign="top">
44 <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Page</button>
45 </th>
46 </tr>
47 </thead>
48 <tbody>
49 <xsl:for-each select="$queryResult">
50 <xsl:variable name="hit" select="."/>
51 <tr>
52 <td align="left" valign="top"><xsl:value-of select="position()"/></td>
53 <td align="left" valign="top"><xsl:value-of select="saxon:path(.)" xmlns:saxon="http://saxon.sf.net/"/></td>
54 <td align="left" valign="top"><xsl:value-of select="."/></td>
55 <td align="left" valign="top"><xsl:value-of select="count(./preceding::*:pb)"/></td> <!-- better performance: count($pageBreaks[. << $hit]) -->
56 </tr>
57 </xsl:for-each>
58 </tbody>
59 </table>
60 </xsl:when>
61 <xsl:otherwise>
62 <result>
63 <query><xsl:value-of select="$query"/></query>
64 <flags><xsl:value-of select="$flags"/></flags>
65 <size><xsl:value-of select="$queryResultSize"/></size>
66 <page-size><xsl:value-of select="$queryResultPageSize"/></page-size>
67 <pages><xsl:value-of select="$queryResultPages"/></pages>
68 <pn>1</pn>
69 <hits>
70 <xsl:for-each select="$queryResult">
71 <xsl:variable name="hit" select="."/>
72 <hit>
73 <hitType><xsl:value-of select="'s'"/></hitType>
74 <pos><xsl:value-of select="position()"/></pos>
75 <pn><xsl:value-of select="count(./preceding::*:pb)"/></pn>
76 <hitId>xmlId</hitId>
77 <hitPos>4711</hitPos>
78 <hitString><xsl:value-of select="."/></hitString>
79 <hitSurroundsPB>false</hitSurroundsPB>
80 </hit>
81 </xsl:for-each>
82 </hits>
83 <query-forms></query-forms>
84 <query-regularizations></query-regularizations>
85 </result>
86 </xsl:otherwise>
87 </xsl:choose>
88 </xsl:variable>
89 <xsl:template match="/">
90 <xsl:sequence select="$queryResultHtml"/>
91 </xsl:template>
92
93 </xsl:stylesheet>