1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
3 | xmlns:my="myFunctions" |
---|
4 | version="2.0"> |
---|
5 | |
---|
6 | <!-- the stylesheet for the operation mode: |
---|
7 | uses the prepared map to resolve terms to other terms, or list available terms. |
---|
8 | --> |
---|
9 | <xsl:include href="smc_commons.xsl"/> |
---|
10 | |
---|
11 | <xsl:output indent="yes"></xsl:output> |
---|
12 | |
---|
13 | <!-- user input-params --> |
---|
14 | <xsl:param name="operation">list</xsl:param> <!-- list | map --> |
---|
15 | <xsl:param name="context">*</xsl:param> |
---|
16 | <xsl:param name="term"></xsl:param> |
---|
17 | <xsl:param name="relset"></xsl:param> |
---|
18 | <!--<xsl:param name="lang">pt</xsl:param>--> |
---|
19 | |
---|
20 | |
---|
21 | <xsl:template match="/"> |
---|
22 | <xsl:choose> |
---|
23 | <xsl:when test="$operation='map'"> |
---|
24 | <Terms> |
---|
25 | <xsl:variable name="matching_concepts" > |
---|
26 | <xsl:choose> |
---|
27 | <xsl:when test="$relset=''"> |
---|
28 | <xsl:copy-of select="$dcr-cmd-map//Concept[Term/lower-case(text())=lower-case($term)]" /> |
---|
29 | </xsl:when> |
---|
30 | <xsl:otherwise> |
---|
31 | <xsl:variable name="matching-concept" select="$dcr-cmd-map//Concept[Term/lower-case(text())=lower-case($term)]" /> |
---|
32 | <!-- this returns both, the original concept and the expanded/related one --> |
---|
33 | <xsl:variable name="related-concepts" select="$rr-relations//Termset[@set='rr-cmdi']//Concept[@id=$matching-concept/@id]/parent::Relation/Concept" /> |
---|
34 | <xsl:copy-of select="$dcr-cmd-map//Concept[@id = $related-concepts/@id]" /> |
---|
35 | </xsl:otherwise> |
---|
36 | </xsl:choose> |
---|
37 | |
---|
38 | </xsl:variable> |
---|
39 | <xsl:for-each select="$matching_concepts//Term[@set='cmd']"> |
---|
40 | <xsl:copy-of select="." /> |
---|
41 | </xsl:for-each> |
---|
42 | </Terms> |
---|
43 | </xsl:when> |
---|
44 | <xsl:when test="$operation='list' and $context='*' or $context='top'"> |
---|
45 | <xsl:copy-of select="my:getData('termsets')"></xsl:copy-of> |
---|
46 | </xsl:when> |
---|
47 | <!-- list all terms of given context--> |
---|
48 | <xsl:when test="$operation='list'"> |
---|
49 | <!--separate handling for isocat, because of lang --> |
---|
50 | <xsl:choose> |
---|
51 | <xsl:when test="starts-with($context, 'isocat')"> |
---|
52 | <xsl:variable name="lang" select="if(starts-with($context, 'isocat')) then substring-after($context, 'isocat-') else 'en'"></xsl:variable> |
---|
53 | <Termset set="{$context}" xml:lang="{$lang}"> |
---|
54 | <xsl:for-each select="$dcr-cmd-map//Term[@set='isocat' and @xml:lang=$lang]" > |
---|
55 | <xsl:copy > |
---|
56 | <xsl:copy-of select="@*" /> |
---|
57 | <xsl:attribute name="concept-id" select="ancestor::Concept/@id"></xsl:attribute> |
---|
58 | <xsl:value-of select="." /> |
---|
59 | </xsl:copy> |
---|
60 | </xsl:for-each> |
---|
61 | </Termset> |
---|
62 | </xsl:when> |
---|
63 | <xsl:otherwise> |
---|
64 | <Termset set="{$context}" > |
---|
65 | <xsl:for-each select="$dcr-cmd-map//Term[@set=$context]" > |
---|
66 | <xsl:copy > |
---|
67 | <xsl:copy-of select="@*" /> |
---|
68 | <xsl:attribute name="concept-id" select="ancestor::Concept/@id"></xsl:attribute> |
---|
69 | <xsl:value-of select="." /> |
---|
70 | </xsl:copy> |
---|
71 | |
---|
72 | </xsl:for-each> |
---|
73 | </Termset> |
---|
74 | </xsl:otherwise> |
---|
75 | </xsl:choose> |
---|
76 | |
---|
77 | </xsl:when> |
---|
78 | <xsl:otherwise> |
---|
79 | <diagnostics>unknown operation: <xsl:value-of select="$operation"></xsl:value-of></diagnostics> |
---|
80 | </xsl:otherwise> |
---|
81 | </xsl:choose> |
---|
82 | |
---|
83 | </xsl:template> |
---|
84 | |
---|
85 | </xsl:stylesheet> |
---|