Pi преди 1 година
родител
ревизия
b59335875f
променени са 3 файла, в които са добавени 36 реда и са изтрити 25 реда
  1. 32 23
      app/rest/static/query-to-xml-xslt.xml
  2. 3 1
      app/rest/templates/query-to-xml.tpl
  3. 1 1
      app/rest/templates/trend.tpl

+ 32 - 23
app/rest/static/query-to-xml-xslt.xml

@@ -1,23 +1,25 @@
-<xsl:stylesheet version="1.0"
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-    xmlns="http://www.w3.org/1999/xhtml"
+<xsl:stylesheet version="1.1"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
 >
 
   <xsl:output method="xml"
-      doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
-      doctype-public="-//W3C/DTD XHTML 1.0 Strict//EN"
-      indent="yes"/>
+    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+    doctype-public="-//W3C/DTD XHTML 1.0 Strict//EN"
+    indent="yes"/>
   
   <!-- This is an identity template - it copies everything
         that doesn't match another template -->
   <xsl:template match="@* | node()">
-      <xsl:copy>
-          <xsl:apply-templates select="@* | node()"/>
-      </xsl:copy>
+    <xsl:copy>
+      <xsl:apply-templates select="@* | node()"/>
+    </xsl:copy>
+  </xsl:template>
+  <xsl:template match="processing-instruction()">
   </xsl:template>
 
-  <xsl:template match="/html/body/*/div[@id='xmldata']/*">
+  <xsl:template match="//xhtml:div[@id='xmldata']/*">
     <xsl:variable name="schema" select="//xsd:schema"/>
     <xsl:variable name="tabletypename"
                   select="$schema/xsd:element[@name=name(current())]/@type"/>
@@ -25,7 +27,8 @@
                   select="$schema/xsd:complexType[@name=$tabletypename]/xsd:sequence/xsd:element[@name='row']/@type"/>
     <xsl:variable name="tablename" select="$schema/xsd:complexType[@name=$rowtypename]/xsd:sequence/xsd:element[1]/@name"/>
      
-    <table class="pure-table pure-table-bordered pure-table-striped" style="text-align: left; width: 100%;">
+    <table xmlns="http://www.w3.org/1999/xhtml"
+      class="pure-table pure-table-bordered pure-table-striped" style="text-align: left; width: 100%;">
     
       <thead style="text-align: center">
       <tr>
@@ -35,29 +38,35 @@
       </tr>
       </thead>
 
-      <xsl:for-each select="row">
+      <tbody>
+      <xsl:for-each select="xhtml:row">
+        <xsl:choose>
+          <xsl:when test="position() != last()">
+            <tr>
+              <xsl:for-each select="*">
+                <td><xsl:value-of select="."/></td>
+              </xsl:for-each>
+            </tr>
+          </xsl:when>
+        </xsl:choose>
+      </xsl:for-each>
+      </tbody>
+      <tfoot>
+      <xsl:for-each select="xhtml:row">
         <xsl:choose>
           <xsl:when test="position() = last()">
-            <tfoot>
               <tr>
                 <xsl:for-each select="*">
                   <th style="text-align: center"><xsl:value-of select="."/></th>
                 </xsl:for-each>
               </tr>
-            </tfoot>
           </xsl:when>
-          <xsl:otherwise>
-            <tr>
-              <xsl:for-each select="*">
-                <td><xsl:value-of select="."/></td>
-              </xsl:for-each>
-            </tr>
-          </xsl:otherwise>
         </xsl:choose>
       </xsl:for-each>
+      </tfoot>
 
     </table>
 
   </xsl:template>
 
-</xsl:stylesheet>
+</xsl:stylesheet>

+ 3 - 1
app/rest/templates/query-to-xml.tpl

@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml-stylesheet type="text/xsl" href="/grocery/static/query-to-xml-xslt.xml"?>
-<html>
+<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
     <title>{{ title }}</title>
     <meta name="viewport" content="width=device-width, initial-scale=1"/>
     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/purecss@2.1.0/build/pure-min.css" integrity="sha384-yHIFVG6ClnONEA5yB5DJXfW2/KC173DIQrYoZMEtBvGzmf0PKiGyNEqe9N6BNDBH" crossorigin="anonymous"/>
@@ -11,6 +12,7 @@
 body {
   background-color: #080808;
   color: #cccccc;
+  text-align: center;
 }
 .pure-table thead{
   background-color:#a0a0a0;

+ 1 - 1
app/rest/templates/trend.tpl

@@ -39,7 +39,7 @@ svg {
         <link rel="stylesheet" href="https://shandan.one/css/grids-responsive-min.css"/>
         <link rel="stylesheet" href="https://shandan.one/css/responsive-visibility-collapse.css"/>
     </head>
-    <body align="center">
+    <body align="center" style="text-align: center">
 {{!form}}
 {{!svg}}
     </body>