Changeset 1494
- Timestamp:
- 08/25/11 13:35:55 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
metadata/trunk/toolkit/xslt/imdi2clarin.xsl
r1302 r1494 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <xsl:stylesheet xmlns="http://www.clarin.eu/cmd/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"3 xpath-default-namespace="http://www.mpi.nl/IMDI/Schema/IMDI">2 <xsl:stylesheet xmlns="http://www.clarin.eu/cmd/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version="2.0" xpath-default-namespace="http://www.mpi.nl/IMDI/Schema/IMDI"> 4 4 <!-- this is a version of imdi2clarin.xsl that batch processes a whole directory structure of imdi files, call it from the command line like this: 5 5 java -jar saxon8.jar -it main batch-imdi2clarin.xsl … … 10 10 <!-- A collection name can be specified for each record. This 11 11 information is extrinsic to the IMDI file, so it is given as an 12 external parameter. -->12 external parameter. Omit this if you are unsure. --> 13 13 <xsl:param name="collection"/> 14 14 15 <!-- If this optional parameter is defined, the behaviour of this 16 stylesheet changes in the following ways: If no archive handle is 17 available for MdSelfLink, the base URI is inserted there 18 instead. All links (ResourceProxy elements) that contain relative 19 paths are resolved into absolute URIs in the context of the base 20 URI. Omit this if you are unsure. --> 21 <xsl:param name="uri-base"/> 22 15 23 <xsl:template name="metatranscriptDelegate"> 16 <xsl:param name="profile" ></xsl:param>24 <xsl:param name="profile"/> 17 25 <Header> 18 26 <MdCreator>imdi2clarin.xsl</MdCreator> 19 27 <MdCreationDate><xsl:value-of select="format-date(current-date(), '[Y]-[M01]-[D01]')"/></MdCreationDate> 20 <MdSelfLink>test-<xsl:value-of select="@ArchiveHandle"/></MdSelfLink> 21 <MdProfile><xsl:value-of select="$profile"/></MdProfile> 28 <MdSelfLink> 29 <xsl:choose> 30 <xsl:when test="not($uri-base='') and normalize-space(@ArchiveHandle)=''"><xsl:value-of select="$uri-base"/></xsl:when> 31 <xsl:otherwise> 32 test-<xsl:value-of select="@ArchiveHandle"/> 33 </xsl:otherwise> 34 </xsl:choose> 35 </MdSelfLink> 36 <MdProfile> 37 <xsl:value-of select="$profile"/> 38 </MdProfile> 22 39 <xsl:if test="$collection"> 23 40 <MdCollectionDisplayName><xsl:value-of select="$collection"/></MdCollectionDisplayName> … … 41 58 <xsl:choose> 42 59 <xsl:when test=".[@Type='SESSION'] or .[@Type='SESSION.Profile']"> 43 <CMD CMDVersion="1.1" 44 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 60 <CMD CMDVersion="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 45 61 xsi:schemaLocation="http://www.clarin.eu/cmd/ http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1271859438204/xsd"> 46 62 <xsl:call-template name="metatranscriptDelegate"> … … 50 66 </xsl:when> 51 67 <xsl:when test=".[@Type='CORPUS'] or .[@Type='CORPUS.Profile']"> 52 <CMD CMDVersion="1.1" 53 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 68 <CMD CMDVersion="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 54 69 xsi:schemaLocation="http://www.clarin.eu/cmd/ http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1274880881885/xsd"> 55 70 <xsl:call-template name="metatranscriptDelegate"> … … 100 115 <ResourceProxy id="{generate-id()}"> 101 116 <ResourceType>Metadata</ResourceType> 102 <ResourceRef><xsl:value-of select="."/>.cmdi</ResourceRef> 117 <ResourceRef> 118 <xsl:choose> 119 <xsl:when test="$uri-base='' or starts-with(., 'hdl:')"><xsl:value-of select="."/>.cmdi</xsl:when> 120 <xsl:otherwise><xsl:value-of select="concat(resolve-uri(., $uri-base), '.cmdi')"/></xsl:otherwise> 121 </xsl:choose> 122 </ResourceRef> 103 123 </ResourceProxy> 104 124 </xsl:for-each> … … 115 135 </xsl:if>Resource</ResourceType> 116 136 <ResourceRef> 117 <xsl:value-of select="ResourceLink/@ArchiveHandle"/> 137 <xsl:choose> 138 <xsl:when test="not(normalize-space(ResourceLink/@ArchiveHandle)='')"><xsl:value-of select="ResourceLink/@ArchiveHandle"/></xsl:when> 139 <xsl:when test="not($uri-base='')"><xsl:value-of select="resolve-uri(ResourceLink/., $uri-base)"/></xsl:when> 140 </xsl:choose> 118 141 </ResourceRef> 119 142 </ResourceProxy> … … 128 151 </xsl:if>Resource</ResourceType> 129 152 <ResourceRef> 130 <xsl:value-of select="ResourceLink/@ArchiveHandle"/> 153 <xsl:choose> 154 <xsl:when test="not(normalize-space(ResourceLink/@ArchiveHandle)='')"><xsl:value-of select="ResourceLink/@ArchiveHandle"/></xsl:when> 155 <xsl:when test="not($uri-base='')"><xsl:value-of select="resolve-uri(ResourceLink/., $uri-base)"/></xsl:when> 156 </xsl:choose> 131 157 </ResourceRef> 132 158 </ResourceProxy> … … 730 756 </References> 731 757 </xsl:template> 732 758 733 759 <xsl:template name="main"> 734 760 <xsl:for-each … … 739 765 </xsl:for-each> 740 766 </xsl:template> 741 767 742 768 </xsl:stylesheet>
Note: See TracChangeset
for help on using the changeset viewer.