summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2019-02-03 21:42:35 +0300
committerdefanor <defanor@uberspace.net>2019-02-03 21:42:35 +0300
commit83a90895a5b6f1267ad272bfe23a6b604068d3c0 (patch)
tree8e9e59ac917c53a7c1921e6fcee14c35a7d0cae4 /example
parent7bc223ad6408a36072b5196fbf0dcc7de15b0984 (diff)
Replace HXT with libxml
The primary issue is that str:encode-uri function from EXSLT is not available with HXT (but available with libxml's friends: libxslt and libexslt, which are generally more complete). This function is important for HTML documents. Another reason is libxml being better documented and somewhat easier to work with. Yet another reason to switch is the intent to avoid dependencies that reimplement common functionality, and/or normally get statically linked.
Diffstat (limited to 'example')
-rw-r--r--example/bugs.sql2
-rw-r--r--example/common.xsl1
-rw-r--r--example/list.xsl21
-rw-r--r--example/view.xsl13
4 files changed, 21 insertions, 16 deletions
diff --git a/example/bugs.sql b/example/bugs.sql
index 033a1f7..eadb89a 100644
--- a/example/bugs.sql
+++ b/example/bugs.sql
@@ -30,7 +30,7 @@ as $$
|| 'where (project like ' || quote_literal('%' || proj || '%')
|| ') and (description like ' || quote_literal('%' || descr || '%')
|| ') order by reported desc limit ' || lim || ' offset ' || offs,
- false, false, 'bugs')
+ false, false, 'urn:x-bugs')
$$ language sql;
-- Now users can be added with select and/or insert privileges,
diff --git a/example/common.xsl b/example/common.xsl
index ff456a3..3a89d46 100644
--- a/example/common.xsl
+++ b/example/common.xsl
@@ -8,6 +8,7 @@
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
+ <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Bugs</title>
diff --git a/example/list.xsl b/example/list.xsl
index 86c3150..f229e3e 100644
--- a/example/list.xsl
+++ b/example/list.xsl
@@ -2,7 +2,10 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:bugs="urn:x-bugs"
+ xmlns:str="http://exslt.org/strings"
xmlns="http://www.w3.org/1999/xhtml"
+ extension-element-prefixes="str"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
@@ -11,10 +14,10 @@
<xsl:param name="limit" select="10" />
<xsl:param name="offset" select="0" />
- <xsl:template match="table">
+ <xsl:template match="bugs:table">
<!-- Report form -->
<h2>Report</h2>
- <form method="post" action="view.xhtml?q=insert%20into%20bugs%20(%20:fields%20)%20values%20(%20:values%20)%20returning%20xmlelement(name%20table,xmlelement(name%20row,xmlelement(name%20id,id),xmlelement(name%20reported,reported),xmlelement(name%20reporter,reporter),xmlelement(name%20project,project),xmlelement(name%20description,description)))">
+ <form method="post" action="view.xhtml?q=insert%20into%20bugs%20(%20:fields%20)%20values%20(%20:values%20)%20returning%20xmlelement(name%20table,xmlattributes('urn:x-bugs'%20as%20xmlns),xmlelement(name%20row,xmlelement(name%20id,id),xmlelement(name%20reported,reported),xmlelement(name%20reporter,reporter),xmlelement(name%20project,project),xmlelement(name%20description,description)))">
<dl>
<dt><label for="report_project">Project</label></dt>
<dd>
@@ -70,18 +73,18 @@
<th>Project</th>
<th>Summary</th>
</tr>
- <xsl:for-each select="row">
+ <xsl:for-each select="bugs:row">
<tr>
- <td><xsl:copy-of select="reported/text()" /></td>
- <td><xsl:copy-of select="reporter/text()" /></td>
+ <td><xsl:copy-of select="bugs:reported/text()" /></td>
+ <td><xsl:copy-of select="bugs:reporter/text()" /></td>
<td>
- <a href="list.xhtml?q=select%20bug_search('{project/text()}','',{$limit},{$offset})">
- <xsl:copy-of select="project/text()" />
+ <a href="list.xhtml?q=select%20bug_search(%20q:project%20,'',{$limit},{$offset})&amp;project={str:encode-uri(bugs:project/text(), true())}">
+ <xsl:copy-of select="bugs:project/text()" />
</a>
</td>
<td>
- <a href="view.xhtml?q=select%20query_to_xml('select%20*%20from%20bugs%20where%20id=''{id}''',false,false,'foo')">
- <xsl:copy-of select="summary/text()" />
+ <a href="view.xhtml?q=select%20query_to_xml('select%20*%20from%20bugs%20where%20id=''{bugs:id}''',false,false,'urn:x-bugs')">
+ <xsl:copy-of select="bugs:summary/text()" />
</a>
</td>
</tr>
diff --git a/example/view.xsl b/example/view.xsl
index af0e090..84a9d5a 100644
--- a/example/view.xsl
+++ b/example/view.xsl
@@ -2,24 +2,25 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:bugs="urn:x-bugs"
xmlns="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
- <xsl:template match="table/row">
+ <xsl:template match="bugs:table/bugs:row">
<a href="list.xhtml?q=select%20bug_search(%27%27,%20%27%27,%2010,%200)">back to listing</a>
<dl>
<dt>ID</dt>
- <dd><xsl:copy-of select="id/text()" /></dd>
+ <dd><xsl:copy-of select="bugs:id/text()" /></dd>
<dt>Reported</dt>
- <dd><xsl:copy-of select="reported/text()" /></dd>
+ <dd><xsl:copy-of select="bugs:reported/text()" /></dd>
<dt>Reporter</dt>
- <dd><xsl:copy-of select="reporter/text()" /></dd>
+ <dd><xsl:copy-of select="bugs:reporter/text()" /></dd>
<dt>Project</dt>
- <dd><xsl:copy-of select="project/text()" /></dd>
+ <dd><xsl:copy-of select="bugs:project/text()" /></dd>
<dt>Description</dt>
- <dd><pre><xsl:copy-of select="description/text()" /></pre></dd>
+ <dd><pre><xsl:copy-of select="bugs:description/text()" /></pre></dd>
</dl>
</xsl:template>