|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dl="http://www.ivansinsurance.com/connect/download" xmlns:al3="http://www.ivansinsurance.com/acord/al3" xmlns:format="http://www.ivansinsurance.com/acord/al3/formatters"
|
|
xmlns:nx="http://www.ivansinsurance.com/connect" xmlns:dlp="http://www.ivansinsurance.com/connect/download/private" xmlns:nxp="NxTech.http://www.ivansinsurance.com/connect/download/private" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:dx="xalan://com.nxtech.util.date.DateUtil"
|
|
xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:br="http://www.ivansinsurance.com/bookroll2" exclude-result-prefixes="#all" expand-text="true" version="3.1">
|
|
<!-- Functions related to formatting ACORD XML elements based on AL3 class and data type -->
|
|
<xsl:function name="format:num">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="implied-decimals" as="xs:integer"/>
|
|
<xsl:variable name="divisor" select="math:pow(10, $implied-decimals)"/>
|
|
<xsl:sequence select="
|
|
if ($implied-decimals = 0)
|
|
then
|
|
xs:integer($value)
|
|
else
|
|
$value div $divisor"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:signed-num">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="implied-decimals" as="xs:integer"/>
|
|
<xsl:variable name="sign" select="substring($value, string-length($value), 1)"/>
|
|
<xsl:variable name="prefix" select="
|
|
if ($sign = '-') then
|
|
'-'
|
|
else
|
|
''"/>
|
|
<xsl:variable name="xml-value" select="$prefix || format:num(number(substring($value, 1, string-length($value) - 1)), $implied-decimals)"/>
|
|
|
|
<xsl:sequence
|
|
select="
|
|
if ($implied-decimals = 5) then
|
|
$xml-value
|
|
else
|
|
format:amt($xml-value)"
|
|
/>
|
|
</xsl:function>
|
|
<xsl:function name="format:amt">
|
|
<xsl:param name="value"/>
|
|
|
|
<Amt>
|
|
<xsl:sequence select="$value"/>
|
|
</Amt>
|
|
</xsl:function>
|
|
<xsl:function name="format:amount">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="implied-decimals" as="xs:integer"/>
|
|
<!--<xsl:param name="unit-of-measure"/>-->
|
|
<Amt>
|
|
<xsl:sequence select="format:num($value, $implied-decimals)"/>
|
|
</Amt>
|
|
</xsl:function>
|
|
<xsl:function name="format:duration">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="implied-decimals" as="xs:integer"/>
|
|
<xsl:param name="unit-of-measure" as="xs:string"/>
|
|
<DurationPeriod>
|
|
<xsl:sequence select="format:numunits($value, $implied-decimals, $unit-of-measure)"/>
|
|
</DurationPeriod>
|
|
</xsl:function>
|
|
<xsl:function name="format:numunits">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="implied-decimals" as="xs:integer"/>
|
|
<xsl:param name="unit-of-measure" as="xs:string"/>
|
|
<xsl:variable name="sign" select="substring($value, string-length($value), 1)"/>
|
|
<NumUnits>
|
|
<xsl:choose>
|
|
<xsl:when test="$sign='+' or $sign='-'">
|
|
<xsl:variable name="prefix" select="if ($sign = '-') then '-' else ''"/>
|
|
<xsl:variable name="xml-value" select="$prefix || format:num(number(substring($value, 1, string-length($value) - 1)), $implied-decimals)"/>
|
|
<xsl:sequence select="$xml-value"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:sequence select="format:num($value, $implied-decimals)"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</NumUnits>
|
|
<UnitMeasurementCd>
|
|
<xsl:sequence select="$unit-of-measure"/>
|
|
</UnitMeasurementCd>
|
|
</xsl:function>
|
|
<xsl:function name="format:time">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="implied-decimals" as="xs:integer"/>
|
|
<xsl:param name="unit-of-measure"/>
|
|
<xsl:sequence select="substring($value, 1, 2) || ':' || substring($value, 3, 2)"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:integer" as="element(FormatInteger)">
|
|
<xsl:param name="value" as="xs:integer?"/>
|
|
<xsl:param name="implied-decimal" as="xs:integer?"/>
|
|
<FormatInteger>{format:num($value, 0)}</FormatInteger>
|
|
</xsl:function>
|
|
<xsl:function name="format:pct" as="element(FormatPct)">
|
|
<xsl:param name="value" as="xs:integer"/>
|
|
<xsl:param name="implied-decimal" as="xs:integer?"/>
|
|
|
|
<FormatPct>{format:num($value, $implied-decimal)}</FormatPct>
|
|
|
|
</xsl:function>
|
|
<xsl:function name="format:deductible">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="implied-decimal"/>
|
|
<xsl:variable name="formatter" select="
|
|
if (br:deductible-type($value) = 'PC') then
|
|
format:pct#2
|
|
else
|
|
format:integer#2"/>
|
|
<xsl:sequence select="$formatter($value, $implied-decimal)"/>
|
|
<xsl:variable name="basis" select="br:deductible-basis($value)"/>
|
|
<xsl:if test="$basis">
|
|
<DeductibleAppliesToCd>
|
|
<xsl:sequence select="br:key-with-fallback('deductible-applies-to-codes-list', $basis)"/>
|
|
</DeductibleAppliesToCd>
|
|
</xsl:if>
|
|
</xsl:function>
|
|
<xsl:function name="br:deductible-type" as="xs:string?">
|
|
<xsl:param name="node" as="element()"/>
|
|
<xsl:variable name="tag-name" select="name($node) || 'TypeCode'"/>
|
|
<xsl:sequence select="$node/../*[name() = $tag-name]"/>
|
|
</xsl:function>
|
|
<xsl:function name="br:deductible-basis" as="xs:string?">
|
|
<xsl:param name="node" as="element()"/>
|
|
<xsl:sequence select="$node/../*[name() = 'DeductibleBasisCode']"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:limit">
|
|
<xsl:param name="value"/>
|
|
<FormatInteger>{format:num($value, 0)}</FormatInteger>
|
|
<xsl:variable name="basis" select="br:limit-basis($value)"/>
|
|
<xsl:variable name="valuation" select="br:limit-valuation($value)"/>
|
|
<xsl:if test="$basis">
|
|
<LimitAppliesToCd>
|
|
<xsl:sequence select="br:key-with-fallback('limit-applies-to-codes-list', $basis)"/>
|
|
</LimitAppliesToCd>
|
|
</xsl:if>
|
|
<xsl:if test="$valuation">
|
|
<ValuationCd>
|
|
<xsl:sequence select="br:key-with-fallback('limit-valuation-codes-list', $valuation)"/>
|
|
</ValuationCd>
|
|
</xsl:if>
|
|
</xsl:function>
|
|
<xsl:function name="br:limit-basis" as="xs:string?">
|
|
<xsl:param name="node" as="element()"/>
|
|
<xsl:variable name="element_name" select="
|
|
if (contains(name($node), 'Homeowners')) then
|
|
substring-after(name($node), 'Homeowners')
|
|
else
|
|
name($node)"/>
|
|
<xsl:variable name="tag-name" select="$element_name || 'BasisCode'"/>
|
|
<xsl:sequence select="$node/../*[name() = $tag-name]"/>
|
|
</xsl:function>
|
|
<xsl:function name="br:limit-valuation" as="xs:string?">
|
|
<xsl:param name="node" as="element()"/>
|
|
<xsl:variable name="tag-name" select="name($node) || 'ValuationTypeCode'"/>
|
|
<xsl:sequence select="$node/../*[name() = $tag-name]"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:option">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="optionType"/>
|
|
<OptionTypeCd>{if ($optionType='Num') then br:option-number-of-count($value) else $optionType}</OptionTypeCd>
|
|
<xsl:choose>
|
|
<xsl:when test="$optionType = 'NumV1' and br:option-numeric-value-format($value) = 'P'">
|
|
<OptionValue>{$value div 10000000}</OptionValue>
|
|
</xsl:when>
|
|
<xsl:when test="$optionType = 'Num' or $optionType = 'NumV1' or $optionType = 'YNInd1'">
|
|
<OptionValue>{$value}</OptionValue>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<OptionCd>{br:key-with-fallback('coverage-option-codes-list', $value)}</OptionCd>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:function>
|
|
<xsl:function name="format:question">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="questionCode"/>
|
|
<QuestionCd>{$questionCode}</QuestionCd>
|
|
<YesNoCd>{if ($value = 'Y') then 'YES' else 'NO'}</YesNoCd>
|
|
</xsl:function>
|
|
<xsl:function name="br:option-number-of-count" as="xs:string?">
|
|
<xsl:param name="node" as="element()"/>
|
|
<xsl:for-each select="$node">
|
|
<xsl:sequence select="'Num' || accumulator-before('number-of-counter')"/>
|
|
</xsl:for-each>
|
|
|
|
</xsl:function>
|
|
<xsl:function name="br:option-numeric-value-format" as="xs:string?">
|
|
<xsl:param name="node" as="element()"/>
|
|
<xsl:sequence select="$node/../*[name() = 'NumericValueFormatCode']"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:acord-xml-date" as="xs:string?">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="length" as="xs:integer"/>
|
|
<xsl:param name="translation_type"/>
|
|
<xsl:variable name="full-date" as="xs:string?">
|
|
<xsl:choose>
|
|
<xsl:when test="$length = 8">{$value}</xsl:when>
|
|
<xsl:when test="$length = 6">
|
|
<xsl:sequence
|
|
select="
|
|
concat(if ($translation_type = 'date6_figure_century') then
|
|
br:figure-century(substring($value, 1, 2), substring(string(current-date()), 3, 2))
|
|
else
|
|
20, $value)"
|
|
/>
|
|
</xsl:when>
|
|
</xsl:choose>
|
|
</xsl:variable>
|
|
<xsl:sequence select="br:al3-to-xml-date($full-date)"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:expand-dt6-calculated">
|
|
<xsl:param name="date6"/>
|
|
<xsl:variable name="short-year" select="substring($date6, 1, 2)"/>
|
|
<xsl:variable name="century" select="br:figure-century($short-year, format:get-century-threshold())"/>
|
|
<xsl:sequence select="$century || $date6"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:expand-dt6-default">
|
|
<xsl:param name="date6"/>
|
|
<xsl:sequence select="'20' || $date6"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:expand-dt4-calculated">
|
|
<xsl:param name="date4"/>
|
|
<xsl:variable name="short-year" select="substring($date4, 3, 2)"/>
|
|
<xsl:variable name="century" select="br:figure-century($short-year, format:get-century-threshold())"/>
|
|
<xsl:sequence select="$century || $short-year || substring($date4, 1, 2) || '01'"/>
|
|
</xsl:function>
|
|
<xsl:function name="format:get-century-threshold">
|
|
<xsl:variable name="current-year" select="year-from-date(current-date())"/>
|
|
<xsl:sequence select="substring(xs:string($current-year), 3, 2)"/>
|
|
|
|
</xsl:function>
|
|
<xsl:function name="br:ImprovementCodeYear">
|
|
<xsl:param name="value"/>
|
|
<xsl:param name="improvement-type"/>
|
|
<xsl:variable name="code-tag-name" select="$improvement-type || 'ImprovementCd'"/>
|
|
<xsl:variable name="year-tag-name" select="$improvement-type || 'ImprovementYear'"/>
|
|
<xsl:element name="{$code-tag-name}">{substring($value, 1, 1)}</xsl:element>
|
|
<xsl:variable name="YY" select="substring($value, 2, 2)"/>
|
|
<xsl:element name="{$year-tag-name}">{br:figure-century($YY, substring($CurrentDate, 3, 2)) || $YY}</xsl:element>
|
|
</xsl:function>
|
|
</xsl:stylesheet>
|