summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
84e79eb)
- `<书社:apply-attributes>` should not prevent H·T·M·L from wrapping.
Note that the H·T·M·L wrapper is still not
`<书社:apply-attributes>`‐aware; it will _not_ seek into the wrapped
contents to search for attributes to pull upwards to the root
element. This could probably be improved.
- `@书社:archived-as` can now be applied to `<书社:link>` and will be
passed down to any embedded contents.
- `@书社:archived-as` will not be deleted during attribute application
onto the root element; it now ensures there is a nonroot, nonarchive
ancestor. This is required because archive children are processed
into a separate document prior to application.
An alternative approach might be to wrap archive children in a
`<书社:archive>` element before application and then strip it after,
but this is a fair bit of added work for little benefit. It’s a fair
question whether removing invalid `@书社:*` attributes like this is
even a good practice—invalid `<书社:link>` elements are maintained,
in contrast.
<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: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='archived-as' and $context-nodes/ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)][position()=1 and not(self::书社:archive)]"/>
<xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping' or @local-name='version')"/>
<xslt:when test="preceding-sibling::*[@local-name=current()/@local-name and @namespace-uri=current()/@namespace-uri]"/>
<xslt:otherwise>
<xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping' or @local-name='version')"/>
<xslt:when test="preceding-sibling::*[@local-name=current()/@local-name and @namespace-uri=current()/@namespace-uri]"/>
<xslt:otherwise>
</html:html>
</xslt:template>
<xslt:template match="/" priority="1">
</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: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"/>
<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"/>
</xslt:variable>
<xslt:variable name="wrapped-component-fragment">
<xslt:for-each select="exsl:node-set($component-fragment)/*">
</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: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: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>
</xslt:call-template>
</xslt:otherwise>
</xslt:choose>
</xslt:copy>
</xslt:template>
<xslt:template match="书社:link[@xlink:show='embed' and (not(@xlink:actuate) or @xlink:actuate='none')]" mode="书社:expand" priority="1">
</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)]"/>
<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)]"/>
</xslt:text>
</xslt:if>
</xslt:attribute>
</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: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>
</xslt:otherwise>
</xslt:choose>
</xslt:copy>