]> Lady’s Gitweb - Shushe/commitdiff
Don’t use literal result elements in parsers current
authorLady <redacted>
Tue, 26 Nov 2024 04:16:36 +0000 (23:16 -0500)
committerLady <redacted>
Tue, 26 Nov 2024 04:16:36 +0000 (23:16 -0500)
Literal result elements inherit name·spaces from their surrounding
context. Using `<xslt:element>` elements avoids this trouble (and also
allows for the removal of name·space prefixes, reducing sizes of
results).

parsers/plain.xslt
parsers/record-jar.xslt
parsers/tsv.xslt

index 01e6f8d15beaed5f7af054b898e106761f1fa8f9..3430526d5c37378eb1242d18c0068aa8f9fed3be 100644 (file)
@@ -11,14 +11,19 @@ SPDX-License-Identifier: MPL-2.0
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
+<!DOCTYPE transform [
+       <!ENTITY xhtml 'http://www.w3.org/1999/xhtml'>
+]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
-       xmlns:html="http://www.w3.org/1999/xhtml"
+       xmlns:html="&xhtml;"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:plain.xslt</书社:id>
        <template match="html:script[@type='text/plain']">
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:plain.xslt</书社:id>
        <template match="html:script[@type='text/plain']">
-               <html:pre><value-of select="."/></html:pre>
+               <element name="pre" namespace="&xhtml;">
+                       <value-of select="."/>
+               </element>
        </template>
 </transform>
        </template>
 </transform>
index abaf08c04e450c09331cc81e3d55722448cc1ae6..b58505d3600da93e842ae752f1581a4fa30f6cc2 100644 (file)
@@ -11,11 +11,14 @@ SPDX-License-Identifier: MPL-2.0
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
+<!DOCTYPE transform [
+       <!ENTITY xhtml 'http://www.w3.org/1999/xhtml'>
+]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:exsl="http://exslt.org/common"
        xmlns:exslstr="http://exslt.org/strings"
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:exsl="http://exslt.org/common"
        xmlns:exslstr="http://exslt.org/strings"
-       xmlns:html="http://www.w3.org/1999/xhtml"
+       xmlns:html="&xhtml;"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        extension-element-prefixes="exsl exslstr"
        version="1.0"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        extension-element-prefixes="exsl exslstr"
        version="1.0"
@@ -23,7 +26,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:record-jar.xslt</书社:id>
        <template match="html:script[@type='text/record-jar']">
                <variable name="lines" select="exslstr:tokenize(., '&#xA;')"/>
        <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:record-jar.xslt</书社:id>
        <template match="html:script[@type='text/record-jar']">
                <variable name="lines" select="exslstr:tokenize(., '&#xA;')"/>
-               <html:div>
+               <element name="div" namespace="&xhtml;">
                        <if test="starts-with($lines[1], '%%') and substring-after($lines[1], '%%')!=''">
                                <comment>
                                        <value-of select="substring-after($lines[1], '%%')"/>
                        <if test="starts-with($lines[1], '%%') and substring-after($lines[1], '%%')!=''">
                                <comment>
                                        <value-of select="substring-after($lines[1], '%%')"/>
@@ -34,17 +37,17 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <variable name="start" select="preceding-sibling::*[starts-with(., '%%')][1]"/>
                                <variable name="fields" select="($start/following-sibling::*|$lines[not($start)])[not(preceding-sibling::*[generate-id()=generate-id($end)]) and not(starts-with(., '%%'))]"/>
                                <if test="$fields">
                                <variable name="start" select="preceding-sibling::*[starts-with(., '%%')][1]"/>
                                <variable name="fields" select="($start/following-sibling::*|$lines[not($start)])[not(preceding-sibling::*[generate-id()=generate-id($end)]) and not(starts-with(., '%%'))]"/>
                                <if test="$fields">
-                                       <html:dl>
+                                       <element name="dl" namespace="&xhtml;">
                                                <for-each select="$fields">
                                                        <choose>
                                                                <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
                                                                <otherwise>
                                                                        <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
                                                <for-each select="$fields">
                                                        <choose>
                                                                <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
                                                                <otherwise>
                                                                        <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
-                                                                       <html:div>
-                                                                               <html:dt>
+                                                                       <element name="div" namespace="&xhtml;">
+                                                                               <element name="dt" namespace="&xhtml;">
                                                                                        <value-of select="normalize-space(substring-before(., ':'))"/>
                                                                                        <value-of select="normalize-space(substring-before(., ':'))"/>
-                                                                               </html:dt>
-                                                                               <html:dd>
+                                                                               </element>
+                                                                               <element name="dd" namespace="&xhtml;">
                                                                                        <variable name="firstline">
                                                                                                <choose>
                                                                                                        <when test="contains(., ':')">
                                                                                        <variable name="firstline">
                                                                                                <choose>
                                                                                                        <when test="contains(., ':')">
@@ -74,12 +77,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                                        </otherwise>
                                                                                                </choose>
                                                                                        </for-each>
                                                                                                        </otherwise>
                                                                                                </choose>
                                                                                        </for-each>
-                                                                               </html:dd>
-                                                                       </html:div>
+                                                                               </element>
+                                                                       </element>
                                                                </otherwise>
                                                        </choose>
                                                </for-each>
                                                                </otherwise>
                                                        </choose>
                                                </for-each>
