Skip to content

Commit

Permalink
Created one template per view, introduced keydef list #66
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMaudry committed Oct 21, 2014
1 parent f3d1bc2 commit 1e66dad
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 28 deletions.
60 changes: 39 additions & 21 deletions dita2rdf/src/xsl/browser.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,37 @@

<xsl:template match="div[@id='content']">
<xsl:param name="currentPageType" tunnel="yes"/>
<xsl:param name="data" tunnel="yes"/>
<xsl:param name="objectInfo" tunnel="yes"/>
<xsl:variable name="query">
<xsl:value-of select="$queries/query[@name='contexts']"/>
</xsl:variable>
<xsl:variable name="title">
<xsl:choose>
<xsl:when test="$currentPageType='contexts'">Contexts</xsl:when>
<xsl:otherwise>
<span class="label label-default"><xsl:value-of select="colin:prettifyVariableName($currentPageType)"/></span>
<xsl:text> </xsl:text>
<xsl:value-of select="$objectInfo/s:binding[@name='title']/s:literal"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$currentPageType!='contexts'">
<span class="label label-default"><xsl:value-of select="colin:prettifyVariableName($currentPageType)"/></span>
<xsl:text> </xsl:text>
<xsl:value-of select="$objectInfo/s:binding[@name='title']/s:literal"/>
</xsl:if>
</xsl:variable>
<div>
<xsl:apply-templates select="@*"/>
<div class="well well-sm" id="datanav" style="position: fixed; width: 100%;">
<h1><xsl:copy-of select="$title"/></h1>
<a class="btn btn-primary" role="button" href="#links">Links</a>
<a class="btn btn-primary" role="button" href="#stats">Stats</a>
</div>
<xsl:apply-templates select="$data" mode="table">
<xsl:with-param name="location" select="'center'"/>
</xsl:apply-templates>
<xsl:call-template name="stats"/>
<xsl:choose>
<xsl:when test="$currentPageType = 'contexts'">
<xsl:call-template name="contextsContent"/>
</xsl:when>
<xsl:when test="$currentPageType = 'context'">
<xsl:call-template name="contextContent">
<xsl:with-param name="title" select="$title"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$currentPageType = 'map'">
<xsl:call-template name="mapContent">
<xsl:with-param name="title" select="$title"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$currentPageType = 'topic'">
<xsl:call-template name="topicContent">
<xsl:with-param name="title" select="$title"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>

</div>
</xsl:template>

Expand Down Expand Up @@ -146,6 +151,19 @@
</div>
</xsl:template>

<xsl:template name="contextsContent">
<xsl:param name="data" tunnel="yes"/>
<div class="well well-sm" id="datanav" style="position: fixed; width: 100%;">
<h1>Contexts</h1>
<a class="btn btn-primary" role="button" href="#links">Links</a>
<a class="btn btn-primary" role="button" href="#stats">Stats</a>
</div>
<xsl:apply-templates select="$data" mode="table">
<xsl:with-param name="location" select="'center'"/>
</xsl:apply-templates>
<xsl:call-template name="stats"/>
</xsl:template>

<xsl:template match="@href[not(starts-with(.,'http'))] | @src[not(starts-with(.,'http'))]">
<xsl:param name="currentPageType" tunnel="yes"/>
<xsl:attribute name="{local-name()}">
Expand Down
37 changes: 36 additions & 1 deletion dita2rdf/src/xsl/browser/queries.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,50 @@
?thing &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?typeUri
OPTIONAL
{ ?thing dita:title ?title }
}
GRAPH &lt;http://purl.org/dita/ns>
{ ?rel rdfs:subPropertyOf dita:referenceObject .
?rel rdfs:label ?relation .
?typeUri rdfs:label ?typeLabel
}
}
}
GROUP BY ?thing ?title ?relation
</query>
<query name="context-keys" replace="yes">
PREFIX rdfs:&lt;http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcat: &lt;http://www.w3.org/ns/dcat#>
PREFIX dita: &lt;http://purl.org/dita/ns#>
PREFIX dcterms: &lt;http://purl.org/dc/terms/>

SELECT DISTINCT ?key_name ?key_value ?map_title ?map_id
WHERE
{ GRAPH ?graph
{

?uri a dcat:Dataset ;
dcterms:title ?context_title .

?thing a dita:Key ;
dita:keyname ?key_name .
{?thing dita:href ?key_value .} UNION
{?thing dita:keyword ?keyword .
?keyword rdfs:label ?key_value .}

?keydefObject dita:key ?thing ;
a dita:Topicref .
?map a dita:Map ;
?keydef ?keydefObject ;
dita:title ?map_title ;
dita:id ?map_id .


}
GRAPH &lt;http://purl.org/dita/ns>
{ ?keydef rdfs:subPropertyOf dita:topicref .
}
}
</query>
</queries>
</xsl:param>

