Daniel Sheffield пре 8 месеци
родитељ
комит
5ad61ca87d
3 измењених фајлова са 67 додато и 60 уклоњено
  1. 1 1
      rest/pyapi.py
  2. 66 48
      rest/query-to-xml-xslt.xml
  3. 0 11
      rest/query-to-xml.tpl

+ 1 - 1
rest/pyapi.py

@@ -34,7 +34,7 @@ SELECT query_to_xml_and_xmlschema({q}, false, false, ''::text);
 @route('/pyapi/xslt')
 def table():
     response.content_type = 'application/xhtml+xml; charset=utf-8'
-    return static_file("rest/query-to-xml-xslt.xml")
+    return static_file("rest/query-to-xml-xslt.xml", root="rest")
 
 @route('/pyapi/pg')
 def specified():

+ 66 - 48
rest/query-to-xml-xslt.xml

@@ -25,72 +25,90 @@ All rights reserved.
   </xsl:template>
 
   <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"/>
     <xsl:variable name="rowtypename"
                   select="$schema/xsd:complexType[@name=$tabletypename]/xsd:sequence/xsd:element[@name='row']/@type"/>
     
-    <table class="pure-table pure-table-bordered pure-table-striped">
-      <tr style="text-transform: capitalize">
-      <xsl:for-each select="$schema/xsd:complexType[@name=$rowtypename]/xsd:sequence/xsd:element/@name">
-          <xsl:variable name="elementtype"
-                        select="."/>
-          <xsl:choose>
-          <xsl:when test="$elementtype = 'txt'">
-        <th class="opt-all">Text</th>
-          </xsl:when>
-          <xsl:when test="$elementtype = 'category'">
-        <th class="opt-all">Section</th>
-          </xsl:when>
-          <xsl:when test="$elementtype = 'translation'">
-        <th class="opt-md opt-lg opt-xl opt-xxl">Reference</th>
-          </xsl:when>
-          <xsl:otherwise>
-          </xsl:otherwise>
-          </xsl:choose>
-      </xsl:for-each>
-      </tr>
-
-      <xsl:for-each select="row">
-        <tr>
-          <xsl:for-each select="*">
+    <div xmlns="http://www.w3.org/1999/xhtml"
+         style="background: darkgray; position: sticky; top: 0; margin: 0; padding: 0; width: 100%; z-index: 1; text-align: center;">
+      <form action="random">
+        <button type="submit" style="margin: 0.2em">Generate</button>
+        <span style="position: absolute; right: 0; padding: 0.4em">
+          <a>
+            <xsl:attribute name="href">./pg?<xsl:for-each select="//row"><xsl:value-of select="category"/>=<xsl:value-of select="translate(reference,' ','')"/>+<xsl:value-of select="translation"/><xsl:if test="position() != last()">&#038;</xsl:if></xsl:for-each></xsl:attribute>
+            Permalink
+          </a>
+        </span>
+	    </form>
+    </div>
+    <table xmlns="http://www.w3.org/1999/xhtml"
+           class="pure-table pure-table-bordered pure-table-striped">
+      <thead>
+        <tr style="text-transform: capitalize">
+        <xsl:for-each select="$schema/xsd:complexType[@name=$rowtypename]/xsd:sequence/xsd:element/@name">
             <xsl:variable name="elementtype"
-                          select="name(current())"/>
+                          select="."/>
             <xsl:choose>
             <xsl:when test="$elementtype = 'txt'">
-            <td class="opt-all" style="text-align: justify"><xsl:value-of select="."/>&#160;<span class="engraved">
-            <xsl:value-of select="../translation"/>
-            </span>
-            </td>
+              <th class="opt-all">Text</th>
             </xsl:when>
             <xsl:when test="$elementtype = 'category'">