-                                       </html:dl>
+                                       </element>
                                </if>
                                <if test="substring-after(., '%%')!=''">
                                        <comment>
                                </if>
                                <if test="substring-after(., '%%')!=''">
                                        <comment>
@@ -87,6 +90,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        </comment>
                                </if>
                        </for-each>
                                        </comment>
                                </if>
                        </for-each>
-               </html:div>
+               </element>
        </template>
 </transform>
        </template>
 </transform>
index 5b3cc684f6821c0e3a85f09e2637d7027c391c00..90e156e28c776c3b51bf74b557c1e35a687e5396 100644 (file)
@@ -11,11 +11,14 @@ SPDX-License-Identifier: MPL-2.0
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
+<!DOCTYPE transform [
+       <!ENTITY xhtml 'http://www.w3.org/1999/xhtml'>
+]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:exsl="http://exslt.org/common"
        xmlns:exslstr="http://exslt.org/strings"
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:exsl="http://exslt.org/common"
        xmlns:exslstr="http://exslt.org/strings"
-       xmlns:html="http://www.w3.org/1999/xhtml"
+       xmlns:html="&xhtml;"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        extension-element-prefixes="exsl exslstr"
        version="1.0"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        extension-element-prefixes="exsl exslstr"
        version="1.0"
@@ -31,22 +34,25 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <with-param name="separator" select="'&#x9;'"/>
                        </call-template>
                </variable>
                                <with-param name="separator" select="'&#x9;'"/>
                        </call-template>
                </variable>
-               <html:table>
+               <element name="table" namespace="&xhtml;">
                        <for-each select="$lines[starts-with(., '#') and following-sibling::*[generate-id(.)=generate-id($head)]]">
                                <comment>
                                        <value-of select="substring-after(., '#')"/>
                                </comment>
                        </for-each>
                        <for-each select="$lines[starts-with(., '#') and following-sibling::*[generate-id(.)=generate-id($head)]]">
                                <comment>
                                        <value-of select="substring-after(., '#')"/>
                                </comment>
                        </for-each>
-                       <html:thead>
-                               <html:tr>
+                       <element name="thead" namespace="&xhtml;">
+                               <element name="tr" namespace="&xhtml;">
                                        <for-each select="exsl:node-set($headcols)/*">
                                        <for-each select="exsl:node-set($headcols)/*">
-                                               <html:th scope="col">
+                                               <element name="th" namespace="&xhtml;">
+                                                       <attribute name="scope">
+                                                               <text>col</text>
+                                                       </attribute>
                                                        <value-of select="."/>
                                                        <value-of select="."/>
-                                               </html:th>
+                                               </element>
                                        </for-each>
                                        </for-each>
-                               </html:tr>
-                       </html:thead>
-                       <html:tbody>
+                               </element>
+                       </element>
+                       <element name="tbody" namespace="&xhtml;">
                                <for-each select="$head/following-sibling::*[normalize-space(.)!='']">
                                        <choose>
                                                <when test="starts-with(., '#')">
                                <for-each select="$head/following-sibling::*[normalize-space(.)!='']">
                                        <choose>
                                                <when test="starts-with(., '#')">
@@ -61,9 +67,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                        <with-param name="separator" select="'&#x9;'"/>
                                                                </call-template>
                                                        </variable>
                                                                        <with-param name="separator" select="'&#x9;'"/>
                                                                </call-template>
                                                        </variable>
-                                                       <html:tr>
+                                                       <element name="tr" namespace="&xhtml;">
                                                                <for-each select="exsl:node-set($cols)/*[count(exsl:node-set($headcols)/*)>=position()]">
                                                                <for-each select="exsl:node-set($cols)/*[count(exsl:node-set($headcols)/*)>=position()]">
-                                                                       <html:td>
+                                                                       <element name="td" namespace="&xhtml;">
                                                                                <attribute name="data-tsv-header">
                                                                                        <value-of select="exsl:node-set($headcols)/*[count(current()/preceding-sibling::*)+1]"/>
                                                                                </attribute>
                                                                                <attribute name="data-tsv-header">
                                                                                        <value-of select="exsl:node-set($headcols)/*[count(current()/preceding-sibling::*)+1]"/>
                                                                                </attribute>
@@ -74,16 +80,16 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                                <value-of select="."/>
                                                                                        </for-each>
                                                                                </if>
                                                                                                <value-of select="."/>
                                                                                        </for-each>
                                                                                </if>
-                                                                       </html:td>
+                                                                       </element>
                                                                </for-each>
                                                                <for-each select="exsl:node-set($headcols)/*[position()>count(exsl:node-set($cols)/*)]">
                                                                </for-each>
                                                                <for-each select="exsl:node-set($headcols)/*[position()>count(exsl:node-set($cols)/*)]">
-                                                                       <html:td/>
+                                                                       <element name="td" namespace="&xhtml;"/>
                                                                </for-each>
                                                                </for-each>
-                                                       </html:tr>
+                                                       </element>
                                                </otherwise>
                                        </choose>
                                </for-each>
                                                </otherwise>
                                        </choose>
                                </for-each>
-                       </html:tbody>
-               </html:table>
+                       </element>
+               </element>
        </template>
 </transform>
        </template>
 </transform>
This page took 0.039114 seconds and 4 git commands to generate.