Skip to content

Commit

Permalink
Try to parse more TEI links into data attributes
Browse files Browse the repository at this point in the history
Reuse the ID to label mapping.
  • Loading branch information
simar0at committed Oct 3, 2023
1 parent 8fd9946 commit 2eea4e6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 40 deletions.
41 changes: 2 additions & 39 deletions xslt/menu-json.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,8 @@
<xsl:output method="xml" indent="yes"/>

<xsl:param name="baseURIPublic"/>

<xsl:variable name="captionFromMenuID" select=" map{
'vicavArabicTools': 'Arabic Tools',
'vicavContributeBibliography': 'Contribute to Bibliography',
'vicavContributeDictionary': 'Contribute a Dictionary',
'vicavContributeFeature': 'Contribute a Feature List',
'vicavContributeProfile': 'Contribute a Profile',
'vicavContributeSample': 'Contribute a Sample',
'vicavContributors': 'Contributors',
'vicavDictionaryEncoding': 'Dictionaries (Encoding)',
'vicavDictionariesTechnicalities': 'Dictionaries (Technicalities)',
'vicavOverview_corpora_spoken': 'Corpora of Spoken Arabic',
'vicavOverview_corpora_msa': 'MSA Corpora',
'vicavOverview_special_corpora': 'Special Corpora',
'vicavOverview_corpora_historical_varieties': 'Corpora of Historical Language',
'vicavOverview_dictionaries': 'Dictionary Projects',
'vicavOverview_nlp': 'Arabic NLP',
'vicavOverview_otherStuff': 'Other Websites &amp; Projects',
'vicavLearning': 'Learning',
'vicavLearningTextbookDamascus': 'Textbook Damascus',
'vicavLearningSmartphone': 'VOCABULARIES on Smartphones',
'vicavLearningPrograms': 'Learning Programs',
'vicavLearningData': 'Learning Data',
'vicavKeyboards': 'Keyboards',
'vicavVLE': 'Dictionary Editor (VLE)',
'vicavExplanationBibliography': 'Bibliography (Details)',
'vicavExplanationCorpusTexts': 'Corpus Texts (Details)',
'vicavExplanationFeatures': 'Features (Details)',
'vicavExplanationProfiles': 'rofiles (Details)',
'vicavExplanationSamples': 'Samples (Details)',
'vicavExploreFeatures': 'Explore Features',
'vicavLinguistics': 'Linguistics',
'vicavMission': 'Mission',
'vicavNews': 'VICAV News',
'vicavTypesOfText': 'Types of Text'}"/>

<xsl:include href="vicavIDToLabel.xslt"/>

<xsl:function name="_:cleanID" as="xs:string">
<xsl:param name="in" as="xs:string"/>
Expand Down
44 changes: 44 additions & 0 deletions xslt/vicavIDToLabel.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns:_ = "urn:_"
version="3.1">

<xsl:variable name="captionFromMenuID" select=" map{
'vicavArabicTools': 'Arabic Tools',
'vicavContributeBibliography': 'Contribute to Bibliography',
'vicavContributeDictionary': 'Contribute a Dictionary',
'vicavContributeFeature': 'Contribute a Feature List',
'vicavContributeProfile': 'Contribute a Profile',
'vicavContributeSample': 'Contribute a Sample',
'vicavContributors': 'Contributors',
'vicavDictionaryEncoding': 'Dictionaries (Encoding)',
'vicavDictionariesTechnicalities': 'Dictionaries (Technicalities)',
'vicavOverview_corpora_spoken': 'Corpora of Spoken Arabic',
'vicavOverview_corpora_msa': 'MSA Corpora',
'vicavOverview_special_corpora': 'Special Corpora',
'vicavOverview_corpora_historical_varieties': 'Corpora of Historical Language',
'vicavOverview_dictionaries': 'Dictionary Projects',
'vicavOverview_nlp': 'Arabic NLP',
'vicavOverview_otherStuff': 'Other Websites &amp; Projects',
'vicavLearning': 'Learning',
'vicavLearningTextbookDamascus': 'Textbook Damascus',
'vicavLearningSmartphone': 'VOCABULARIES on Smartphones',
'vicavLearningPrograms': 'Learning Programs',
'vicavLearningData': 'Learning Data',
'vicavKeyboards': 'Keyboards',
'vicavVLE': 'Dictionary Editor (VLE)',
'vicavExplanationBibliography': 'Bibliography (Details)',
'vicavExplanationCorpusTexts': 'Corpus Texts (Details)',
'vicavExplanationFeatures': 'Features (Details)',
'vicavExplanationProfiles': 'rofiles (Details)',
'vicavExplanationSamples': 'Samples (Details)',
'vicavExploreFeatures': 'Explore Features',
'vicavLinguistics': 'Linguistics',
'vicavMission': 'Mission',
'vicavNews': 'VICAV News',
'vicavTypesOfText': 'Types of Text'}"/>
</xsl:stylesheet>
7 changes: 6 additions & 1 deletion xslt/vicavTexts.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
exclude-result-prefixes="#all"
version="2.0" >

<xsl:include href="vicavIDToLabel.xslt"/>

<xsl:variable name="openDictFuncToDictID" select='map{
"func:openDict_Damascus()": "dc_apc_eng_publ",
"func:openDict_Tunis()": "dc_tunico",
Expand All @@ -20,6 +22,9 @@
<xsl:choose>
<xsl:when test="starts-with($target, 'func:openDict_')">
<xsl:sequence select="('DictQuery', $openDictFuncToDictID($target), replace($target, 'func:openDict_([^(]+)\(.*', '$1 Dictionary Query'))"/>
</xsl:when>
<xsl:when test="starts-with($target, 'text:')">
<xsl:sequence select="('Text', replace($target, '^text:', ''), $captionFromMenuID(replace($target,'^text:', '')))"/>
</xsl:when>
<xsl:otherwise>
<xsl:analyze-string select="$target" regex="^([^:]+):([^/]+)/([^/,]+)[,/]?(([^/,]+)[,/]?)?(([^/,]+)[,/]?)?(([^/,]+)[,/]?)?(([^/,]+)[,/]?)?">
Expand All @@ -41,7 +46,7 @@
</xsl:when>
<xsl:otherwise>
<xsl:sequence>
<xsl:attribute name="data-target-type"><xsl:value-of select="$targetSplit[1]"/></xsl:attribute>
<xsl:attribute name="data-target-type"><xsl:value-of select="upper-case(substring($targetSplit[1], 1, 1))||substring($targetSplit[1], 2)"/></xsl:attribute>
<xsl:attribute name="data-text-id"><xsl:value-of select="$targetSplit[2]"/></xsl:attribute>
<xsl:attribute name="data-label"><xsl:value-of select="translate($targetSplit[3], '_', ' ')"/></xsl:attribute>
<xsl:for-each select="$targetSplit[position() > 3]"><xsl:attribute name="data-query-{position()}"><xsl:value-of select="."/></xsl:attribute></xsl:for-each>
Expand Down

0 comments on commit 2eea4e6

Please sign in to comment.