1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:ics="http://www.icsmed.de/xslt">
<!-- =====================================================================
|
| Copyright (C) 2007, ICSMED AG
|
| This software and supporting documentation were developed by
|
| ICSMED AG
| Escherweg 2
| 26121 Oldenburg
| Germany
|
| Purpose: Convert DICOM data dictionary from GDCM to DCMTK format.
|
======================================================================= -->
<!-- GENERAL -->
<xsl:output method="text" indent="no" encoding="ISO-8859-1"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="apos">'</xsl:variable>
<!-- default edition of the DICOM standard (if not specified in the input file) -->
<xsl:param name="dicom-default-edition" select="'2007'"/>
<!-- actually used edition of the DICOM standard -->
<xsl:variable name="dicom-edition" select="if (string(/dict/@edition)) then /dict/@edition else $dicom-default-edition"/>
<!-- MAIN -->
<xsl:template match="/dicts">
<!--xsl:call-template name="add-copyright-note"/-->
<!--xsl:call-template name="add-generator-note"/-->
<!-- iterate over all entries -->
<xsl:for-each select="dict/entry">
<xsl:sort select="@group"/>
<xsl:sort select="@element"/>
<!--xsl:variable name="attribute-name" select="ics:to-camel-case(ics:convert-chars(description))"/-->
<xsl:variable name="attribute-name" select="ics:to-camel-case(ics:convert-chars(@name))"/>
<!-- output tag -->
<xsl:choose>
<!-- repeating group -->
<xsl:when test="contains(@group,'xx')">
<xsl:value-of select="concat('(',substring(@group,1,2),'00-',substring(@group,1,2),'FF,',upper-case(@element),')	')"/>
</xsl:when>
<xsl:when test="contains(@element,'xx')">
<xsl:value-of select="concat('(',upper-case(@group),',',substring(@element,1,2),'00-',substring(@element,1,2),'FF)	')"/>
</xsl:when>
<!-- standard case -->
<xsl:otherwise>
<xsl:value-of select="concat('(',upper-case(@group),',',upper-case(@element),')	')"/>
</xsl:otherwise>
</xsl:choose>
<!-- output VR -->
<xsl:choose>
<!-- offset attribute for DICOMDIR -->
<xsl:when test="@group='0004' and contains($attribute-name,'Offset')">
<xsl:value-of select="'up	'"/>
</xsl:when>
<!-- multiple value representations -->
<xsl:when test="@vr='OB_OW'">
<xsl:value-of select="'ox	'"/>
</xsl:when>
<xsl:when test="@vr='US_SS'">
<xsl:value-of select="'xs	'"/>
</xsl:when>
<xsl:when test="@vr='US_SS_OW'">
<xsl:value-of select="'lt	'"/>
</xsl:when>
<!-- standard case -->
<xsl:when test="string(@vr)">
<xsl:value-of select="concat(@vr,'	')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'na	'"/>
</xsl:otherwise>
</xsl:choose>
<!-- output name -->
<xsl:choose>
<xsl:when test="@version='2'">
<xsl:value-of select="concat('ACR_NEMA_',$attribute-name,'	')"/>
</xsl:when>
<xsl:when test="@retired='true'">
<xsl:value-of select="concat('RETIRED_',$attribute-name,'	')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($attribute-name,'	')"/>
</xsl:otherwise>
</xsl:choose>
<!-- output VM -->
<xsl:choose>
<xsl:when test="string(@vm)">
<xsl:value-of select="concat(@vm,'	')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'1	'"/>
</xsl:otherwise>
</xsl:choose>
<!-- output version -->
<xsl:choose>
<xsl:when test="@version='2'">
<xsl:value-of select="'ACR/NEMA2'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'DICOM'"/>
</xsl:otherwise>
</xsl:choose>
<!-- output newline -->
<xsl:value-of select="' '"/>
</xsl:for-each>
</xsl:template>
<!-- TEMPLATES -->
<xsl:template name="add-copyright-note">
<xsl:value-of select="concat('# Copyright 1994-',fn:format-date(fn:current-date(),'[Y0001]'),' by OFFIS e.V. and ICSMED AG, Oldenburg, Germany ')"/>
<xsl:value-of select="'# Thanks to Mathieu Malaterre for the XML version of the DICOM standard text '"/>
</xsl:template>
<xsl:template name="add-generator-note">
<xsl:value-of select="concat('# Generated automatically from DICOM PS 3.6-',$dicom-edition,' and PS 3.7-',$dicom-edition,' ')"/>
<xsl:value-of select="concat('# File created on ',fn:format-dateTime(fn:current-dateTime(),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]')),' '"/>
<xsl:value-of select="'# Last modified on YYYY-MM-DD by NOBODY '"/>
</xsl:template>
<!-- FUNCTIONS -->
<xsl:function name="ics:to-camel-case" as="xs:string*">
<xsl:param name="string" as="xs:string*"/>
<!-- create camel case string -->
<xsl:variable name="result">
<xsl:for-each select="tokenize($string,'-| |/')">
<xsl:value-of select="concat(upper-case(substring(.,1,1)),substring(.,2))"/>
</xsl:for-each>
</xsl:variable>
<!-- compose result string -->
<xsl:sequence select="ics:remove-invalid-chars($result)"/>
</xsl:function>
<xsl:function name="ics:remove-invalid-chars" as="xs:string*">
<xsl:param name="string" as="xs:string*"/>
<xsl:sequence select="translate($string,concat($apos,' -/%^.,‘’()[]&‑'),'')"/>
</xsl:function>
<xsl:function name="ics:convert-chars" as="xs:string*">
<xsl:param name="string" as="xs:string*"/>
<xsl:sequence select="fn:replace($string,'µ|','micro')"/>
</xsl:function>
</xsl:stylesheet>
|