1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <xsl:stylesheet |
---|
3 | version="2.0" |
---|
4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
5 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
6 | xmlns:my="myFunctions" |
---|
7 | xmlns:owl="http://www.w3.org/2002/07/owl#" |
---|
8 | xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
---|
9 | > |
---|
10 | <!-- |
---|
11 | <purpose> generate a termMatrix for a datcat-profile (rdf-based = dublincore: http://dublincore.org/2008/01/14/dcelements.rdf#)</purpose> |
---|
12 | <strategy>map from rdf to Terms </strategy> |
---|
13 | <params> |
---|
14 | <param name=""></param> |
---|
15 | </params> |
---|
16 | <history> |
---|
17 | <change on="2010-10-10" type="created" by="vr"></change> |
---|
18 | </history> |
---|
19 | --> |
---|
20 | <xsl:import href="cmd_commons.xsl"/> |
---|
21 | |
---|
22 | <xsl:output method="xml" indent="yes" > </xsl:output> |
---|
23 | |
---|
24 | <xsl:param name="title" select="'Datcat terms'"></xsl:param> |
---|
25 | |
---|
26 | <xsl:template name="continue-root"> |
---|
27 | |
---|
28 | <xsl:message>continue in :<xsl:value-of select="name()" /></xsl:message> |
---|
29 | <xsl:choose> |
---|
30 | <xsl:when test="contains($format,'rr-rdf')" > |
---|
31 | <xsl:message>count rels:<xsl:value-of select="count(/rdf:RDF/rdf:Description)" /></xsl:message> |
---|
32 | <xsl:message>src_file:<xsl:value-of select="$src_file" /></xsl:message> |
---|
33 | <xsl:message>root_uri:<xsl:value-of select="$root_uri" /></xsl:message> |
---|
34 | <xsl:call-template name="rr" /> |
---|
35 | </xsl:when> |
---|
36 | <xsl:when test="//rdf:Property" > |
---|
37 | <xsl:message>count terms:<xsl:value-of select="count(//rdf:Property)" /></xsl:message> |
---|
38 | <xsl:apply-templates select="/rdf:RDF/rdf:Description" mode="init" /> |
---|
39 | </xsl:when> |
---|
40 | <xsl:otherwise> |
---|
41 | <xsl:apply-templates select="/rdf:RDF/rdf:Description[1]" mode="init" /> |
---|
42 | </xsl:otherwise> |
---|
43 | </xsl:choose> |
---|
44 | </xsl:template> |
---|
45 | |
---|
46 | <xsl:template match="rdf:Description" mode="init" > |
---|
47 | <Termset id="{@rdf:about}" label="{dcterms:title}" > |
---|
48 | <!-- different structures in: |
---|
49 | dcelements: --> |
---|
50 | <xsl:apply-templates select="/rdf:RDF/rdf:Property" /> |
---|
51 | <!-- and dcterms: --> |
---|
52 | <xsl:apply-templates select="/rdf:RDF/rdf:Description[position() > 1]" mode="dcterm" /> |
---|
53 | |
---|
54 | </Termset> |
---|
55 | </xsl:template> |
---|
56 | |
---|
57 | <xsl:template name="rr"> |
---|
58 | <xsl:variable name="rrroot" select="rdf:RDF" /> |
---|
59 | <Termset type="rr" > |
---|
60 | <!-- TODO: we have to match on ID/url! --> |
---|
61 | <xsl:copy-of select="$terms_setup//Termset[@type='rr']/@*" /> |
---|
62 | <xsl:for-each select="distinct-values(.//@rdf:about)" > <!-- .//@rdf:resource| --> |
---|
63 | <xsl:variable name="datcat1" select="." /> |
---|
64 | <Term type="rel" datcat="{$datcat1}" > |
---|
65 | <xsl:for-each select="$rrroot/rdf:Description[@rdf:about=$datcat1]" > |
---|
66 | <Term type="rel" reltype="{name(*[1])}" datcat="{*/@rdf:resource}" /> |
---|
67 | </xsl:for-each> |
---|
68 | <!-- <xsl:for-each select="$rrroot/rdf:Description[*/@rdf:resource=$datcat1]" > |
---|
69 | <Term type="rel" name="y" ref="{@rdf:about}" /> |
---|
70 | </xsl:for-each> --> |
---|
71 | </Term> |
---|
72 | </xsl:for-each> |
---|
73 | </Termset> |
---|
74 | |
---|
75 | </xsl:template> |
---|
76 | |
---|
77 | |
---|
78 | <!-- <Term elem="TextCorpusProfile" datcat="" corresponding_component="" parent="" context=".TextCorpusProfile" |
---|
79 | name="TextCorpusProfile" count="8" count_text="199" count_distinct_text="87" path="TextCorpusProfile"/> |
---|
80 | --> |
---|
81 | <xsl:template match="rdf:Property" > |
---|
82 | <Term type="datcat" name="{rdfs:label}" datcat="{@rdf:about}" id="{@rdf:about}"> |
---|
83 | <xsl:for-each select="*" > |
---|
84 | <xsl:element name="{name()}" ><xsl:value-of select="." /></xsl:element> |
---|
85 | </xsl:for-each> |
---|
86 | </Term> |
---|
87 | </xsl:template> |
---|
88 | |
---|
89 | <xsl:template match="rdf:Description" mode="dcterm" > |
---|
90 | <Term type="datcat" name="{rdfs:label}" datcat="{@rdf:about}" id="{@rdf:about}"> |
---|
91 | <xsl:for-each select="*" > |
---|
92 | <xsl:element name="{name()}" ><xsl:value-of select="." /></xsl:element> |
---|
93 | </xsl:for-each> |
---|
94 | </Term> |
---|
95 | </xsl:template> |
---|
96 | |
---|
97 | </xsl:stylesheet> |
---|