Skip to content

Commit

Permalink
Change the json result so more rendering logic can be implemented in …
Browse files Browse the repository at this point in the history
…Vue.
  • Loading branch information
simar0at committed Nov 9, 2023
1 parent d4a9f4b commit 4db715f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 51 deletions.
38 changes: 22 additions & 16 deletions xslt/corpus_search_result_json.xslt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:acdh="http://acdh.oeaw.ac.at"
xmlns:tei="http://www.tei-c.org/ns/1.0" version="2.0">
xmlns:tei="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="tei acdh"
version="2.0">

<xsl:output method="xml" indent="yes"/>
<xsl:param name="query"></xsl:param>

<xsl:include href="serialize-html.xslt"/>

<xsl:function name="acdh:index-of-node">
<xsl:param name="nodes"></xsl:param>
<xsl:param name="search"></xsl:param>
Expand All @@ -31,9 +31,9 @@
<xsl:variable select="acdh:index-of-node($hit/tei:u/tei:w, $w)" name="word_pos"/>
<xsl:variable select="subsequence($hit/tei:u/tei:w, $word_pos+1, 5)" name="right"/>
<xsl:variable select="subsequence($hit/tei:u/tei:w, $word_pos - 5, 5)" name="left"/>
<div class="corpus-search-result justify-content-between">
<xsl:attribute name="id" select="concat('corpus-w-', $hit/token)"/>
<span class="left flex-fill text-end">
<!-- <xsl:attribute name="id" select="concat('corpus-w-', $hit/token)"/> -->
<left>
<xsl:variable name="html">
<xsl:for-each select="$left">
<span class="w">
<xsl:attribute name="id" select="@xml:id"/>
Expand All @@ -46,9 +46,12 @@
<span>-</span>
</xsl:if>
</xsl:for-each>
</span>
<span class="keyword text-center" width="150px">
<span class="w bg-warning">
</xsl:variable>
<xsl:value-of select="serialize($html)"/>
</left>
<kwic>
<xsl:variable name="html">
<span class="w">
<xsl:value-of select="$w" />
</span>
<xsl:if test="not($w/@join = 'right')">
Expand All @@ -57,8 +60,11 @@
<xsl:if test="$w/@join = 'right' and $w/@rend='withDash'">
<span>-</span>
</xsl:if>
</span>
<span class="right flex-fill text-start">
</xsl:variable>
<xsl:value-of select="serialize($html)"/>
</kwic>
<right>
<xsl:variable name="html">
<xsl:for-each select="$right">
<span class="w">
<xsl:value-of select="."/>
Expand All @@ -70,16 +76,17 @@
<span>-</span>
</xsl:if>
</xsl:for-each>
</span>
</div>
</xsl:variable>
<xsl:value-of select="serialize($html)"/>
</right>
</xsl:if>
</xsl:function>




<xsl:template match="/">
<json objects="json" arrays="hits docHits">
<json objects="json content" arrays="hits docHits">
<xsl:apply-templates/>
</json>
</xsl:template>
Expand All @@ -89,7 +96,6 @@
<query><xsl:value-of select="$query"/></query>
<hits>


<xsl:for-each select="./hit">
<xsl:variable select="." name="hit"/>
<_ type="object">
Expand All @@ -99,7 +105,7 @@
<_ type="string"><xsl:value-of select="."/></_>
</xsl:for-each>
</docHits>
<content><xsl:apply-templates select="acdh:render-hit(.)" mode="serialize"/></content>
<content><xsl:sequence select="acdh:render-hit(.)"/></content>
</_>
</xsl:for-each>
</hits>
Expand Down
35 changes: 0 additions & 35 deletions xslt/serialize-html.xslt

This file was deleted.

0 comments on commit 4db715f

Please sign in to comment.