Skip to content

Commit 70f9a27

Browse files
committed
fixup! fixup! fixup! fixup! fixup! New implementation of TEI to Markdown, and Markdown to TEI conversions using XSLT
1 parent 0503b9f commit 70f9a27

File tree

2 files changed

+77
-7
lines changed

2 files changed

+77
-7
lines changed

src/main/xar-resources/services/tei-to-tei-form.xslt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,18 @@
174174
</xsl:call-template>
175175
</xsl:template>
176176

177-
<xsl:template match="tei:relation[tei:mutual or tei:active or tei:passive]">
177+
<xsl:template match="tei:relation[tei:active or tei:mutual or tei:passive]">
178178
<xsl:copy>
179-
<xsl:apply-templates select="@*[not(name(.) = ('active', 'passive', 'mutual'))]"/>
180-
<xsl:attribute name="active" select="string-join(tei:active/@ref, ' ')"/>
181-
<xsl:attribute name="passive" select="string-join(tei:passive/@ref, ' ')"/>
182-
<xsl:attribute name="mutual" select="string-join(tei:mutual/@ref, ' ')"/>
179+
<xsl:apply-templates select="@*[not(name(.) = ('active', 'mutual', 'passive'))]"/>
180+
<xsl:if test="tei:active/@ref">
181+
<xsl:attribute name="active" select="string-join(tei:active/@ref, ' ')"/>
182+
</xsl:if>
183+
<xsl:if test="tei:mutual/@ref">
184+
<xsl:attribute name="mutual" select="string-join(tei:mutual/@ref, ' ')"/>
185+
</xsl:if>
186+
<xsl:if test="tei:passive/@ref">
187+
<xsl:attribute name="passive" select="string-join(tei:passive/@ref, ' ')"/>
188+
</xsl:if>
183189
</xsl:copy>
184190
</xsl:template>
185191

src/test/xar-resources/services/tei-to-tei-form.xspec

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,71 @@
18061806

18071807
</x:scenario>
18081808

1809-
<x:scenario label="Given a Relation Element"
1810-
pending="TODO(AR) implement these tests for tei:relation"> </x:scenario>
1809+
<x:scenario label="Given a Relation Element">
1810+
1811+
<x:scenario label="When it has an Active child Element">
1812+
<x:context>
1813+
<tei:relation>
1814+
<tei:active ref="active-1"/>
1815+
</tei:relation>
1816+
</x:context>
1817+
<x:expect label="Then transform the Active child Element into an Attribute">
1818+
<tei:relation active="active-1"/>
1819+
</x:expect>
1820+
</x:scenario>
1821+
1822+
<x:scenario label="When it has a Mutual child Element">
1823+
<x:context>
1824+
<tei:relation>
1825+
<tei:mutual ref="mutual-1"/>
1826+
</tei:relation>
1827+
</x:context>
1828+
<x:expect label="Then transform the Mutual child Element into an Attribute">
1829+
<tei:relation mutual="mutual-1"/>
1830+
</x:expect>
1831+
</x:scenario>
1832+
1833+
<x:scenario label="When it has a Passive child Element">
1834+
<x:context>
1835+
<tei:relation>
1836+
<tei:passive ref="passive-1"/>
1837+
</tei:relation>
1838+
</x:context>
1839+
<x:expect label="Then transform the Passive child Element into an Attribute">
1840+
<tei:relation passive="passive-1"/>
1841+
</x:expect>
1842+
</x:scenario>
1843+
1844+
<x:scenario label="When it has no Active, Mutual, or Passive child Elements">
1845+
<x:context>
1846+
<tei:relation>
1847+
<tei:desc>
1848+
<tei:idno>desc-1</tei:idno>
1849+
</tei:desc>
1850+
</tei:relation>
1851+
</x:context>
1852+
<x:expect label="Then copy as is">
1853+
<tei:relation>
1854+
<tei:desc>
1855+
<tei:idno>desc-1</tei:idno>
1856+
</tei:desc>
1857+
</tei:relation>
1858+
</x:expect>
1859+
</x:scenario>
1860+
1861+
<x:scenario label="When it has Active, Mutual, and Passive child Elements">
1862+
<x:context>
1863+
<tei:relation>
1864+
<tei:active ref="active-1"/>
1865+
<tei:mutual ref="mutual-1"/>
1866+
<tei:passive ref="passive-1"/>
1867+
</tei:relation>
1868+
</x:context>
1869+
<x:expect label="Then transform the Active, Mutual, and Passive child Elements into an Attributes">
1870+
<tei:relation active="active-1" mutual="mutual-1" passive="passive-1"/>
1871+
</x:expect>
1872+
</x:scenario>
1873+
1874+
</x:scenario>
18111875

18121876
</x:description>

0 commit comments

Comments
 (0)