Expand Down
30 changes: 30 additions & 0 deletions dita2rdf/src/xsl/browser/view/context.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,34 @@
<xsl:with-param name="currentPageType" select="'context'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template name="contextContent">
<xsl:param name="data" tunnel="yes"/>
<xsl:param name="objectInfo" tunnel="yes"/>
<xsl:param name="title"/>
<xsl:variable name="dataKeys">
<xsl:call-template name="colin:getData">
<xsl:with-param name="queryName">context-keys</xsl:with-param>
<xsl:with-param name="uri" select="$objectInfo/s:binding[@name='thing']/s:uri"></xsl:with-param>
</xsl:call-template>
</xsl:variable>

<div class="well well-sm" id="datanav" style="position: fixed; width: 100%;">
<h1><xsl:copy-of select="$title"/></h1>
<a class="btn btn-primary" role="button" href="#links">Links</a>
<a class="btn btn-primary" role="button" href="#stats">Stats</a>
</div>
<h3>Links</h3>
<xsl:apply-templates select="$data" mode="table">
<xsl:with-param name="location" select="'center'"/>
</xsl:apply-templates>

<xsl:apply-templates select="$dataKeys" mode="table">
<xsl:with-param name="location" select="'center'"/>
</xsl:apply-templates>

<xsl:call-template name="stats"/>
</xsl:template>
</xsl:stylesheet>


15 changes: 15 additions & 0 deletions dita2rdf/src/xsl/browser/view/map.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,19 @@
<xsl:with-param name="currentPageType" select="'map'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:template>


<xsl:template name="mapContent">
<xsl:param name="data" tunnel="yes"/>
<xsl:param name="title"/>
<div class="well well-sm" id="datanav" style="position: fixed; width: 100%;">
<h1><xsl:copy-of select="$title"/></h1>
<a class="btn btn-primary" role="button" href="#links">Links</a>
<a class="btn btn-primary" role="button" href="#stats">Stats</a>
</div>
<xsl:apply-templates select="$data" mode="table">
<xsl:with-param name="location" select="'center'"/>
</xsl:apply-templates>
<xsl:call-template name="stats"/>
</xsl:template>
</xsl:stylesheet>
9 changes: 3 additions & 6 deletions dita2rdf/src/xsl/browser/view/table.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<xsl:param name="head" select="s:head" as="node()"/>
<xsl:param name="location"/>
<table class="table browsable sortable">
<xsl:if test="$location='center'">
<xsl:attribute name="id">links</xsl:attribute>
</xsl:if>
<caption><span class="badge pull-right"><xsl:value-of select="count(s:results/s:result[count(s:binding)=count($head/s:variable)])"/></span></caption>
<thead>
<tr>
Expand All @@ -25,8 +22,8 @@
</tr>
</thead>
<xsl:apply-templates select="s:results" mode="table">
<xsl:with-param name="head" select="$head" tunnel="yes"/>
</xsl:apply-templates>
<xsl:with-param name="head" select="$head" tunnel="yes"/>
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="s:results" mode="table">
Expand Down Expand Up @@ -63,7 +60,7 @@
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="s:result[s:binding[@name='title']/s:literal/text()='' and s:binding[@name='id']/s:literal/text()='']"/>
<xsl:template match="s:result[s:binding[contains(@name,'title')]/s:literal/text()='' and s:binding[contains(@name,'id')]/s:literal/text()='']"/>
<xsl:template match="s:binding" mode="table" priority="-1">
<xsl:param name="path"/>
<td class="{@name}"><a href="{$path}"><xsl:value-of select="."/></a></td>
Expand Down
14 changes: 14 additions & 0 deletions dita2rdf/src/xsl/browser/view/topic.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,19 @@
</xsl:with-param>
<xsl:with-param name="currentPageType" select="'topic'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template name="topicContent">
<xsl:param name="data" tunnel="yes"/>
<xsl:param name="title"/>
<div class="well well-sm" id="datanav" style="position: fixed; width: 100%;">
<h1><xsl:copy-of select="$title"/></h1>
<a class="btn btn-primary" role="button" href="#links">Links</a>
<a class="btn btn-primary" role="button" href="#stats">Stats</a>
</div>
<xsl:apply-templates select="$data" mode="table">
<xsl:with-param name="location" select="'center'"/>
</xsl:apply-templates>
<xsl:call-template name="stats"/>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 1e66dad

Please sign in to comment.