]> Lady’s Gitweb - Shushe/blobdiff - lib/catalog2transform.xslt
Don’t remove invalid @书社:* attributes
[Shushe] / lib / catalog2transform.xslt
index 05ca7d52627e49520589f477ea447b9955bbcbe2..10a5479a4ff4f5ea2d9c5e93cd6818b394dac322 100644 (file)
@@ -143,8 +143,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                        <xslt:choose>
                                                                                <xslt:when test="@namespace-uri='&xml;'"/>
                                                                                <xslt:when test="$context[self::html:* or self::svg:*] and @namespace-uri='' and @local-name='lang'"/>
-                                                                               <xslt:when test="@namespace-uri='&书社;' and @local-name='archived-as' and not($context-nodes/ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)][1][self::书社:archive])"/>
-                                                                               <xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping' or @local-name='version')"/>
+                                                                               <xslt:when test="$and-version and $THISREV and @namespace-uri='&书社;' and @local-name='version'"/>
+                                                                               <xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping')"/>
                                                                                <xslt:when test="preceding-sibling::*[@local-name=current()/@local-name and @namespace-uri=current()/@namespace-uri]"/>
                                                                                <xslt:otherwise>
                                                                                        <xslt:attribute>
@@ -262,10 +262,11 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </html:html>
                        </xslt:template>
                        <xslt:template match="/" priority="1">
-                               <xslt:variable name="result-nodes" select="$书社:result/node()[not(self::书社:apply-attributes-to-root)]|$书社:result/书社:apply-attributes-to-root/descendant::node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
+                               <xslt:variable name="result-nodes" select="$书社:result/node()[not(self::书社:apply-attributes-to-root)]|$书社:result/书社:apply-attributes-to-root//node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
+                               <xslt:variable name="significant-nodes" select="$result-nodes/descendant-or-self::*[not(self::书社:apply-attributes) and not(ancestor::*[not(self::书社:apply-attributes)])]"/>
                                <xslt:variable name="root-with-attributes">
                                        <xslt:choose>
-                                               <xslt:when test="not($result-nodes/self::html:*) or $result-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive'] or $result-nodes/@书社:disable-output-wrapping or $书社:result//书社:apply-attributes-to-root/@书社:disable-output-wrapping">
+                                               <xslt:when test="not($significant-nodes/self::html:*) or $significant-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive'] or $significant-nodes/@书社:disable-output-wrapping or $书社:result//书社:apply-attributes-to-root/@书社:disable-output-wrapping">
                                                        <xslt:call-template name="书社:apply-attributes">
                                                                <xslt:with-param name="and-version" select="true()"/>
                                                                <xslt:with-param name="context-nodes" select="$书社:result//书社:apply-attributes-to-root"/>
@@ -293,17 +294,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        <xslt:apply-templates select="@*|node()"/>
                                </xslt:copy>
                        </xslt:template>
-                       <xslt:template match="@书社:destination|@书社:disable-output-wrapping|@书社:archived-as[../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]]" mode="书社:apply" priority="1"/>
+                       <xslt:template match="@书社:destination|@书社:disable-output-wrapping" mode="书社:apply" priority="1"/>
                        <xslt:template match="书社:archive" mode="书社:apply" priority="1">
                                <xslt:copy>
-                                       <xslt:for-each select="@*">
-                                               <xslt:choose>
-                                                       <xslt:when test="local-name()='archived-as' and namespace-uri()='&书社;' and ../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]"/>
-                                                       <xslt:otherwise>
-                                                               <xslt:apply-templates select="." mode="书社:apply"/>
-                                                       </xslt:otherwise>
-                                               </xslt:choose>
-                                       </xslt:for-each>
+                                       <xslt:apply-templates select="@*" mode="书社:apply"/>
                                        <xslt:for-each select="node()">
                                                <xslt:choose>
                                                        <xslt:when test="self::*">
@@ -343,13 +337,15 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </xslt:variable>
                                                                <xslt:variable name="wrapped-component-fragment">
                                                                        <xslt:for-each select="exsl:node-set($component-fragment)/*">
+                                                                               <xslt:variable name="result-nodes" select="self::*[not(self::书社:apply-attributes-to-root)]|self::书社:apply-attributes-to-root//node()[not(self::书社:apply-attributes-to-root) and not(ancestor::*[not(self::书社:apply-attributes-to-root)])]"/>
+                                                                               <xslt:variable name="significant-nodes" select="$result-nodes/descendant-or-self::*[not(self::书社:apply-attributes) and not(ancestor::*[not(self::书社:apply-attributes)])]"/>
                                                                                <xslt:choose>
-                                                                                       <xslt:when test="self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive']|@书社:disable-output-wrapping">
+                                                                                       <xslt:when test="not($significant-nodes/self::html:*) or $significant-nodes/self::书社:*[local-name()='raw-text' or local-name()='base64-binary' or local-name()='archive'] or $significant-nodes/@书社:disable-output-wrapping">
                                                                                                <xslt:copy-of select="."/>
                                                                                        </xslt:when>
                                                                                        <xslt:otherwise>
                                                                                                <xslt:call-template name="书社:wrap">
-                                                                                                       <xslt:with-param name="nodes" select="."/>
+                                                                                                       <xslt:with-param name="nodes" select="$result-nodes"/>
                                                                                                </xslt:call-template>
                                                                                        </xslt:otherwise>
                                                                                </xslt:choose>
@@ -382,6 +378,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </xslt:copy>
                        </xslt:template>
                        <xslt:template match="书社:link[@xlink:show='embed' and (not(@xlink:actuate) or @xlink:actuate='none')]" mode="书社:expand" priority="1">
+                               <xslt:variable name="link" select="."/>
                                <xslt:variable name="identifier" select="string(@xlink:href)"/>
                                <xslt:variable name="is-dir" select="substring($identifier, string-length($identifier))='/'"/>
                                <xslt:variable name="included" select="$书社:about//*[@rdf:about=$identifier or $is-dir and starts-with(@rdf:about, $identifier)]"/>
@@ -421,10 +418,26 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                                        </xslt:text>
                                                                                                </xslt:if>
                                                                                        </xslt:attribute>
-                                                                                       <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()"/>
+                                                                                       <xslt:choose>
+                                                                                               <xslt:when test="$link/@书社:archived-as">
+                                                                                                       <xslt:copy-of select="$link/@书社:archived-as"/>
+                                                                                               </xslt:when>
+                                                                                               <xslt:when test="@书社:archived-as">
+                                                                                                       <xslt:copy-of select="@书社:archived-as"/>
+                                                                                               </xslt:when>
+                                                                                       </xslt:choose>
+                                                                                       <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype')) and not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
                                                                                </xslt:when>
                                                                                <xslt:otherwise>
-                                                                                       <xslt:copy-of select="@*|node()"/>
+                                                                                       <xslt:choose>
+                                                                                               <xslt:when test="self::* and $link/@书社:archived-as">
+                                                                                                       <xslt:copy-of select="$link/@书社:archived-as"/>
+                                                                                               </xslt:when>
+                                                                                               <xslt:when test="@书社:archived-as">
+                                                                                                       <xslt:copy-of select="@书社:archived-as"/>
+                                                                                               </xslt:when>
+                                                                                       </xslt:choose>
+                                                                                       <xslt:copy-of select="@*[not(namespace-uri()='&书社;' and local-name()='archived-as')]|node()"/>
                                                                                </xslt:otherwise>
                                                                        </xslt:choose>
                                                                </xslt:copy>
This page took 0.028076 seconds and 4 git commands to generate.