-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add xsl for handling clinical trial numbers (#157)
* Add xsl for handling clinical trial numbers * Update kitchen sink and all other test cases * Add readme description * tweak whitespace in output * add missing text in templates * Add test case for new xsl and update all case
- Loading branch information
1 parent
bee27fd
commit 30d9739
Showing
26 changed files
with
1,181 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
exclude-result-prefixes="xs" | ||
version="3.0"> | ||
|
||
<xsl:output method="xml" encoding="UTF-8"/> | ||
|
||
<xsl:template match="*|@*|text()|comment()|processing-instruction()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<!-- Only match on related-objects which are determined to be clinical trial numbers with a link --> | ||
<xsl:template match="related-object[@xlink:href!='' and @document-id-type='clinical-trial-number']"> | ||
<xsl:choose> | ||
<!-- This is in a structured abstract: replace with a link --> | ||
<xsl:when test="parent::p/parent::sec and ancestor::abstract"> | ||
<xsl:element name="ext-link"> | ||
<xsl:attribute name="ext-link-type">uri</xsl:attribute> | ||
<xsl:apply-templates select="@xlink:href|*|text()|comment()|processing-instruction()"/> | ||
</xsl:element> | ||
</xsl:when> | ||
<!-- This is simply included in the narrative flow: replace with a link --> | ||
<xsl:when test="parent::p or parent::th or parent::td"> | ||
<xsl:element name="ext-link"> | ||
<xsl:attribute name="ext-link-type">uri</xsl:attribute> | ||
<xsl:apply-templates select="@xlink:href|*|text()|comment()|processing-instruction()"/> | ||
</xsl:element> | ||
</xsl:when> | ||
<!-- else: do nothing, retain it as related-object --> | ||
<xsl:otherwise> | ||
<xsl:copy> | ||
<xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/> | ||
</xsl:copy> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
<!-- Introduce related-objects placed within article-meta into additional information sections | ||
This case handles when an additional information section already exists in back --> | ||
<xsl:template match="article[descendant::article-meta/related-object[@xlink:href!='' and @document-id-type='clinical-trial-number']]/back/sec[@sec-type='additional-information' or matches(lower-case(title[1]),'^additional information$')]"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/> | ||
<xsl:element name="sec"> | ||
<xsl:text>
</xsl:text> | ||
<xsl:element name="p"> | ||
<xsl:text>Clinical trial number: </xsl:text> | ||
<xsl:for-each select="ancestor::article//article-meta/related-object[@xlink:href!='' and @document-id-type='clinical-trial-number']"> | ||
<xsl:choose> | ||
<xsl:when test="position() = 1"> | ||
<xsl:element name="ext-link"> | ||
<xsl:attribute name="ext-link-type">uri</xsl:attribute> | ||
<xsl:apply-templates select="@xlink:href|*|text()|comment()|processing-instruction()"/> | ||
</xsl:element> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:text>; </xsl:text> | ||
<xsl:element name="ext-link"> | ||
<xsl:attribute name="ext-link-type">uri</xsl:attribute> | ||
<xsl:apply-templates select="@xlink:href|*|text()|comment()|processing-instruction()"/> | ||
</xsl:element> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:for-each> | ||
<xsl:text>.</xsl:text> | ||
</xsl:element> | ||
<xsl:text>
</xsl:text> | ||
</xsl:element> | ||
<xsl:text>
</xsl:text> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<!-- Introduce related-objects placed within article-meta into additional information sections | ||
This case handles when an additional information section does not exist in back --> | ||
<xsl:template match="article[descendant::article-meta/related-object[@xlink:href!='' and @document-id-type='clinical-trial-number']]/back[not(sec[@sec-type='additional-information' or matches(lower-case(title[1]),'^additional information$')])]"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/> | ||
<xsl:element name="sec"> | ||
<xsl:attribute name="sec-type">additional-information</xsl:attribute> | ||
<xsl:text>
</xsl:text> | ||
<xsl:element name="title">Additional information</xsl:element> | ||
<xsl:text>
</xsl:text> | ||
<xsl:element name="sec"> | ||
<xsl:text>
</xsl:text> | ||
<xsl:element name="p"> | ||
<xsl:text>Clinical trial number: </xsl:text> | ||
<xsl:for-each select="ancestor::article//article-meta/related-object[@xlink:href!='' and @document-id-type='clinical-trial-number']"> | ||
<xsl:choose> | ||
<xsl:when test="position() = 1"> | ||
<xsl:element name="ext-link"> | ||
<xsl:attribute name="ext-link-type">uri</xsl:attribute> | ||
<xsl:apply-templates select="@xlink:href|*|text()|comment()|processing-instruction()"/> | ||
</xsl:element> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:text>; </xsl:text> | ||
<xsl:element name="ext-link"> | ||
<xsl:attribute name="ext-link-type">uri</xsl:attribute> | ||
<xsl:apply-templates select="@xlink:href|*|text()|comment()|processing-instruction()"/> | ||
</xsl:element> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:for-each> | ||
<xsl:text>.</xsl:text> | ||
</xsl:element> | ||
<xsl:text>
</xsl:text> | ||
</xsl:element> | ||
<xsl:text>
</xsl:text> | ||
</xsl:element> | ||
<xsl:text>
</xsl:text> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.