[16] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
| 2 | <xsl:stylesheet |
---|
| 3 | version="1.0" |
---|
| 4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
| 5 | xmlns:witsml="http://www.witsml.org/schemas/131"> |
---|
| 6 | |
---|
| 7 | <xsl:output method="html" /> |
---|
| 8 | |
---|
| 9 | <!-- Unit of Measure Element linked to the unit file. --> |
---|
| 10 | <xsl:template match="*" mode="UnitRef"> |
---|
| 11 | <xsl:call-template name="uomRefString"> |
---|
| 12 | <xsl:with-param name="string" select="."/> |
---|
| 13 | <xsl:with-param name="path" select="'../ancillary/witsmlUnitDict.html'"/> |
---|
| 14 | </xsl:call-template> |
---|
| 15 | </xsl:template> |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | <!-- Uom attribute linked to the unit file. --> |
---|
| 19 | <xsl:template match="*" mode="UomRef"> |
---|
| 20 | <xsl:call-template name="uomRefString"> |
---|
| 21 | <xsl:with-param name="string" select="@uom"/> |
---|
| 22 | <xsl:with-param name="path" select="'../ancillary/witsmlUnitDict.html'"/> |
---|
| 23 | </xsl:call-template> |
---|
| 24 | </xsl:template> |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | <!-- Measure value with a unit of measure linked to the unit file. --> |
---|
| 28 | <xsl:template match="*" mode="valueWithUomRef"> |
---|
| 29 | <xsl:value-of select="."/> |
---|
| 30 | <xsl:text> </xsl:text> |
---|
| 31 | <xsl:call-template name="uomRefString"> |
---|
| 32 | <xsl:with-param name="path" select="'../ancillary/witsmlUnitDict.html'"/> |
---|
| 33 | </xsl:call-template> |
---|
| 34 | <!-- In case this is a coordinate, check for datum. --> |
---|
| 35 | <xsl:if test="@datum"> |
---|
| 36 | <xsl:text> </xsl:text> |
---|
| 37 | (<xsl:value-of select="@datum"/>) |
---|
| 38 | </xsl:if> |
---|
| 39 | </xsl:template> |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | <!-- Template to create a name anchor or to create an href to a uom in the WITSML unit file. --> |
---|
| 43 | <!-- Add an underscore in front of Uppercase characters in the string. --> |
---|
| 44 | <!-- Also substitute T (times) and P (per) for period (.) and slash (/). --> |
---|
| 45 | <xsl:template name="uomRefString"> |
---|
| 46 | <xsl:param name="string" select="@uom"/> <!-- The uom string. --> |
---|
| 47 | <xsl:param name="index" select="1"/> <!-- The start index in the string. --> |
---|
| 48 | <xsl:param name="mode" select="'href'"/> <!-- 'href' or 'name'. --> |
---|
| 49 | <xsl:param name="path" select="''"/> <!-- Path to the unit file. Only relevant to 'href'. --> |
---|
| 50 | <xsl:choose> |
---|
| 51 | <xsl:when test="not($string)"> |
---|
| 52 | <!-- For whatever reason, this value does not have a uom. --> |
---|
| 53 | <!-- It may be a unitless quantity or an indexed parameter with an optional uom. --> |
---|
| 54 | </xsl:when> |
---|
| 55 | <xsl:when test="$index > string-length($string)"> |
---|
| 56 | -------- This is a bad call ---------- |
---|
| 57 | string='<xsl:value-of select="$string"/>' |
---|
| 58 | index='<xsl:value-of select="$index"/>' |
---|
| 59 | mode='<xsl:value-of select="$mode"/>' |
---|
| 60 | path='<xsl:value-of select="$path"/>' |
---|
| 61 | </xsl:when> |
---|
| 62 | <xsl:otherwise> |
---|
| 63 | <xsl:call-template name="_nextChar"> |
---|
| 64 | <xsl:with-param name="string" select="$string"/> |
---|
| 65 | <xsl:with-param name="index" select="$index"/> |
---|
| 66 | <xsl:with-param name="mode" select="$mode"/> |
---|
| 67 | <xsl:with-param name="original" select="$string"/> |
---|
| 68 | <xsl:with-param name="path" select="$path"/> |
---|
| 69 | </xsl:call-template> |
---|
| 70 | </xsl:otherwise> |
---|
| 71 | </xsl:choose> |
---|
| 72 | </xsl:template> |
---|
| 73 | <!--Template to examine the next character for an upper case letter. --> |
---|
| 74 | <xsl:template name="_nextChar"> |
---|
| 75 | <xsl:param name="string"/> |
---|
| 76 | <xsl:param name="index"/> |
---|
| 77 | <xsl:param name="mode"/> |
---|
| 78 | <xsl:param name="original"/> |
---|
| 79 | <xsl:param name="path"/> |
---|
| 80 | <xsl:variable name="char"><xsl:value-of select="substring($string,$index,1)"/></xsl:variable> |
---|
| 81 | <xsl:variable name="len"><xsl:value-of select="string-length($string)"/></xsl:variable> |
---|
| 82 | <xsl:choose> |
---|
| 83 | <xsl:when test="not($string)"/> |
---|
| 84 | <xsl:when test="$index > $len"> |
---|
| 85 | <!-- We are finished --> |
---|
| 86 | <xsl:if test="$mode = 'href'"> |
---|
| 87 | <a href="{$path}#uom::{translate($string,'./','TP')}"><xsl:value-of select="$original"/></a> |
---|
| 88 | </xsl:if> |
---|
| 89 | <xsl:if test="$mode = 'name'"> |
---|
| 90 | <a name="uom::{translate($string,'./','TP')}"/> |
---|
| 91 | </xsl:if> |
---|
| 92 | </xsl:when> |
---|
| 93 | <xsl:when test="contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ',$char)"> |
---|
| 94 | <xsl:call-template name="_insertChar"> |
---|
| 95 | <xsl:with-param name="string" select="$string"/> |
---|
| 96 | <xsl:with-param name="index" select="$index"/> |
---|
| 97 | <xsl:with-param name="mode" select="$mode"/> |
---|
| 98 | <xsl:with-param name="original" select="$original"/> |
---|
| 99 | <xsl:with-param name="path" select="$path"/> |
---|
| 100 | </xsl:call-template> |
---|
| 101 | </xsl:when> |
---|
| 102 | <xsl:otherwise> |
---|
| 103 | <xsl:call-template name="_nextChar"> |
---|
| 104 | <xsl:with-param name="string" select="$string"/> |
---|
| 105 | <xsl:with-param name="index" select="$index +1"/> |
---|
| 106 | <xsl:with-param name="mode" select="$mode"/> |
---|
| 107 | <xsl:with-param name="original" select="$original"/> |
---|
| 108 | <xsl:with-param name="path" select="$path"/> |
---|
| 109 | </xsl:call-template> |
---|
| 110 | </xsl:otherwise> |
---|
| 111 | </xsl:choose> |
---|
| 112 | </xsl:template> |
---|
| 113 | <!--Template to insert an underscore at the current index while calling _nextChar. --> |
---|
| 114 | <xsl:template name="_insertChar"> |
---|
| 115 | <xsl:param name="string"/> |
---|
| 116 | <xsl:param name="index"/> |
---|
| 117 | <xsl:param name="mode"/> |
---|
| 118 | <xsl:param name="original"/> |
---|
| 119 | <xsl:param name="path"/> |
---|
| 120 | <xsl:variable name="len"><xsl:value-of select="string-length($string)"/></xsl:variable> |
---|
| 121 | <xsl:call-template name="_nextChar"> |
---|
| 122 | <xsl:with-param name="string" select="concat(substring($string,1,$index - 1),'_',substring($string,$index,$len - $index +1))"/> |
---|
| 123 | <xsl:with-param name="index" select="$index +2"/> |
---|
| 124 | <xsl:with-param name="mode" select="$mode"/> |
---|
| 125 | <xsl:with-param name="original" select="$original"/> |
---|
| 126 | <xsl:with-param name="path" select="$path"/> |
---|
| 127 | </xsl:call-template> |
---|
| 128 | </xsl:template> |
---|
| 129 | |
---|
| 130 | </xsl:stylesheet> |
---|