-              <xsl:choose>
-                <xsl:when test="contains(.,'z_')">
-                  <td class="opt-all" rowspan="2" style="text-transform: capitalize;">Kingdom</td>
-                </xsl:when>
-                <xsl:when test="contains(.,'a_')"></xsl:when>
-                <xsl:otherwise>
-                  <td class="opt-all" style="text-transform: capitalize;"><xsl:value-of select="."/></td>
-                </xsl:otherwise>
-              </xsl:choose>
+              <th class="opt-all">Section</th>
             </xsl:when>
             <xsl:when test="$elementtype = 'translation'">
+              <th class="opt-md opt-lg opt-xl opt-xxl">Reference</th>
             </xsl:when>
             <xsl:otherwise>
-              <td class="opt-md opt-lg opt-xl opt-xxl">
-              <xsl:value-of select="translate(translate(.,' ','&#160;'),'-','&#8209;')"/>
-              <br/>
-              <a>
-                <xsl:attribute name="href">/license/<xsl:value-of select="preceding-sibling::translation"/>.txt</xsl:attribute>
-                <xsl:value-of select="preceding-sibling::translation"/>
-              </a>
-              </td>
             </xsl:otherwise>
             </xsl:choose>
-          </xsl:for-each>
+        </xsl:for-each>
         </tr>
-      </xsl:for-each>
+      </thead>
+      <tbody>
+        <xsl:for-each select="xhtml:row">
+          <tr>
+            <xsl:for-each select="*">
+              <xsl:variable name="elementtype"
+                            select="name(current())"/>
+              <xsl:choose>
+              <xsl:when test="$elementtype = 'txt'">
+              <td class="opt-all" style="text-align: justify"><xsl:value-of select="."/>&#160;<span class="engraved">
+              <xsl:value-of select="../translation"/>
+              </span>
+              </td>
+              </xsl:when>
+              <xsl:when test="$elementtype = 'category'">
+                <xsl:choose>
+                  <xsl:when test="contains(.,'z_')">
+                    <td class="opt-all" rowspan="2" style="text-transform: capitalize;">Kingdom</td>
+                  </xsl:when>
+                  <xsl:when test="contains(.,'a_')"></xsl:when>
+                  <xsl:otherwise>
+                    <td class="opt-all" style="text-transform: capitalize;"><xsl:value-of select="."/></td>
+                  </xsl:otherwise>
+                </xsl:choose>
+              </xsl:when>
+              <xsl:when test="$elementtype = 'translation'">
+              </xsl:when>
+              <xsl:otherwise>
+                <td class="opt-md opt-lg opt-xl opt-xxl">
+                <xsl:value-of select="translate(translate(.,' ','&#160;'),'-','&#8209;')"/>
+                <br/>
+                <a>
+                  <xsl:attribute name="href">/license/<xsl:value-of select="preceding-sibling::translation"/>.txt</xsl:attribute>
+                  <xsl:value-of select="preceding-sibling::translation"/>
+                </a>
+                </td>
+              </xsl:otherwise>
+              </xsl:choose>
+            </xsl:for-each>
+          </tr>
+        </xsl:for-each>
+      </tbody>
+
       <tfoot style="line-height: 1.4">
         <tr>
           <td colspan="3">

+ 0 - 11
rest/query-to-xml.tpl

@@ -24,17 +24,6 @@ span.engraved {
   </style>
   </head>
   <body>
-    <div style="background: darkgray; position: sticky; top: 0; margin: 0; padding: 0; width: 100%; z-index: 1; text-align: center;">
-      <form action="random">
-        <button type="submit" style="margin: 0.2em">Generate</button>
-        <span style="position: absolute; right: 0; padding: 0.4em">
-          <a>
-            <xsl:attribute name="href">./pg?<xsl:for-each select="//row"><xsl:value-of select="category"/>=<xsl:value-of select="translate(reference,' ','')"/>+<xsl:value-of select="translation"/><xsl:if test="position() != last()">&#038;</xsl:if></xsl:for-each></xsl:attribute>
-            Permalink
-          </a>
-        </span>
-	  </form>
-    </div>
     <div id="xmldata" style="position: relative; max-width: 68em; min-width: min(100%, 68em); left: 50%; transform: translate(max(-50%, -34em),0)">
 {{!xml}}
     </div>