Skip to content

Commit

Permalink
map persons to the organisations they belong to if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanzadelhoff committed Sep 19, 2019
1 parent da4993e commit 9cb8815
Showing 1 changed file with 28 additions and 41 deletions.
69 changes: 28 additions & 41 deletions src/main/resources/iso2dcat.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -447,45 +447,38 @@

<xsl:template name="foafOrg">
<rdf:Description>
<xsl:variable name="orgLink" select="string(gmd:organisationName/gmx:Anchor/@xlink:href)"/>
<xsl:variable name="indLink" select="string(gmd:individualName/gmx:Anchor/@xlink:href)"/>
<xsl:choose>
<xsl:when test="$indLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$indLink"/></xsl:attribute>
</xsl:when>
<xsl:when test="$orgLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$orgLink"/></xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:variable name="orgName" select="string(gmd:organisationName/gco:CharacterString)"/>
<xsl:variable name="indName" select="string(gmd:individualName/gco:CharacterString)"/>
<xsl:choose>
<xsl:when test="$indName != ''">
<rdf:type rdf:resource="http:https://xmlns.com/foaf/0.1/Person"/>
</xsl:when>
<xsl:when test="$orgName != ''">
<rdf:type rdf:resource="http:https://xmlns.com/foaf/0.1/Organization"/>
<xsl:variable name="orgLink" select="string(gmd:organisationName/gmx:Anchor/@xlink:href)"/>
<xsl:if test="$orgLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$orgLink"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="gmd:organisationName/gco:CharacterString[text()]"/>
</xsl:when>
<xsl:when test="$indName != ''">
<rdf:type rdf:resource="http:https://xmlns.com/foaf/0.1/Person"/>
<xsl:variable name="indLink" select="string(gmd:individualName/gmx:Anchor/@xlink:href)"/>
<xsl:if test="$indLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$indLink"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="gmd:individualName/gco:CharacterString[text()]"/>
</xsl:when>
<xsl:otherwise>
<rdf:type rdf:resource="http:https://xmlns.com/foaf/0.1/Agent"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="gmd:organisationName[not(../gmd:individualName/gco:CharacterString/text())]/gco:CharacterString[text()]"/>
<xsl:apply-templates select="gmd:individualName/gco:CharacterString[text()]"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:address/*/gmd:electronicMailAddress/gco:CharacterString[not(contains(text, ';') or contains(text, ',') or contains(text, ' '))]"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:phone/*/gmd:voice/*[text()]"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:onlineResource/*/gmd:linkage/*[text()]"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:address/*"/>
</rdf:Description>
</xsl:template>

<xsl:template match="gmd:organisationName/gco:CharacterString">
<foaf:name><xsl:value-of select="."/></foaf:name>
</xsl:template>

<xsl:template match="gmd:individualName/gco:CharacterString">
<xsl:template match="gmd:organisationName/gco:CharacterString|gmd:individualName/gco:CharacterString">
<foaf:name><xsl:value-of select="."/></foaf:name>
<xsl:apply-templates select="../../gmd:organisationName/gco:CharacterString[text()]" mode="memberOf"/>
</xsl:template>

<xsl:template match="gmd:organisationName/gco:CharacterString" mode="memberOf">
Expand Down Expand Up @@ -542,43 +535,37 @@

<xsl:template name="vcardOrg">
<rdf:Description>
<xsl:variable name="orgLink" select="string(gmd:organisationName/gmx:Anchor/@xlink:href)"/>
<xsl:variable name="indLink" select="string(gmd:individualName/gmx:Anchor/@xlink:href)"/>
<xsl:choose>
<xsl:when test="$indLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$indLink"/></xsl:attribute>
</xsl:when>
<xsl:when test="$orgLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$orgLink"/></xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:variable name="orgName" select="string(gmd:organisationName/gco:CharacterString)"/>
<xsl:variable name="indName" select="string(gmd:individualName/gco:CharacterString)"/>
<xsl:choose>
<xsl:when test="$indName != ''">
<rdf:type rdf:resource="http:https://www.w3.org/2006/vcard/ns#Individual"/>
</xsl:when>
<xsl:when test="$orgName != ''">
<xsl:variable name="orgLink" select="string(gmd:organisationName/gmx:Anchor/@xlink:href)"/>
<xsl:if test="$orgLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$orgLink"/></xsl:attribute>
</xsl:if>
<rdf:type rdf:resource="http:https://www.w3.org/2006/vcard/ns#Organization"/>
<xsl:apply-templates select="gmd:organisationName/gco:CharacterString[text()]" mode="vcard"/>
</xsl:when>
<xsl:when test="$indName != ''">
<xsl:variable name="indLink" select="string(gmd:individualName/gmx:Anchor/@xlink:href)"/>
<xsl:if test="$indLink != ''">
<xsl:attribute name="rdf:resource"><xsl:value-of select="$indLink"/></xsl:attribute>
</xsl:if>
<rdf:type rdf:resource="http:https://www.w3.org/2006/vcard/ns#Individual"/>
<xsl:apply-templates select="gmd:individualName/gco:CharacterString[text()]" mode="vcard"/>
</xsl:when>
<xsl:otherwise>
<rdf:type rdf:resource="http:https://www.w3.org/2006/vcard/ns#Kind"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="gmd:organisationName/gco:CharacterString[text()]" mode="vcard"/>
<xsl:apply-templates select="gmd:individualName/gco:CharacterString[text()]" mode="vcard"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:address/*/gmd:electronicMailAddress/gco:CharacterString[not(contains(text, ';') or contains(text, ',') or contains(text, ' '))]" mode="vcard"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:phone/*/gmd:voice/*[text()]" mode="vcard"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:onlineResource/*/gmd:linkage/*[text()]" mode="vcard"/>
<xsl:apply-templates select="gmd:contactInfo/*/gmd:address/*" mode="vcard"/>
</rdf:Description>
</xsl:template>

<xsl:template match="gmd:organisationName/gco:CharacterString" mode="vcard">
<vcard:organization-name><xsl:value-of select="."/></vcard:organization-name>
</xsl:template>

<xsl:template match="gmd:individualName/gco:CharacterString" mode="vcard">
<xsl:template match="gmd:organisationName/gco:CharacterString|gmd:individualName/gco:CharacterString" mode="vcard">
<vcard:fn><xsl:value-of select="."/></vcard:fn>
</xsl:template>

Expand Down

0 comments on commit 9cb8815

Please sign in to comment.