Project

Profile

Help

Bug #4549 » Main.xsl

Jeremy Cronk, 2020-05-08 19:02

 
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:br="http://www.ivansinsurance.com/bookroll2" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:dl="download-specific-functions" xmlns:dx="java://com.nxtech.util.date.DateUtil" xmlns:list="xalan://com.nxtech.util.list.Lists"
xmlns:nx="NxTech.custom.function" xmlns:stash="xalan://com.nxtech.util.io.Stash" xmlns:saxon="http://saxon.sf.net/" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:format="http://www.ivansinsurance.com/acord/al3/formatters" xmlns:xs="http://www.w3.org/2001/XMLSchema"
expand-text="yes" version="3.0" exclude-result-prefixes="#all">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:mode on-no-match="deep-skip"/>
<xsl:include href="FormattingFunctions.xsl"/>
<xsl:variable name="CODELOOKUP" select="document('CodeLookup.xml')"/>
<xsl:variable name="LOBLevel" select="document('')/*/br:LOBLevel"/>
<xsl:accumulator name="number-of-counter" initial-value="0">
<xsl:accumulator-rule match="NumberOf" select="$value + 1"/>
<xsl:accumulator-rule match="PersonalAutomobileCoverageAndAdjustmentsGroup" select="0"/>
<xsl:accumulator-rule match="HomeownersAndDwellingFireCoverageAndAdjustmentsGroup" select="0"/>
</xsl:accumulator>
<br:LOBLevel lob="AUTOP"/>
<br:LOBLevel lob="HOME"/>
<br:LOBLevel lob="DFIRE"/>
<br:LOBLevel lob="PUMBR"/>
<br:LOBLevel lob="INMRP"/>
<br:LOBLevel lob="MHOME"/>
<br:LOBLevel lob="BOAT"/>
<br:LOBLevel lob="PPKGE"/>
<br:LOBLevel lob="FLOOD"/>
<xsl:key name="lookup-table-by-refid" match="CodeLookupTablesByAL3RefId" use="@al3ReferenceId"/>
<xsl:key name="air-conditioning-codes-list" match="AirConditioningCd" use="@al3Code"/>
<xsl:key name="animal-type-codes-list" match="AnimalTypeCd" use="@al3Code"/>
<xsl:key name="area-type-codes-list" match="AreaTypeCd" use="@al3Code"/>
<xsl:key name="attachment-responsibility-codes-list" match="AttachmentResponsibilityCd" use="@al3Code"/>
<xsl:key name="attachment-type-codes-list" match="AttachmentTypeCd" use="@al3Code"/>
<xsl:key name="autop-coverage-codes-list" match="PersonalAutoCoverageCd" use="@al3Code"/>
<xsl:key name="billing-method-codes-list" match="BillingMethodCd" use="@al3Code"/>
<xsl:key name="bldg-over-water-codes-list" match="BuildingOverWater" use="@al3Code"/>
<xsl:key name="body-water-proximity-codes-list" match="SeacoastOrOtherBodyWaterProximityCd" use="@al3Code"/>
<xsl:key name="boolean-codes-list" match="Boolean" use="@al3Code"/>
<xsl:key name="breed-codes-list" match="BreedCd" use="@al3Code"/>
<xsl:key name="business-purpose-type-codes-list" match="BusinessPurposeTypeCd" use="@al3Code"/>
<xsl:key name="communication-use-codes-list" match="CommunicationUseCd" use="@al3Code"/>
<xsl:key name="construction-type-codes-list" match="ConstructionTypeCd" use="@al3Code"/>
<xsl:key name="continuous-insurance-codes-list" match="ContinuousInsuranceCd" use="@al3Code"/>
<xsl:key name="cooking-location-codes-list" match="CookingLocationCd" use="@al3Code"/>
<xsl:key name="coverage-option-codes-list" match="CoverageOptionCd" use="@al3Code"/>
<xsl:key name="customer-servicing-codes-list" match="CustomerServicingCd" use="@al3Code"/>
<xsl:key name="damageability-codes-list" match="DamageabilityCd" use="@al3Code"/>
<xsl:key name="deductible-applies-to-codes-list" match="DeductibleAppliesToCd" use="@al3Code"/>
<xsl:key name="door-lock-codes-list" match="DoorLockCd" use="@al3Code"/>
<xsl:key name="driver-relates-to-codes-list" match="DriverRelatesToCd" use="@al3Code"/>
<xsl:key name="driver-training-codes-list" match="DriverTrainingCd" use="@al3Code"/>
<xsl:key name="driver-type-codes-list" match="DriverTypeCd" use="@al3Code"/>
<xsl:key name="driving-record-codes-list" match="DrivingRecordCd" use="@al3Code"/>
<xsl:key name="dwelling-location-codes-list" match="DwellingLocationCd" use="@al3Code"/>
<xsl:key name="dwelling-style-codes-list" match="DwellingStyleCd" use="@al3Code"/>
<xsl:key name="dwelling-use-codes-list" match="DwellingUseCd" use="@al3Code"/>
<xsl:key name="education-level-codes-list" match="EducationLevelCd" use="@al3Code"/>
<xsl:key name="employee-status-codes-list" match="EmployeeStatusCd" use="@al3Code"/>
<xsl:key name="eclosed-area-usage-codes-list" match="EnclosedAreaUsage" use="@al3Code"/>
<xsl:key name="enclosure-wall-type-codes-list" match="EnclosedAreaUsage" use="@al3Code"/>
<xsl:key name="engine-type-codes-list" match="EngineTypeCd" use="@al3Code"/>
<xsl:key name="evaluation-method-codes-list" match="EvaluationMethodCd" use="@al3Code"/>
<xsl:key name="floors-in-bldg-codes-list" match="NumStoriesInDwellingCd" use="@al3Code"/>
<xsl:key name="foundation-codes-list" match="FoundationCd" use="@al3Code"/>
<xsl:key name="frequency-codes-list" match="FrequencyCd" use="@al3Code"/>
<xsl:key name="fuel-tank-codes-list" match="FuelTankCd" use="@al3Code"/>
<xsl:key name="fuel-type-codes-list" match="FuelTypeCd" use="@al3Code"/>
<xsl:key name="garage-type-codes-list" match="GarageTypeCd" use="@al3Code"/>
<xsl:key name="gender-codes-list" match="GenderCd" use="@al3Code"/>
<xsl:key name="heat-source-codes-list" match="HeatSourceCd" use="@al3Code"/>
<xsl:key name="housekeeping-condition-codes-list" match="HousekeepingConditionCd" use="@al3Code"/>
<xsl:key name="hull-design-type-codes-list" match="HullDesignTypeCd" use="@al3Code"/>
<xsl:key name="hull-material-type-codes-list" match="HullMaterialTypeCd" use="@al3Code"/>
<xsl:key name="hydrant-type-codes-list" match="HydrantTypeCd" use="@al3Code"/>
<xsl:key name="improvement-codes-list" match="ImprovementCd" use="@al3Code"/>
<xsl:key name="info-source-codes-list" match="InfoSourceCd" use="@al3Code"/>
<xsl:key name="language-codes-list" match="LanguageCd" use="@al3Code"/>
<xsl:key name="legal-entity-codes-list" match="LegalEntityCd" use="@al3Code"/>
<xsl:key name="limit-applies-to-codes-list" match="LimitAppliesToCd" use="@al3Code"/>
<xsl:key name="limit-valuation-codes-list" match="ValuationCd" use="@al3Code"/>
<xsl:key name="line-business-codes-list" match="LOBCd" use="@al3Code"/>
<xsl:key name="line-business-subcodes-list" match="LOBSubCd" use="@al3Code"/>
<xsl:key name="location_by_number" match="LocationAddressGroup" use="LocationNumber"/>
<xsl:key name="location-type-codes-list" match="LocationTypeCd" use="@al3Code"/>
<xsl:key name="loss-location-codes-list" match="LossLocationCd" use="@al3Code"/>
<xsl:key name="marital-status-codes-list" match="MaritalStatusCd" use="@al3Code"/>
<xsl:key name="method-payment-codes-list" match="MethodPaymentCd" use="@al3Code"/>
<xsl:key name="multi-car-discount-codes-list" match="MultiCarDiscountCd" use="@al3Code"/>
<xsl:key name="nature-business-codes-list" match="NatureBusinessCd" use="@al3Code"/>
<xsl:key name="nature-interest-codes-list" match="NatureInterestCd" use="@al3Code"/>
<xsl:key name="occupancy-type-codes-list" match="OccupancyTypeCd" use="@al3Code"/>
<xsl:key name="occupation-class-codes-list" match="OccupationClassCd" use="@al3Code"/>
<xsl:key name="oil-tank-loc-codes-list" match="OilStorageTankLocationCd" use="@al3Code"/>
<xsl:key name="org-id-codes-list" match="MailResponsibiltyCd" use="@al3Code"/>
<xsl:key name="payor-codes-list" match="PayorCd" use="@al3Code"/>
<xsl:key name="plota-coverage-codes-list" match="PLOTACoverageCd" use="@al3Code"/>
<xsl:key name="plota-cov-code-by-pulname-list" match="PLOTACoverageCd" use="@PUL5FieldName"/>
<xsl:key name="plumbing-type-codes-list" match="PlumbingTypeCd" use="@al3Code"/>
<xsl:key name="policy-type-codes-list" match="PolicyTypeCd" use="@al3Code"/>
<xsl:key name="premium-basis-codes-list" match="PremiumBasisCd" use="@al3Code"/>
<xsl:key name="property-class-codes-list" match="PropertyClassCd" use="@al3Code"/>
<xsl:key name="propulsion-type-codes-list" match="PropulsionTypeCd" use="@al3Code"/>
<xsl:key name="protective-device-burgfire-codes-list" match="ProtectionDeviceBurglarFireCd" use="@al3Code"/>
<xsl:key name="protective-device-smoke-codes-list" match="ProtectionDeviceSmokeCd" use="@al3Code"/>
<xsl:key name="protective-device-sprinkler-codes-list" match="ProtectionDeviceSprinklerCd" use="@al3Code"/>
<xsl:key name="race-codes-list" match="RaceCd" use="@al3Code"/>
<xsl:key name="rating-method-codes-list" match="RatingMethodCd" use="@al3Code"/>
<xsl:key name="residence-owned-rented-codes-list" match="ResidenceOwnedRentedCd" use="@al3Code"/>
<xsl:key name="residence-type-codes-list" match="ResidenceTypeCd" use="@al3Code"/>
<xsl:key name="response-codes-list" match="ResponseCd" use="@al3Code"/>
<xsl:key name="risk-location-codes-list" match="RiskLocationCd" use="@al3Code"/>
<xsl:key name="role-codes-list" match="RoleCd" use="@al3Code"/>
<xsl:key name="roof-deck-attachment-codes-list" match="RoofDeckAttachmentCd" use="@al3Code"/>
<xsl:key name="roof-material-type-codes-list" match="RoofMaterialTypeCd" use="@al3Code"/>
<xsl:key name="settlement-type-codes-list" match="SettlementTypeCd" use="@al3Code"/>
<xsl:key name="siding-type-codes-list" match="SidingTypeCd" use="@al3Code"/>
<xsl:key name="signed-by-codes-list" match="SignedByCd" use="@al3Code"/>
<xsl:key name="spar-material-codes-list" match="SparMaterialCd" use="@al3Code"/>
<xsl:key name="termination-reason-codes-list" match="TerminationReasonCd" use="@al3Code"/>
<xsl:key name="tie-down-codes-list" match="TieDownCodesList" use="@al3Code"/>
<xsl:key name="veh-body-type-codes-list" match="VehBodyTypeCd" use="@al3Code"/>
<xsl:key name="veh-performance-codes-list" match="VehPerformanceCd" use="@al3Code"/>
<xsl:key name="veh-use-codes-list" match="VehUseCd" use="@al3Code"/>
<xsl:key name="watercraft-definition-type-codes-list" match="WatercraftDefinitionTypeCd" use="@al3Code"/>
<xsl:key name="watercraft-type-codes-list" match="WatercraftTypeCd" use="@al3Code"/>
<xsl:key name="waters-navigated-codes-list" match="WatersNavigatedCd" use="@al3Code"/>
<xsl:key name="wiring-type-codes-list" match="WiringTypeCd" use="@al3Code"/>
<xsl:key name="where-work-performed-codes-list" match="WhereWorkPerformedCd" use="@al3Code"/>
<xsl:variable name="AL3DATADICTIONARY" select="document('AL3DataDictionary.xml')"/>
<xsl:key name="al3-data-definition" match="Definition" use="@groupelement"/>
<xsl:variable name="DATAELEMENTS">
<xsl:variable name="expanded-table">
<xsl:apply-templates select="document('DataElements.xml')" mode="br:mapping"/>
</xsl:variable>
<xsl:apply-templates select="$AL3DATADICTIONARY" mode="br:mapping">
<xsl:with-param name="mapping-table" select="$expanded-table" tunnel="yes"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:key name="al3-data-element" match="DataElement" use="xs:string(@al3XmlTagName)" saxon:range-key="yes"/>
<xsl:key name="map-info-by-element" match="DataElement" use="@al3Elements"/>
<xsl:key name="element-by-name" match="*" use="@group_element"/>
<xsl:variable name="CurrentDate" select="string(current-date())"/>
<xsl:function name="br:get-element" as="element()*">
<xsl:param name="element-name" as="xs:string"/>
<xsl:param name="ancestor" as="element()"/>
<xsl:sequence select="key('element-by-name', $element-name, $ancestor)"/>
</xsl:function>
<xsl:function name="br:identity-value">
<xsl:param name="input"/>
<xsl:sequence select="data($input)"/>
</xsl:function>
<xsl:template match="Definition" mode="br:mapping">
<xsl:param name="mapping-table" tunnel="yes"/>
<xsl:variable name="map-entry" select="key('map-info-by-element', @groupelement, $mapping-table)"/>
<xsl:if test="$map-entry">
<DataElement>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="$map-entry/@*"/>
</DataElement>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="$map-entry/@*"/>
</xsl:copy>
</xsl:if>
</xsl:template>
<xsl:variable name="dl:formatting-dispatch" as="map(*)">
<xsl:map>
<xsl:map-entry key="'A'" select="br:identity-value#1"/>
<xsl:map-entry key="'AN'" select="br:identity-value#1"/>
<xsl:map-entry key="'T'" select="br:identity-value#1"/>
<xsl:map-entry key="'DT'" select="format:acord-xml-date#3"/>
<xsl:map-entry key="'SN'" select="format:signed-num#2"/>
<xsl:map-entry key="'N'" select="format:num#2"/>
<xsl:map-entry key="'S'" select="format:signed-num#2"/>
<xsl:map-entry key="'amount'" select="format:amount#2"/>
<xsl:map-entry key="'duration'" select="format:duration#3"/>
<xsl:map-entry key="'numunits'" select="format:numunits#3"/>
<xsl:map-entry key="'time'" select="format:time#3"/>
<xsl:map-entry key="'deductible'" select="format:deductible#2"/>
<xsl:map-entry key="'limit'" select="format:limit#1"/>
<xsl:map-entry key="'option'" select="format:option#2"/>
<xsl:map-entry key="'question'" select="format:question#2"/>
</xsl:map>
</xsl:variable>
<xsl:variable name="policy-quote-prefix-table"
select="
map {
'P': map {
'AUTO': 'PersAuto',
'HOME': 'Home',
'PROP': 'DwellFire',
'UMB': 'PersUmbrella',
'INMAR': 'PersInlandMarine',
'MHOME': 'Home',
'BOAT': 'Watercraft',
'FLOOD': 'Home',
'PKG': 'PersPkg'
},
'C': map {
'AUTO': 'CommlAuto',
'PKG': 'CommlPkg'
}
}"/>
<xsl:template match="Root">
<xsl:variable name="messages">
<xsl:apply-templates select="Message" mode="br:clean-up-empty-elements"/>
</xsl:variable>
<ACORD>
<InsuranceSvcRq>
<xsl:apply-templates select="$messages"/>
</InsuranceSvcRq>
</ACORD>
</xsl:template>
<xsl:mode name="br:clean-up-empty-elements" on-no-match="shallow-copy"/>
<xsl:mode name="br:mapping" on-no-match="shallow-copy"/>
<xsl:template match="Root" mode="br:clean-up-empty-elements" as="element(Message)*">
<xsl:apply-templates select="Message" mode="br:clean-up-empty-elements"/>
</xsl:template>
<xsl:template match="*[not(*)][matches(text(), '^(\?+)|(\s+)$')]" mode="br:clean-up-empty-elements"/>
<xsl:template match="*[not(node())]" mode="br:clean-up-empty-elements"/>
<xsl:template match="Message">
<xsl:apply-templates select="Transaction"/>
</xsl:template>
<xsl:template match="Transaction">
<xsl:element name="{$policy-quote-prefix-table(PolicyTypeRoutingCode)(LineOfBusinessRoutingCode) || 'PolicyQuoteInqRq'}">
<xsl:variable name="BPI" select="BasicInsuredInformationGroup/BasicPolicyInformationGroup"/>
<BusinessPurposeTypeCd>{br:key-with-fallback('business-purpose-type-codes-list', CycleBusinessPurpose)}</BusinessPurposeTypeCd>
<TransactionRequestDt>{current-dateTime()}</TransactionRequestDt>
<xsl:apply-templates select="('2TRG33', '2TRG23') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="." mode="producer"/>
<xsl:apply-templates select="BasicInsuredInformationGroup/BasicPolicyInformationGroup/MgaCode"/>
<xsl:apply-templates select="BasicInsuredInformationGroup"/>
<xsl:apply-templates select="BasicInsuredInformationGroup/BasicPolicyInformationGroup"/>
<xsl:apply-templates select="$BPI/LocationAddressGroup"/>
<xsl:variable name="LocationNumbers" select="distinct-values($BPI/PackageInformationGroup/LocationAddressGroup/LocationNumber)"/>
<xsl:apply-templates select="$LocationNumbers ! key('location_by_number', ., $BPI)[1]"/>
<!--<xsl:apply-templates select="$BPI/PackageInformationGroup/LocationAddressGroup[not(LocationNumber = preceding::PackageInformationGroup/LocationAddressGroup/LocationNumber)]"/>-->
<xsl:variable name="LOB" select="$BPI/LineOfBusinessCode"/>
<xsl:apply-templates select="$LOBLevel[@lob = $LOB]">
<xsl:with-param name="Policy" select="BasicInsuredInformationGroup/BasicPolicyInformationGroup"/>
</xsl:apply-templates>
<xsl:apply-templates select="$BPI/PolicyActivityGroup"/>
<xsl:apply-templates select="descendant::RemarksGroup"/>
<xsl:apply-templates select="descendant::AttachmentsGroup"/>
</xsl:element>
</xsl:template>
<xsl:template match="*" mode="data_element">
<xsl:variable name="deleted_replacement_tag" select="substring-after(name(), 'Deleted')"/>
<xsl:if test="not(contains(name(), 'Deleted')) or (contains(name(), 'Deleted') and not(following-sibling::*[name() = $deleted_replacement_tag]))">
<xsl:variable name="ACORD_xml_tag_name" select="key('al3-data-element', name(), $DATAELEMENTS)[1]/@acordXmlTagName"/>
<xsl:variable name="data_translation_type" select="key('al3-data-element', name(), $DATAELEMENTS)/@dataTranslationType"/>
<xsl:element name="{$ACORD_xml_tag_name}">
<xsl:sequence select="br:format-element(., key('al3-data-definition', @group_element, $DATAELEMENTS))"/>
</xsl:element>
<xsl:choose>
<xsl:when test="name() = 'NumberOfExtraFullBaths'">
<BathroomTypeCd>Full</BathroomTypeCd>
</xsl:when>
<xsl:when test="name() = 'NumberOfHalfBaths'">
<BathroomTypeCd>Half</BathroomTypeCd>
</xsl:when>
<xsl:when test="name() = 'VehicleBodyTypeCode'">
<VehBodyTypeDesc>{key('veh-body-type-codes-list', ., $CODELOOKUP)}</VehBodyTypeDesc>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:function name="br:format-element">
<xsl:param name="value"/>
<xsl:param name="defn"/>
<xsl:variable name="formatter" as="function(*)">
<xsl:apply-templates select="$defn" mode="dl:data-type"/>
</xsl:variable>
<xsl:sequence select="$formatter($value)"/>
</xsl:function>
<!-- Formatting templates -->
<xsl:template match="Definition[@dataTranslationType = 'question']" as="function(*)" priority="2" mode="dl:data-type">
<xsl:variable name="number-type" select="format:read-numeric-type(@data_type)"/>
<xsl:sequence select="$dl:formatting-dispatch(@dataTranslationType)(?, @questionCode)"/>
</xsl:template>
<!-- match Y/N, returns an ACORD boolean value -->
<xsl:template match="Definition[matches(@data_class, 'Y/N')]" mode="dl:data-type" as="function(*)">
<xsl:sequence
select="
function ($value) as xs:string {
if (key('boolean-codes-list', $value, $CODELOOKUP)/@xmlCode) then
key('boolean-codes-list', $value, $CODELOOKUP)/@xmlCode
else
'0'
}"
/>
</xsl:template>
<!-- match CD, returns a ACORD xml code value based on the incoming ACORD al3 code value; if no code lookup table name then the al3 and xml codes match up and no translation needed -->
<xsl:template match="Definition[matches(@data_class, 'CD')]" mode="dl:data-type" as="function(*)">
<xsl:variable name="RefId" select="@reference_id"/>
<xsl:variable name="LookupTableName" select="key('lookup-table-by-refid', $RefId, $CODELOOKUP)/@codeLookupTableName"/>
<xsl:sequence
select="
if ($LookupTableName)
then
function ($value) as xs:string {
br:key-with-fallback($LookupTableName, $value)
}
else
function ($value) as xs:string {
$value
}"
/>
</xsl:template>
<!-- match DT6 or DT8, returns a function to format value as ACORD xml date -->
<xsl:template match="Definition[@data_class = 'D2Y'][@dataTranslationType = 'date4_figure_century']" mode="dl:data-type" priority="2" as="function(*)">
<xsl:sequence select="
function ($v) {
format:expand-dt4-calculated($v) => br:al3-to-xml-date()
}"/>
</xsl:template>
<xsl:template match="Definition[@data_class = 'DT6'][@dataTranslationType = 'date6_figure_century']" mode="dl:data-type" priority="2" as="function(*)">
<xsl:sequence select="
function ($v) {
format:expand-dt6-calculated($v) => br:al3-to-xml-date()
}"/>
</xsl:template>
<xsl:template match="Definition[@data_class = 'DT6'][@dataTranslationType = 'date6_current_century']" mode="dl:data-type" priority="2" as="function(*)">
<xsl:sequence select="
function ($v) {
format:expand-dt6-default($v) => br:al3-to-xml-date()
}"/>
</xsl:template>
<xsl:template match="Definition[@data_class = 'DT8']" as="function(*)" priority="2" mode="dl:data-type">
<xsl:sequence select="br:al3-to-xml-date#1"/>
</xsl:template>

<xsl:template match="Definition[@dataTranslationType = 'deductible']" as="function(*)" priority="2" mode="dl:data-type">
<xsl:variable name="number-type" select="format:read-numeric-type(@data_type)"/>
<xsl:sequence select="$dl:formatting-dispatch(@dataTranslationType)(?, xs:integer(@length - 3))"/>
</xsl:template>
<xsl:template match="Definition[@dataTranslationType = 'limit']" as="function(*)" priority="2" mode="dl:data-type">
<xsl:variable name="number-type" select="format:read-numeric-type(@data_type)"/>
<xsl:sequence select="$dl:formatting-dispatch(@dataTranslationType)"/>
</xsl:template>
<xsl:template match="Definition[@dataTranslationType = 'option']" as="function(*)" priority="2" mode="dl:data-type">
<xsl:variable name="number-type" select="format:read-numeric-type(@data_type)"/>
<xsl:sequence select="$dl:formatting-dispatch(@dataTranslationType)(?, @optionType)"/>
</xsl:template>
<xsl:template match="Definition[@dataTranslationType = ('duration', 'numunits', 'time')]" as="function(*)" priority="2" mode="dl:data-type">
<xsl:variable name="number-type" select="format:read-numeric-type(@data_type)"/>
<xsl:sequence select="$dl:formatting-dispatch(@dataTranslationType)(?, $number-type('implied-decimals'), @unitOfMeasure)"/>
</xsl:template>
<xsl:template match="Definition[@dataTranslationType = 'amount']" as="function(*)" priority="2" mode="dl:data-type">
<xsl:variable name="number-type" select="format:read-numeric-type(@data_type)"/>
<xsl:sequence select="$dl:formatting-dispatch(@dataTranslationType)(?, $number-type('implied-decimals'))"/>
</xsl:template>
<xsl:function name="format:read-numeric-type" as="map(*)">
<xsl:param name="data-type" as="xs:string"/>
<xsl:variable name="match-groups" select="analyze-string($data-type, '^([NS])(\d+)$')/*/fn:group"/>
<xsl:sequence select="
map {
'type': $match-groups[@nr = 1],
'implied-decimals': $match-groups[@nr = 2]
}"/>
</xsl:function>
<!-- Returns a function to format signed numeric -->
<xsl:template match="Definition[matches(@data_type, '[SN]\d')]" mode="dl:data-type" as="function(*)">
<xsl:variable name="number-type" select="format:read-numeric-type(@data_type)"/>
<!-- <xsl:variable name="match-groups" select="analyze-string(@data_type, '^([NS])(\d+)$')/*/fn:group"/>
<xsl:variable name="implied-decimals" select="$match-groups[@nr = 2]"/>-->
<!-- <xsl:variable name="translation_type" select="key('al3-data-element', @groupelement, $DATAELEMENTS)"/>
<xsl:variable name="unit_of_measure" select="key('al3-data-element', @groupelement, $DATAELEMENTS)/@unitOfMeasure"/>-->
<xsl:variable name="mapping-info" select="$DATAELEMENTS/*[1]/DataElement[@al3Elements = current()/@groupelement]"/>
<xsl:variable name="translation_type" select="$mapping-info/@dataTranslationType" as="xs:string?"/>
<xsl:variable name="unit_of_measure" select="$mapping-info/@unitOfMeasure" as="xs:string?"/>
<xsl:variable name="use-translation-type" as="xs:boolean">
<xsl:choose>
<xsl:when test="$translation_type">
<xsl:sequence select="map:contains($dl:formatting-dispatch, $translation_type)"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numeric-formatter" select="
if ($use-translation-type) then
$dl:formatting-dispatch($translation_type)
else
$dl:formatting-dispatch($number-type('type'))"/>
<xsl:sequence
select="
if ($use-translation-type)
then
function ($value) {
$numeric-formatter($value, $number-type('implied-decimals'), $unit_of_measure)
}
else
function ($value) {
$numeric-formatter($value, $number-type('implied-decimals'))
}"
/>
</xsl:template>
<!-- match on data type and return a function -->
<xsl:template match="Definition[@data_type = 'SN']" as="function(*)" mode="dl:data-type">
<xsl:sequence select="$dl:formatting-dispatch(@data_type)(?, 0)"/>
</xsl:template>
<xsl:template match="Definition" mode="dl:data-type" priority="0" as="function(*)">
<xsl:variable name="data-type" select="@data_type"/>
<xsl:sequence select="
function ($value) {
$dl:formatting-dispatch($data-type)($value)
}"/>
</xsl:template>
<xsl:template match="Transaction" mode="producer">
<xsl:variable name="BPI" select="BasicInsuredInformationGroup/BasicPolicyInformationGroup"/>
<Producer>
<ProducerInfo>
<xsl:apply-templates select="('1MHG18', '1MHG03') ! br:get-element(., current()/..)" mode="data_element"/>
<xsl:apply-templates select="('5BPI08', '5BPI45', '5BPI48') ! br:get-element(., current())" mode="data_element"/>
<ProducerRoleCd>Producer</ProducerRoleCd>
<xsl:if test="$BPI/StateProducerNumberIssuingState or $BPI/StateProducerNumberExpirationDate">
<License>
<LicenseTypeCd>PRST</LicenseTypeCd>
<xsl:apply-templates select="('5BPI34') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<LicenseTerm>
<xsl:apply-templates select="('5BPI58') ! br:get-element(., current())" mode="data_element"/>
</LicenseTerm>
</xsl:where-populated>
<xsl:apply-templates select="('5BPI59') ! br:get-element(., current())" mode="data_element"/>
</License>
</xsl:if>
<xsl:if test="$BPI/NonResidentLicenseNumber or $BPI/NonResidentLicenseNumberIssuingState or $BPI/NonResidentLicenseNumberExpirationDate">
<License>
<LicenseTypeCd>ProducerNonResidence</LicenseTypeCd>
<xsl:apply-templates select="('5BPI60') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<LicenseTerm>
<xsl:apply-templates select="('5BPI62') ! br:get-element(., current())" mode="data_element"/>
</LicenseTerm>
</xsl:where-populated>
<xsl:apply-templates select="('5BPI61') ! br:get-element(., current())" mode="data_element"/>
</License>
</xsl:if>
</ProducerInfo>
</Producer>
</xsl:template>
<xsl:template match="MgaCode">
<Producer>
<ProducerInfo>
<xsl:apply-templates select="('5BPI56') ! br:get-element(., current())" mode="data_element"/>
<ProducerRoleCd>ManagingGeneralAgent</ProducerRoleCd>
</ProducerInfo>
</Producer>
</xsl:template>
<xsl:template match="BasicInsuredInformationGroup">
<xsl:variable name="ISIGroup" select="InsuredsSupplementalInformationGroup"/>
<InsuredOrPrincipal>
<xsl:where-populated>
<ItemIdInfo>
<xsl:apply-templates select="('5BIS03', '5BIS02') ! br:get-element(., current())" mode="data_element"/>
</ItemIdInfo>
</xsl:where-populated>
<GeneralPartyInfo>
<NameInfo>
<xsl:apply-templates select="('5BIS01') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5BIS04') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5ISI12') ! br:get-element(., current())"/>
</NameInfo>
<xsl:apply-templates select="ancestor::Transaction/BasicInsuredInformationExtensionGroup">
<xsl:with-param name="Role" select="'Insured'"/>
</xsl:apply-templates>
</GeneralPartyInfo>
<InsuredOrPrincipalInfo>
<InsuredOrPrincipalRoleCd>Insured</InsuredOrPrincipalRoleCd>
<xsl:where-populated>
<PersonInfo>
<xsl:apply-templates select="('5ISI34', '5ISI22', '5ISI01', '5ISI03', '5ISI09', '5ISI02', '5ISI04', '5ISI24', '5ISI26', '9BIS77', '9BIS78', '5ISI32', '5ISI45') ! br:get-element(., current())" mode="data_element"/>
</PersonInfo>
</xsl:where-populated>
<xsl:where-populated>
<BusinessInfo>
<xsl:apply-templates select="('5BIS05') ! br:get-element(., current())" mode="data_element"/>
</BusinessInfo>
</xsl:where-populated>
</InsuredOrPrincipalInfo>
<xsl:apply-templates select="('5ISI08') ! br:get-element(., current())" mode="data_element"/>
</InsuredOrPrincipal>
<xsl:apply-templates select="SupplementaryNameGroup[NameTypeCode = 'IMN']" mode="co-insured"/>
<xsl:apply-templates select="$ISIGroup/GeneralNameAddressGroup[NameAddressTypeCode = 'CN']" mode="co-insured"/>
<xsl:apply-templates select="SupplementaryNameGroup[NameTypeCode = 'DEC']" mode="dec-page"/>
</xsl:template>
<xsl:template match="BasicInsuredInformationExtensionGroup">
<xsl:param name="Role"/>
<Addr>
<xsl:apply-templates select="('9BIS51', '9BIS52', '9BIS62', '9BIS63', '9BIS53', '9BIS54', '9BIS55', '9BIS58', '9BIS60') ! br:get-element(., current())" mode="data_element"/>
</Addr>
<xsl:where-populated>
<Communications>
<xsl:apply-templates select="
if ($Role = 'Insured') then
('9BIS56', '9BIS57', '9BIS73') ! br:get-element(., current())
else
('9BIS67', '9BIS68') ! br:get-element(., current())"/>
<xsl:apply-templates select="ancestor::Transaction/BasicInsuredInformationGroup/CommunicationsIdInformationGroup[CommunicationsTypeCode = 'EMAIL']" mode="email"/>
<xsl:apply-templates select="ancestor::Transaction/BasicInsuredInformationGroup/BasicPolicyInformationGroup/CommunicationsIdInformationGroup[CommunicationsTypeCode = 'EMAIL']" mode="email"/>
<xsl:apply-templates select="ancestor::Transaction/BasicInsuredInformationGroup/CommunicationsIdInformationGroup[CommunicationsTypeCode = 'WWW']" mode="website"/>
<xsl:apply-templates select="ancestor::Transaction/BasicInsuredInformationGroup/BasicPolicyInformationGroup/CommunicationsIdInformationGroup[CommunicationsTypeCode = 'WWW']" mode="website"/>
</Communications>
</xsl:where-populated>
</xsl:template>
<xsl:template match="*[contains(name(), 'TelephoneNumber') and not(contains(name(), 'TelephoneNumberTypeCode'))]">
<xsl:variable name="PhoneTypeCode" select="following-sibling::*[name() = (name(current()) || 'TypeCode')]"/>
<xsl:variable name="Extension" select="following-sibling::*[name() = (name(current()) || 'Extension')]"/>
<PhoneInfo>
<PhoneTypeCd>
<xsl:value-of select="
if ($PhoneTypeCode = 'C') then
'Cell'
else
'Phone'"/>
</PhoneTypeCd>
<xsl:apply-templates select="$PhoneTypeCode"/>
<PhoneNumber>
<xsl:sequence select="
if ($Extension) then
br:format-phone(node()) || '+' || $Extension
else
br:format-phone(node())"/>
</PhoneNumber>
</PhoneInfo>
</xsl:template>
<xsl:template match="*[contains(name(), 'TelephoneNumberTypeCode')]">
<CommunicationUseCd>{br:key-with-fallback('communication-use-codes-list', .)}</CommunicationUseCd>
</xsl:template>
<xsl:template match="CommunicationsIdInformationGroup" mode="email">
<EmailInfo>
<EmailAddr>{CommunicationsIdentificationNumber}</EmailAddr>
</EmailInfo>
</xsl:template>
<xsl:template match="CommunicationsIdInformationGroup" mode="website">
<WebsiteInfo>
<WebsiteURL>{CommunicationsIdentificationNumber}</WebsiteURL>
</WebsiteInfo>
</xsl:template>
<xsl:template match="SupplementaryNameGroup" mode="co-insured">
<InsuredOrPrincipal>
<GeneralPartyInfo>
<NameInfo>
<xsl:apply-templates select="('5SNG03') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5SNG04') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5ISI13') ! br:get-element(., current())"/>
</NameInfo>
<xsl:apply-templates select="ancestor::Transaction/BasicInsuredInformationExtensionGroup">
<xsl:with-param name="Role" select="'Coinsured'"/>
</xsl:apply-templates>
</GeneralPartyInfo>
<InsuredOrPrincipalInfo>
<InsuredOrPrincipalRoleCd>Coinsured</InsuredOrPrincipalRoleCd>
<xsl:apply-templates select="ancestor::BasicInsuredInformationGroup/InsuredsSupplementalInformationGroup" mode="co-insured"/>
</InsuredOrPrincipalInfo>
</InsuredOrPrincipal>
</xsl:template>
<xsl:template match="GeneralNameAddressGroup" mode="co-insured">
<InsuredOrPrincipal>
<xsl:apply-templates select="." mode="general_party_info"/>
<InsuredOrPrincipalInfo>
<InsuredOrPrincipalRoleCd>Coinsured</InsuredOrPrincipalRoleCd>
<xsl:apply-templates select="ancestor::BasicInsuredInformationGroup/InsuredsSupplementalInformationGroup" mode="co-insured"/>
</InsuredOrPrincipalInfo>
</InsuredOrPrincipal>
</xsl:template>
<xsl:template match="SupplementaryNameGroup" mode="misc_party">
<MiscParty>
<GeneralPartyInfo>
<NameInfo>
<xsl:apply-templates select="('5SNG03') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5SNG04') ! br:get-element(., current())" mode="data_element"/>
</NameInfo>
</GeneralPartyInfo>
<MiscPartyInfo>
<MiscPartyRoleCd>{br:key-with-fallback('role-codes-list', NameTypeCode)}</MiscPartyRoleCd>
</MiscPartyInfo>
</MiscParty>
</xsl:template>
<xsl:template match="GeneralNameAddressGroup" mode="misc_party">
<MiscParty>
<xsl:apply-templates select="." mode="general_party_info"/>
<MiscPartyInfo>
<MiscPartyRoleCd>{br:key-with-fallback('role-codes-list', NameAddressTypeCode)}</MiscPartyRoleCd>
</MiscPartyInfo>
</MiscParty>
</xsl:template>
<xsl:template match="GeneralNameAddressGroup" mode="general_party_info">
<GeneralPartyInfo>
<NameInfo>
<xsl:apply-templates select="('5GNA05') ! br:get-element(., current())"/>
<xsl:if test="NameAddressTypeCode = 'CN'">
<xsl:apply-templates select="('5ISI13') ! br:get-element(., current()/..)"/>
</xsl:if>
</NameInfo>
<xsl:where-populated>
<Addr>
<xsl:apply-templates select="('5GNA06', '5GNA07', '5GNA19', '5GNA20', '5GNA08', '5GNA09', '5GNA10', '5GNA24', '5GNA12', '5GNA11') ! br:get-element(., current())" mode="data_element"/>
</Addr>
</xsl:where-populated>
</GeneralPartyInfo>
</xsl:template>
<xsl:template match="InsuredsSupplementalInformationGroup" mode="co-insured">
<PersonInfo>
<xsl:apply-templates select="('5ISI35', '5ISI23', '5ISI05', '5ISI11', '5ISI10', '5ISI06', '5ISI07', '5ISI25', '5ISI27', '5SNG08', '5SNG13', '5ISI33', '5ISI45') ! br:get-element(., current())" mode="data_element"/>
</PersonInfo>
</xsl:template>
<xsl:template match="SupplementaryNameGroup[NameTypeCode = 'DEC']" mode="dec-page">
<InsuredOrPrincipal>
<GeneralPartyInfo>
<NameInfo>
<CommlName>
<CommercialName>{SupplementaryName}</CommercialName>
</CommlName>
</NameInfo>
</GeneralPartyInfo>
<InsuredOrPrincipalInfo>
<InsuredOrPrincipalRoleCd>DEC</InsuredOrPrincipalRoleCd>
</InsuredOrPrincipalInfo>
</InsuredOrPrincipal>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup">
<xsl:variable name="LHGGroup" select="ancestor::BasicInsuredInformationGroup/LossHistoryGroup"/>
<PersPolicy>
<xsl:apply-templates select="('5BPI01', '5BPI28', '5BPI20', '5BPI04', '5BPI05', '5BPI03') ! br:get-element(., current())" mode="data_element"/>
<ContractTerm>
<xsl:apply-templates select="('5BPI37', '5BPI06', '5BPI38', '5BPI07') ! br:get-element(., current())" mode="data_element"/>
</ContractTerm>
<xsl:apply-templates
select="
('5BPI27', '5BPI02', '5BPI16', '5BPI11', '5BPI12', '5BPI22', '5BPI33', '5BPI36', '5BPI29', '5BPI19', '5BPI24', '5BPI42', '5BPI17', '5BPI30', '5BPI39', '5BPI23', '5BPI31',
'5BPI32', '5BPI10', '5BPI15', '5BPI35', '5BPI14') ! br:get-element(., current())"
mode="data_element"/>
<xsl:apply-templates select="BinderNotificationGroup, descendant::FormsGroup, $LHGGroup, descendant::LossHistoryGroup, PriorPolicyHistoryGroup, OtherInsuranceWithCompanyGroup, PersonalUmbrellaAndExcessPrimaryPolicyInformationGrou"/>
<xsl:where-populated>
<PaymentOption>
<xsl:apply-templates select="('5PAY01', '5PAY02', '5PAY09', '5PAY10', '5PAY12', '5PAY03', '5PAY04', '5PAY07', '5PAY08', '5PAY05', '5PMI09') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<ElectronicFundsTransfer>
<xsl:where-populated>
<FromAcct>
<xsl:apply-templates select="('5PMI02') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5PMI01') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5PMI11', '5PMI05') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<BankInfo>
<xsl:if test="AccountBankName">
<MiscParty>
<GeneralPartyInfo>
<NameInfo>
<CommercialName>
<CommlName>{AccountBankName}</CommlName>
</CommercialName>
</NameInfo>
</GeneralPartyInfo>
</MiscParty>
</xsl:if>
<xsl:apply-templates select="('5PMI03') ! br:get-element(., current())"/>
</BankInfo>
</xsl:where-populated>
<xsl:apply-templates select="('5PMI09') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<PayrollDeductionInfo>
<xsl:if test="PaymentMethodInformationGroup/EmployeeName">
<NameInfo>
<xsl:apply-templates select="('5PMI15') ! br:get-element(., current())"/>
</NameInfo>
</xsl:if>
<xsl:apply-templates select="('5PMI04', '5PMI13', '5PMI14') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5PMI16') ! br:get-element(., current())"/>
</PayrollDeductionInfo>
</xsl:where-populated>
<xsl:apply-templates select="('5PMI18') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5PMI17') ! br:get-element(., current())" mode="data_element"/>
</FromAcct>
<xsl:apply-templates select="('5PMI19', '5PMI08', '5PMI12', '5PMI06') ! br:get-element(., current())" mode="data_element"/>
</xsl:where-populated>
</ElectronicFundsTransfer>
</xsl:where-populated>
<xsl:apply-templates select="('5PMI10') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<SignatureInfo>
<xsl:apply-templates select="('5PMI20', '5PMI21') ! br:get-element(., current())" mode="data_element"/>
</SignatureInfo>
</xsl:where-populated>
<xsl:apply-templates select="('5PAY14') ! br:get-element(., current())" mode="data_element"/>
</PaymentOption>
</xsl:where-populated>
<xsl:apply-templates select="AdditionalOtherInterestGroup"/>
<xsl:apply-templates select="descendant::GeneralNameAddressGroup, descendant::SupplementaryNameGroup" mode="misc_party"/>
<xsl:apply-templates select="UnderwritingQuestionGroup, GeneralInformationGroup"/>
<xsl:apply-templates select="('5BPI13') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5BPI47') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<TaxCodeInfo>
<xsl:apply-templates select="('9BIS59') ! br:get-element(., current()/../..)" mode="data_element"/>
</TaxCodeInfo>
</xsl:where-populated>
<xsl:apply-templates select="('5BPI09', '5ISI40') ! br:get-element(., current()/..)" mode="data_element"/>
<xsl:where-populated>
<PaymentHistoryInfo>
<xsl:apply-templates select="('5ISI39', '5ISI41', '5ISI43', '5ISI42') ! br:get-element(., current()/..)"/>
</PaymentHistoryInfo>
</xsl:where-populated>
<xsl:apply-templates select="('5BPI51', '5BPI52', '5BPI54', '5BPI55', '5BPI57', '5BPI63') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<PersApplicationInfo>
<xsl:apply-templates select="('5ISI29', '5ISI16', '5ISI30', '5ISI17', '5ISI15', '5ISI20', '5ISI28', '5ISI18', '5ISI19', '5ISI36', '5ISI37', '5ISI46', '5ISI47') ! br:get-element(., current()/..)" mode="data_element"/>
</PersApplicationInfo>
</xsl:where-populated>
<xsl:apply-templates select="PersonalAutomobileDrivingRecordGroup"/>
<xsl:apply-templates
select="LocationAddressGroup/VehicleGroup/PersonalAutomobileVehicleSupplementGroup/*[contains(name(), 'Driver') and contains(name(), 'Percent')], PackageInformationGroup/LocationAddressGroup/VehicleGroup/PersonalAutomobileVehicleSupplementGroup/*[contains(name(), 'Driver') and contains(name(), 'Percent')]"
/>
</PersPolicy>
</xsl:template>
<xsl:template match="BinderNotificationGroup">
<Binder>
<xsl:apply-templates select="('5BNG05', '5BNG07') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<ContractTerm>
<xsl:apply-templates select="('5BNG10', '5BNG01', '5BNG11', '5BNG03', '5BNG12') ! br:get-element(., current())" mode="data_element"/>
</ContractTerm>
</xsl:where-populated>
<xsl:apply-templates select="('5BNG02', '5BNG04', '5BNG08', '5BNG06', '5BNG09') ! br:get-element(., current())" mode="data_element"/>
</Binder>
</xsl:template>
<xsl:template match="FormsGroup">
<Form>
<xsl:choose>
<xsl:when test="ancestor::VehicleGroup">
<xsl:attribute name="AggregateRef">{concat('V', ancestor::VehicleGroup/CompanyVehicleNumber)}</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:apply-templates select="('5FOR02', '5FOR03', '5FOR07', '5FOR06', '5FOR08', '5FOR04', '5FOR05', '5FOR01') ! br:get-element(., current())" mode="data_element"/>
</Form>
</xsl:template>
<xsl:template match="LossHistoryGroup">
<Loss>
<xsl:apply-templates select="('5LHG13') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<Catastrophe>
<xsl:apply-templates select="('5LHG14') ! br:get-element(., current())" mode="data_element"/>
</Catastrophe>
</xsl:where-populated>
<xsl:apply-templates select="('5LHG11', '5LHG03', '5LHG04', '5LHG05', '5LHG17', '5LHG02', '5LHG12', '5LHG06', '5LHG08', '5LHG10', '5LHG09', '5LHG23', '5LHG24', '5LHG20', '5LHG21', '5LHG22') ! br:get-element(., current())" mode="data_element"/>
</Loss>
</xsl:template>
<xsl:template match="PriorPolicyHistoryGroup">
<OtherOrPriorPolicy>
<PolicyCd>Prior</PolicyCd>
<xsl:apply-templates select="('5PPH03', '5PPH08', '5PPH09', '5PPH01') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="CompanyName">
<NameInfo>
<CommercialName>
<CommlName>{CompanyName}</CommlName>
</CommercialName>
</NameInfo>
</xsl:if>
<xsl:where-populated>
<ContractTerm>
<xsl:apply-templates select="('5PPH12', '5PPH06') ! br:get-element(., current())" mode="data_element"/>
</ContractTerm>
</xsl:where-populated>
<xsl:apply-templates select="('5PPH13', '5PPH07', '5PPH04', '5PPH19', '5PPH05', '5PPH11') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5PPH22') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5PPH17', '5PPH18', '5PPH21') ! br:get-element(., current())" mode="data_element"/>
</OtherOrPriorPolicy>
</xsl:template>
<xsl:template match="OtherInsuranceWithCompanyGroup">
<OtherOrPriorPolicy>
<PolicyCd>OIC</PolicyCd>
<xsl:apply-templates select="('5OIC01', '5OIC03', '5OIC04', '5OIC02') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<ContractTerm>
<xsl:apply-templates select="('5OIC10', '5OIC05', '5OIC11', '5OIC06') ! br:get-element(., current())" mode="data_element"/>
</ContractTerm>
</xsl:where-populated>
<xsl:apply-templates select="('5OIC08') ! br:get-element(., current())" mode="data_element"/>
</OtherOrPriorPolicy>
</xsl:template>
<xsl:template match="PersonalUmbrellaAndExcessPrimaryPolicyInformationGrou">
<OtherOrPriorPolicy>
<PolicyCd>Underly</PolicyCd>
<xsl:apply-templates select="('6PRP05', '6PRP01', '6PRP02', '6PRP03') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="CompanyName or DeletedCompanyName">
<NameInfo>
<CommercialName>
<CommlName>
<xsl:value-of select="
if (CompanyName) then
CompanyName
else
DeletedCompanyName"/>
</CommlName>
</CommercialName>
</NameInfo>
</xsl:if>
<xsl:where-populated>
<ContractTerm>
<xsl:apply-templates select="('6PRP22', '6PRP06') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6PRP23', '6PRP07') ! br:get-element(., current())" mode="data_element"/>
</ContractTerm>
</xsl:where-populated>
<xsl:if test="PolicyBodilyInjuryPerPerson">
<Coverage>
<CoverageCd>BISPL</CoverageCd>
<xsl:apply-templates select="('6PRP08', '6PRP09') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
<xsl:if test="PolicyPropertyDamageLimit">
<Coverage>
<CoverageCd>{if (LineOfBusinessCode = 'HOME') then 'DWELL' else 'PD'}</CoverageCd>
<xsl:apply-templates select="('6PRP10') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
<xsl:if test="PolicyCombinedSingleLimit">
<Coverage>
<CoverageCd>CSL</CoverageCd>
<xsl:apply-templates select="('6PRP11') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
<xsl:if test="UninsuredUnderinsuredBodilyInjuryPerPerson">
<Coverage>
<CoverageCd>UMISP</CoverageCd>
<xsl:apply-templates select="('6PRP13', '6PRP14') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
<xsl:if test="UninsuredUnderinsuredPropertyDamageLimit">
<Coverage>
<CoverageCd>UMPD</CoverageCd>
<xsl:apply-templates select="('6PRP15') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
<xsl:if test="UninsuredUnderinsuredCombinedSingleLimit">
<Coverage>
<CoverageCd>UMCSL</CoverageCd>
<xsl:apply-templates select="('6PRP16') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
<xsl:if test="AggregateLimit">
<Coverage>
<xsl:apply-templates select="('6PRP12') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
</OtherOrPriorPolicy>
</xsl:template>
<xsl:template match="UnderwritingQuestionGroup">
<xsl:apply-templates select="*[contains(name(), 'QuestionCodeNumber')]" mode="uqg_questions"/>
</xsl:template>
<xsl:template match="*" mode="uqg_questions">
<QuestionAnswer>
<QuestionCd>{.}</QuestionCd>
<YesNoCd>{if (following-sibling::*[contains(name(), 'AnswerIndicatorNumber')][1] = 'Y') then 'YES' else 'NO'}</YesNoCd>
<xsl:apply-templates select="../UnderwritingQuestionOccurrenceGroup[DataElementReferenced = substring(@group_element, 5, 2)]"/>
</QuestionAnswer>
</xsl:template>
<xsl:template match="GeneralInformationGroup">
<xsl:apply-templates select="*[contains(name(), 'UnderwritingQuestion')]" mode="gig_questions"/>
</xsl:template>
<xsl:template match="*" mode="gig_questions">
<QuestionAnswer>
<xsl:variable name="QuestionNumber" select="format-number(number(substring-after(name(), 'UnderwritingQuestion')), '00')"/>
<QuestionCd>{concat('GENRL', $QuestionNumber)}</QuestionCd>
<YesNoCd>{if (node() = 'Y') then 'YES' else 'NO'}</YesNoCd>
<xsl:if test="../RemarksGroup[DataElementReferenced = $QuestionNumber]">
<Explanation>{../RemarksGroup[DataElementReferenced = $QuestionNumber]/RemarksText}</Explanation>
</xsl:if>
<xsl:apply-templates select="../UnderwritingQuestionOccurrenceGroup[DataElementReferenced = $QuestionNumber]"/>
</QuestionAnswer>
</xsl:template>
<xsl:template match="UnderwritingQuestionOccurrenceGroup">
<QuestionOccurrenceInfo>
<xsl:apply-templates select="('5UQO02', '5UQO03', '5UQO04', '5UQO05') ! br:get-element(., current())" mode="data_element"/>
</QuestionOccurrenceInfo>
</xsl:template>
<xsl:template match="PersonalAutomobileDrivingRecordGroup">
<AccidentViolation>
<xsl:if test="CompanyDriverNumber">
<xsl:attribute name="DriverRef" select="concat('D', CompanyDriverNumber)"/>
</xsl:if>
<xsl:if test="VehicleNumber">
<xsl:attribute name="VehRef" select="concat('V', VehicleNumber)"/>
</xsl:if>
<xsl:apply-templates select="('6PDA04', '6PDA25', '6PDA16', '6PDA06', '6PDA07', '6PDA05', '6PDA14', '6PDA17', '6PDA22', '6PDA23', '6PDA24', '6PDA15') ! br:get-element(., current())" mode="data_element"/>
</AccidentViolation>
</xsl:template>
<xsl:template match="*[contains(name(), 'Driver') and contains(name(), 'Percent')]">
<DriverVeh>
<xsl:variable name="VehUseNumber" select="substring-after(substring-before(name(), 'Percent'), 'Driver')"/>
<xsl:variable name="DriverTag" select="'DriverNumber' || $VehUseNumber"/>
<xsl:if test="../*[name() = $DriverTag]">
<xsl:attribute name="DriverRef" select="concat('D', ../*[name() = $DriverTag])"/>
</xsl:if>
<xsl:if test="ancestor::VehicleGroup/CompanyVehicleNumber">
<xsl:attribute name="VehRef" select="concat('V', ancestor::VehicleGroup/CompanyVehicleNumber)"/>
</xsl:if>
<UsePct>{.}</UsePct>
</DriverVeh>
</xsl:template>
<xsl:template match="LocationAddressGroup">
<Location>
<xsl:attribute name="id">{concat('L', LocationNumber)}</xsl:attribute>
<xsl:where-populated>
<ItemIdInfo>
<xsl:apply-templates select="('5LAG01') ! br:get-element(., current())" mode="data_element"/>
</ItemIdInfo>
</xsl:where-populated>
<Addr>
<xsl:choose>
<xsl:when test="StreetNumber">
<DetailAddr>
<xsl:apply-templates select="('5LAG24', '5LAG25', '5LAG26', '5LAG23', '5LAG27') ! br:get-element(., current())" mode="data_element"/>
</DetailAddr>
<xsl:if test="StreetName2">
<DetailAddr>
<xsl:apply-templates select="('5LAG29', '5LAG30', '5LAG31') ! br:get-element(., current())" mode="data_element"/>
</DetailAddr>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="('5LAG02') ! br:get-element(., current())" mode="data_element"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="('5LAG03', '5LAG13', '5LAG14', '5LAG04', '5LAG05', '5LAG06', '5LAG21', '5LAG11', '5LAG07', '5LAG20') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<LegalAddr>
<xsl:apply-templates select="('5LAG17') ! br:get-element(., current())" mode="data_element"/>
</LegalAddr>
</xsl:where-populated>
</Addr>
<xsl:apply-templates select="('5LAG09', '5LAG10', '5LAG15', '5LAG16') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="not(RiskLocationCode)">
<xsl:choose>
<xsl:when test="HomeownersAndDwellingFireRatingUnderwritingGroup/DwellingLocationCode">
<xsl:apply-templates select="('6HRU17') ! br:get-element(., current())" mode="data_element"/>
</xsl:when>
<xsl:when test="FloodCommunityInformationGroup/LocationOfBuilding = 'Y'">
<RiskLocationCd>UI</RiskLocationCd>
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="not(FireDistrictName)">
<xsl:apply-templates select="('6HRU24') ! br:get-element(., current())" mode="data_element"/>
</xsl:if>
<xsl:if test="not(FireDistrictCodeNumber)">
<xsl:apply-templates select="('6HRU25') ! br:get-element(., current())" mode="data_element"/>
</xsl:if>
</Location>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'AUTOP']">
<xsl:param name="Policy"/>
<xsl:message>In template for auto</xsl:message>
<xsl:apply-templates select="$Policy" mode="pers_auto"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="pers_auto">
<PersAutoLineBusiness>
<xsl:apply-templates select="('5BPI04') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="LocationAddressGroup/AllLocationUnitAtRiskGroup[TypeCode = 'P']/PersonalAutomobileCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="LocationAddressGroup/PersonalUmbrellaAndExcessLiabilityGroup/PersonalAutomobileCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="DriverGroup"/>
<xsl:apply-templates select="LocationAddressGroup/VehicleGroup"/>
<xsl:apply-templates select="('5BPI53', '5ISI38') ! br:get-element(., current()/..)" mode="data_element"/>
</PersAutoLineBusiness>
</xsl:template>
<xsl:template match="DriverGroup">
<PersDriver>
<xsl:attribute name="id" select="concat('D', CompanyDriversNumber)"/>
<xsl:where-populated>
<ItemIdInfo>
<xsl:apply-templates select="('5DRV02', '5DRV01') ! br:get-element(., current())" mode="data_element"/>
</ItemIdInfo>
</xsl:where-populated>
<GeneralPartyInfo>
<NameInfo>
<xsl:apply-templates select="('5DRV03') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5DRV04') ! br:get-element(., current())"/>
</NameInfo>
</GeneralPartyInfo>
<DriverInfo>
<xsl:where-populated>
<PersonInfo>
<xsl:apply-templates select="('5DRV09', '5DRV14', '5DRV08', '6PDR01', '6PDR14', '6PDR05', '5DRV22', '5DRV23', '5DRV20', '5DRV21') ! br:get-element(., current())" mode="data_element"/>
</PersonInfo>
<xsl:where-populated>
<MilitaryServiceInfo>
<xsl:apply-templates select="('6PDR43', '6PDR44') ! br:get-element(., current())" mode="data_element"/>
</MilitaryServiceInfo>
</xsl:where-populated>
</xsl:where-populated>
<License>
<LicenseTypeCd>Driver</LicenseTypeCd>
<xsl:apply-templates select="('5DRV16', '5DRV07', '5DRV15', '5DRV05', '5DRV10', '5DRV06', '6PDR40', '6PDR41', '6PDS16') ! br:get-element(., current())" mode="data_element"/>
</License>
<xsl:if test="MotorcycleDateLicensed">
<License>
<LicenseTypeCd>MotorcycleDriver</LicenseTypeCd>
<xsl:apply-templates select="('5DRV19') ! br:get-element(., current())" mode="data_element"/>
</License>
</xsl:if>
<xsl:where-populated>
<DrivingRecordRatingInfo> </DrivingRecordRatingInfo>
</xsl:where-populated>
</DriverInfo>
<PersDriverInfo>
<xsl:where-populated>
<xsl:attribute name="VehPrincipallyDrivenRef" select="PersonalAutomobileDriverSupplementaryInformationGroup/VehiclePrincipallyDriven"/>
</xsl:where-populated>
<xsl:apply-templates select="
('6PDS02', '6PDR34', '6PDR11', '6PDR37', '6PDR10', '6PDR08', '6PDS01', '6PDR03', '6PDR33', '6PDR06', '6PDR39', '5DRV12') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<FinancialResponsibilityFiling>
<xsl:apply-templates select="('6PDS08', '6PDS11', '6PDS13', '6PDS10', '6PDS09', '6PDS07', '6PDS17', '6PDS06') ! br:get-element(., current())" mode="data_element"/>
</FinancialResponsibilityFiling>
</xsl:where-populated>
<xsl:apply-templates
select="
('6PDR19', '6PDR20', '6PDR36', '6PDR16', '6PDR07',
'6PDR35', '6PDR13', '6PDR38', '6PDR12', '6PDS12', '6PDS05', '6PDR02', '6PDR15', '6PDS14', '6PDS04', '6PDR42', '5DRV17', '5DRV11', '6PDR45', '6PDR46', '6PDR49', '6PDR48') ! br:get-element(., current())"
mode="data_element"/>
</PersDriverInfo>
</PersDriver>
</xsl:template>
<xsl:template match="VehicleGroup">
<xsl:variable name="PVHGroup" select="PersonalAutomobileVehicleSupplementGroup"/>
<PersVeh>
<xsl:attribute name="id" select="concat('V', CompanyVehicleNumber)"/>
<xsl:attribute name="LocationRef">{concat('L', ancestor::LocationAddressGroup/LocationNumber)}</xsl:attribute>
<xsl:if test="$PVHGroup/GoverningDriver">
<xsl:attribute name="RatedDriverRef">{concat('D', $PVHGroup/GoverningDriver)}</xsl:attribute>
</xsl:if>
<xsl:where-populated>
<ItemIdInfo>
<xsl:apply-templates select="('5VEH01', '5VEH02') ! br:get-element(., current())" mode="data_element"/>
</ItemIdInfo>
</xsl:where-populated>
<xsl:apply-templates select="('5VEH04', '5VEH05', '5VEH03', '5VEH06', '5VEH14') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="LicensePlateRegistrationNumber or LicensePlateEffectiveDate or LicensePlateExpirationDate">
<Registration>
<RegistrationTypeCd>LicensePlate</RegistrationTypeCd>
<xsl:apply-templates select="('5VEH16') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<RegistrationTerm>
<xsl:apply-templates select="('5VEH21', '5VEH17') ! br:get-element(., current())" mode="data_element"/>
</RegistrationTerm>
</xsl:where-populated>
</Registration>
</xsl:if>
<xsl:if test="VehicleRegistrationNumber or VehicleRegistrationState">
<Registration>
<RegistrationTypeCd>StateProvRegistration</RegistrationTypeCd>
<xsl:apply-templates select="('5VEH29', '5VEH08') ! br:get-element(., current())" mode="data_element"/>
</Registration>
</xsl:if>
<xsl:apply-templates select="('5VEH26', '5VEH10', '6PVH22', '6PVH25', '5VEH19', '5VEH20', '6PVH77', '6PVH76', '6PVH09', '6PVH64', '6PVH01', '6PVH63', '6PVH03', '5VEH09', '5VEH07') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="AdditionalOtherInterestGroup"/>
<xsl:apply-templates select="('5VEH24') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<ItemModificationInfo>
<xsl:apply-templates select="('6PVH72', '6PVH73') ! br:get-element(., current())" mode="data_element"/>
</ItemModificationInfo>
</xsl:where-populated>
<xsl:apply-templates
select="
('6PVH74', '5VEH12', '6PVH49', '6PVH16', '6PVH23', '6PVH15', '6PVH59', '6PVH61', '6PVH36', '6PVH08', '6PVH51', '6PVH20', '6PVH14', '5VEH11', '6PVH10', '6PVH50', '6PVH55', '6PVH52',
'6PVH06', '6PVH18', '6PVH58', '6PVH75', '6PVH05', '6PVH38', '6PVH13', '6PVH37', '6PVH53', '5VEH23', '5VEH13', '6PVH62', '6PVH17', '6PVH60', '6PVH21') ! br:get-element(., current())"
mode="data_element"/>
<xsl:apply-templates select="PersonalAutomobileCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="('6PVH65', '6PVH66', '6PVH68', '6PVH69', '6PVH67', '5VEH25') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<AppraiserActivityInfo>
<xsl:apply-templates select="('5VEH28', '5VEH27') ! br:get-element(., current())" mode="data_element"/>
</AppraiserActivityInfo>
</xsl:where-populated>
</PersVeh>
</xsl:template>
<xsl:template match="AdditionalOtherInterestGroup">
<AdditionalInterest>
<GeneralPartyInfo>
<NameInfo>
<xsl:apply-templates select="('5AOI05') ! br:get-element(., current())"/>
</NameInfo>
<xsl:apply-templates select="following-sibling::AdditionalOtherInterestExtensionGroup[1]"/>
</GeneralPartyInfo>
<AdditionalInterestInfo>
<xsl:apply-templates select="('5AOI02', '5AOI03', '5AOI16') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5AOI14') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5AOI24', '5AOI01', '5AOI04', '5AOI12', '5AOI09') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5AOI19', '5AOI11', '5AOI18', '5AOI08') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5AOI20', '5AOI15', '5AOI13', '5AOI06', '5AOI22', '5AOI21', '5AOI23', '5AOI25') ! br:get-element(., current())" mode="data_element"/>
</AdditionalInterestInfo>
</AdditionalInterest>
</xsl:template>
<xsl:template match="AdditionalOtherInterestExtensionGroup">
<Addr>
<xsl:apply-templates select="('9AOI51', '9AOI52', '9AOI58', '9AOI59', '9AOI53', '9AOI54', '9AOI55', '9AOI65', '9AOI62') ! br:get-element(., current())" mode="data_element"/>
</Addr>
<xsl:where-populated>
<Communications>
<xsl:apply-templates select="('9AOI56', '9AOI57') ! br:get-element(., current())"/>
</Communications>
</xsl:where-populated>
</xsl:template>
<xsl:template match="PersonalAutomobileCoverageAndAdjustmentsGroup">
<Coverage>
<CoverageCd>{if (normalize-space(CoverageCode)='') then 'NOCOV' else br:key-with-fallback('autop-coverage-codes-list', CoverageCode)}</CoverageCd>
<CoverageDesc>
<xsl:value-of select="(CoverageCodeDescription, key('autop-coverage-codes-list', CoverageCode, $CODELOOKUP))[1]"/>
</CoverageDesc>
<xsl:apply-templates select="('6CVA11', '6CVA12', '6CVA13', '6CVA15', '6CVA17', '6CVA19', '6CVA16', '6CVA18', '6CVA20', '6CVA27', '6CVA28', '6CVA29', '6CVA06', '6CVA07', '6CVA24', '6CVA02', '6CVA25', '6CVA03', '6CVA05') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<Form>
<xsl:apply-templates select="('6CVA09', '6CVA26', '6CVA10') ! br:get-element(., current())" mode="data_element"/>
</Form>
</xsl:where-populated>
<xsl:apply-templates select="('6CVA04') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'HOME']">
<xsl:param name="Policy"/>
<xsl:message>In template for home</xsl:message>
<xsl:apply-templates select="$Policy" mode="home"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="home">
<HomeLineBusiness>
<xsl:apply-templates select="." mode="home_fire_mh_processing"/>
</HomeLineBusiness>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="home_fire_mh_processing">
<xsl:apply-templates select="('5BPI04') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="LocationAddressGroup/HomeownersAndDwellingFireRatingUnderwritingGroup/AdditionalOtherInterestGroup"/>
<xsl:apply-templates select="LocationAddressGroup/HomeownersAndDwellingFireRatingUnderwritingGroup/HomeownersAndDwellingFireCoverageAndAdjustmentsGroup/AdditionalOtherInterestGroup"/>
<xsl:apply-templates select="LocationAddressGroup/HomeownersAndDwellingFireRatingUnderwritingGroup"/>
<xsl:apply-templates select="LocationAddressGroup/PersonalUmbrellaAndExcessLiabilityGroup" mode="persumbrella"/>
<xsl:apply-templates select="LocationAddressGroup/PersonalUmbrellaAndExcessLiabilityGroup/HomeownersAndDwellingFireCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="LocationAddressGroup/PersonalUmbrellaAndExcessLiabilityGroup" mode="numof_coverages"/>
<xsl:apply-templates select="DriverGroup"/>
<xsl:apply-templates select="LocationAddressGroup/VehicleGroup"/>
<xsl:apply-templates select="LocationAddressGroup/SnowmobileLiabilityGroup"/>
<xsl:apply-templates select="LocationAddressGroup/PersonalPropertyScheduleSummaryGroup"/>
<xsl:apply-templates select="LocationAddressGroup/WaterUnitLiabilityGroup" mode="walgroup"/>
<xsl:apply-templates select="('5BPI53') ! br:get-element(., current()/..)" mode="data_element"/>
</xsl:template>
<xsl:template match="HomeownersAndDwellingFireRatingUnderwritingGroup">
<Dwell>
<xsl:attribute name="id" select="concat('DW', substring(Header, 13, 4))"/>
<xsl:attribute name="LocationRef">{concat('L', ancestor::LocationAddressGroup/LocationNumber)}</xsl:attribute>
<xsl:apply-templates select="('6HRU45', '6HRU01', '6HRU63') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5IIG17', '5IIG10', '6MHT21', '6MHT05') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5IIG09', '6HRU67', '6HRUB2', '6HRUA2', '6HRU70', '6FRU12', '6HRU41', '6FRU09', '6FRU10', '6HRU55', '6HRU46', '6FRU11') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<Construction>
<xsl:apply-templates select="('6HRU02', '6HRUA8', '6HRUA6', '6HRUA7', '5IIG13', '6FRU15', '6FRU05', '6FRU16', '6FRU06', '6FRU07', '6HRU03', '6FRU02', '6HRU60', '6HRU59', '5REP04', '5IIG03', '5REP06') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<RoofingMaterial>
<xsl:apply-templates select="('6HRU36', '6HRUC4') ! br:get-element(., current())" mode="data_element"/>
</RoofingMaterial>
</xsl:where-populated>
<xsl:apply-templates select="('6HRU90', '6HRU91') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<ElectricalPanelCd>
<xsl:choose>
<xsl:when test="CircuitBreakersIndicator = 'Y'">CIRC</xsl:when>
<xsl:when test="FusesIndicator = 'Y'">FUSE</xsl:when>
</xsl:choose>
</ElectricalPanelCd>
</xsl:where-populated>
<xsl:apply-templates select="('6HRU92', '6HRUA3', '6HRUA9', '6FRU20', '6FRU21', '5REP26', '6FRU24', '6FRU25', '6FRU26', '6FRU27') ! br:get-element(., current())" mode="data_element"/>
</Construction>
</xsl:where-populated>
<xsl:where-populated>
<DwellOccupancy>
<xsl:apply-templates select="('6HRU52', '6HRU05', '6HRU22', '6HRU08', '6HRU11', '6HRU68', '6HRUC7', '6HRU50', '6HRUB3', '6HRU49', '6HRU12', '6HRU69', '6HRUB4', '6HRUB5', '6HRUC2') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<UnoccupiedInfo>
<xsl:apply-templates select="('6HRUC3') ! br:get-element(., current())" mode="data_element"/>
</UnoccupiedInfo>
</xsl:where-populated>
<xsl:apply-templates select="('6HRUC8') ! br:get-element(., current())" mode="data_element"/>
</DwellOccupancy>
</xsl:where-populated>
<xsl:where-populated>
<DwellRating>
<xsl:apply-templates select="('6HRU15', '6HRU23', '6HRU80', '6HRU81', '6HRU82', '6HRU83', '6HRU84', '6HRU85', '6HRU86', '6HRU87', '6HRU51', '6FRU03', '6HRU21', '6FRU14', '6HRU20') ! br:get-element(., current())" mode="data_element"/>
</DwellRating>
</xsl:where-populated>
<xsl:where-populated>
<BldgProtection>
<xsl:apply-templates select="('6HRU09', '6HRU10', '6HRU19', '6HRU18', '6HRU48') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6HRU27', '6HRU26', '6HRU28', '6HRU29') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6HRU13', '6HRU14', '6HRU47') ! br:get-element(., current())" mode="data_element"/>
</BldgProtection>
</xsl:where-populated>
<xsl:where-populated>
<BldgImprovements>
<xsl:apply-templates select="('6HRU57', '6HRU76', '6HRU75') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="not(HeatingImprovementCode) and not(HeatingImprovementYear)">
<xsl:apply-templates select="('6HRU33') ! br:get-element(., current())"/>
</xsl:if>
<xsl:apply-templates select="('6HRU74', '6HRU73') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="not(PlumbingImprovementCode) and not(PlumbingImprovementYear)">
<xsl:apply-templates select="('6HRU32') ! br:get-element(., current())"/>
</xsl:if>
<xsl:apply-templates select="('6HRU78', '6HRU77') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="not(RoofingImprovementCode) and not(RoofingImprovementYear)">
<xsl:apply-templates select="('6HRU35') ! br:get-element(., current())"/>
</xsl:if>
<xsl:apply-templates select="('6HRU71', '6HRU72') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="not(WiringImprovementCode) and not(WiringImprovementYear)">
<xsl:apply-templates select="('6HRU31') ! br:get-element(., current())"/>
</xsl:if>
</BldgImprovements>
</xsl:where-populated>
<xsl:where-populated>
<DwellInspectionValuation>
<xsl:apply-templates select="('5REP22', '5REP48', '5IIG11') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6HRU07') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5IIG05', '5REP13', '6HRU34', '6HRU40', '6HRU04', '5IIG02', '5REP01') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<BathroomInfo>
<xsl:apply-templates select="('5REP34') ! br:get-element(., current())" mode="data_element"/>
</BathroomInfo>
</xsl:where-populated>
<xsl:where-populated>
<BathroomInfo>
<xsl:apply-templates select="('5REP35') ! br:get-element(., current())" mode="data_element"/>
</BathroomInfo>
</xsl:where-populated>
<xsl:where-populated>
<DeckInfo>
<xsl:apply-templates select="('5REP33') ! br:get-element(., current())" mode="data_element"/>
</DeckInfo>
</xsl:where-populated>
<xsl:where-populated>
<FireplaceInfo>
<xsl:apply-templates select="('5REP24', '5REP23') ! br:get-element(., current())" mode="data_element"/>
</FireplaceInfo>
</xsl:where-populated>
<xsl:if test="NumberOfPrefabFireplaces">
<FireplaceInfo>
<FirePlaceTypeCd>PreFabMetal</FirePlaceTypeCd>
<NumFireplaces>{NumberOfPrefabFireplaces}</NumFireplaces>
</FireplaceInfo>
</xsl:if>
<xsl:where-populated>
<GarageInfo>
<xsl:apply-templates select="('5REP17') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="GarageTypeCode = 'A'">
<AttachedInd>1</AttachedInd>
</xsl:if>
<xsl:apply-templates select="('5REP16', '5REP46') ! br:get-element(., current())" mode="data_element"/>
</GarageInfo>
</xsl:where-populated>
<xsl:where-populated>
<SubstructureInfo>
<xsl:where-populated>
<FoundationCd>
<xsl:choose>
<xsl:when test="DwellingReplacementCostGroup/FinishedBasementIndicator = 'Y'">Finished</xsl:when>
<xsl:when test="DwellingReplacementCostGroup/WalkoutBasementIndicator = 'Y'">Walkout</xsl:when>
<xsl:when test="DwellingReplacementCostGroup/SlabIndicator = 'Y'">Slab</xsl:when>
<xsl:when test="DwellingReplacementCostGroup/BasementConstructionType = 'C'">Crawl</xsl:when>
</xsl:choose>
</FoundationCd>
</xsl:where-populated>
<xsl:where-populated>
<SubstructureTypeCd>
<xsl:choose>
<xsl:when test="DwellingReplacementCostGroup/BasementConstructionType = 'C'">CRSP</xsl:when>
<xsl:when test="DwellingReplacementCostGroup/BasementConstructionType = 'F'">BS</xsl:when>
<xsl:when test="DwellingReplacementCostGroup/BasementIndicator = 'Y'">BS</xsl:when>
<xsl:when test="DwellingReplacementCostGroup/SlabIndicator = 'Y'">S</xsl:when>
</xsl:choose>
</SubstructureTypeCd>
</xsl:where-populated>
<xsl:where-populated>
<SurfaceArea>
<xsl:where-populated>
<NumUnits>{if (DwellingReplacementCostGroup/SlabIndicator = 'Y') then DwellingReplacementCostGroup/SlabSquareFootage else DwellingReplacementCostGroup/BasementSquareFootage}</NumUnits>
</xsl:where-populated>
</SurfaceArea>
</xsl:where-populated>
</SubstructureInfo>
</xsl:where-populated>
<xsl:where-populated>
<PorchInfo>
<xsl:apply-templates select="('5REP29', '5REP28') ! br:get-element(., current())" mode="data_element"/>
</PorchInfo>
</xsl:where-populated>
<xsl:where-populated>
<PorchInfo>
<xsl:apply-templates select="('5REP31', '5REP30') ! br:get-element(., current())" mode="data_element"/>
</PorchInfo>
</xsl:where-populated>
<xsl:apply-templates select="('5IIG15', '5IIG01') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="DwellingInspectionInformationGroup/InspectedBy">
<MiscParty>
<GeneralPartyInfo>
<NameInfo>
<CommlName>
<CommercialName>{DwellingInspectionInformationGroup/InspectedBy}</CommercialName>
</CommlName>
</NameInfo>
</GeneralPartyInfo>
<MiscPartyInfo>
<MiscPartyRoleCd>InspectionCompany</MiscPartyRoleCd>
</MiscPartyInfo>
</MiscParty>
</xsl:if>
<xsl:apply-templates select="('5IIG04', '5IIG07', '5IIG16', '5IIG08', '5IIG06', '5REP19', '5REP49') ! br:get-element(., current())" mode="data_element"/>
</DwellInspectionValuation>
</xsl:where-populated>
<xsl:apply-templates select="MobileHomeTrailerGroup"/>
<xsl:if test="SwimmingPoolCode and not(SwimmingPoolCode = 0)">
<xsl:where-populated>
<SwimmingPool>
<xsl:apply-templates select="('6HRU30') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6HRUB1', '6HRU62', '6HRU66') ! br:get-element(., current())" mode="data_element"/>
</SwimmingPool>
</xsl:where-populated>
</xsl:if>
<xsl:apply-templates select="AnimalExposureInformation, HomeownersAndDwellingFireCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="../UnderwritingQuestionGroup"/>
<xsl:where-populated>
<DwellStateSupplement>
<xsl:apply-templates
select="
('6SSR16', '6SSR20', '6SSR09', '6SSR24', '6SSR13', '6SSR18', '6SSR03', '6SSR06', '6SSR15', '6SSR30', '6SSR04', '6SSR31', '6SSR25', '6SSR27', '6SSR07',
'6SSR26', '6SSR21', '6SSR22', '6SSR12', '6SSR23', '6SSR01', '6SSR08', '6SSR14', '6SSR19', '6SSR28', '6SSR10', '6SSR02', '6SSR29', '6SSR11', '6SSR05', '6FRU18') ! br:get-element(., current())"
/>
</DwellStateSupplement>
</xsl:where-populated>
<xsl:apply-templates select="('6HRU98', '6HRU96', '6HRU97', '6HRUA4', '6HRUB6') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="ResidenceEmployeesGroup"/>
<xsl:apply-templates select="('6HRUC6') ! br:get-element(., current())" mode="data_element"/>
</Dwell>
</xsl:template>
<xsl:template match="MobileHomeTrailerGroup">
<MobileHome>
<xsl:apply-templates select="('6MHT08', '6MHT07') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="NameOfMobileHomePark">
<MiscParty>
<GeneralPartyInfo>
<NameInfo>
<CommercialName>
<CommlName>{NameOfMobileHomePark}</CommlName>
</CommercialName>
</NameInfo>
</GeneralPartyInfo>
<MiscPartyInfo>
<MiscPartyRoleCd>MobileHomePark</MiscPartyRoleCd>
</MiscPartyInfo>
</MiscParty>
</xsl:if>
<xsl:apply-templates select="('6MHT18', '6MHT10', '6MHT12', '6MHT19', '6MHT23', '6MHT20', '6MHT14', '6MHT17', '6MHT16', '6MHT15', '6MHT06', '6MHT09', '6MHT25', '6MHT26') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<AnchoringSystemCd>
<xsl:choose>
<xsl:when test="MobileHomeOverTheTopIndicator = 'Y'">OverTheTopTies</xsl:when>
<xsl:when test="MobileHomeFrameTiesIndicator = 'Y'">FrameTies</xsl:when>
<xsl:when test="MobileHomeFrameConnectorsIndicator = 'Y'">FrameConnectors</xsl:when>
<xsl:when test="MobileHomeGroundAnchorsIndicator = 'Y'">GroundAnchors</xsl:when>
<xsl:when test="MobileHomeSlabAnchorsIndicator = 'Y'">SlabAnchors</xsl:when>
<xsl:when test="MobileHomeAnchoringOtherIndicator = 'Y'">OT</xsl:when>
<xsl:when test="MobileHomeAnchoringOtherDescription = 'Y'"/>
<xsl:when test="MobileHomeSandySoilAnchorsIndicator = 'Y'">Sand</xsl:when>
</xsl:choose>
</AnchoringSystemCd>
</xsl:where-populated>
<xsl:apply-templates select="('6MHT11') ! br:get-element(., current())" mode="data_element"/>
<ItemDefinition>
<ItemTypeCd>MH</ItemTypeCd>
<xsl:apply-templates select="('6MHT02', '6MHT03', '6MHT04', '6MHT01') ! br:get-element(., current())" mode="data_element"/>
</ItemDefinition>
<xsl:apply-templates select="('6MHT24', '6MHT22', '6MHT27', '6MHT28', '6MHT29', '6MHT30', '6MHT31') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<StructureAddition>
<xsl:apply-templates select="('6MHT32', '6MHT33') ! br:get-element(., current())" mode="data_element"/>
</StructureAddition>
</xsl:where-populated>
<xsl:apply-templates select="('6MHT34', '6MHT35', '6MHT43') ! br:get-element(., current())" mode="data_element"/>
</MobileHome>
</xsl:template>
<xsl:template match="AnimalExposureInformation">
<AnimalExposureInfo>
<xsl:apply-templates select="('6AEI01', '6AEI02', '6AEI03') ! br:get-element(., current())" mode="data_element"/>
</AnimalExposureInfo>
</xsl:template>
<xsl:template match="SnowmobileLiabilityGroup">
<PersVeh>
<xsl:attribute name="id" select="concat('V', CompanySnowmobileId)"/>
<xsl:attribute name="LocationRef">{concat('L', ancestor::LocationAddressGroup/LocationNumber)}</xsl:attribute>
<xsl:where-populated>
<ItemIdInfo>
<xsl:apply-templates select="('6SMB01', '6SMB07') ! br:get-element(., current())" mode="data_element"/>
</ItemIdInfo>
</xsl:where-populated>
<xsl:apply-templates select="('6SMB03', '6SMB08', '6SMB10', '6SMB05', '6SMB04') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6SMB06') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6SMB11', '6SMB12') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="PersonalAutomobileCoverageAndAdjustmentsGroup"/>
</PersVeh>
</xsl:template>
<xsl:template match="PersonalPropertyScheduleSummaryGroup">
<PropertySchedule>
<xsl:attribute name="id">{concat('S', SummaryNumber)}</xsl:attribute>
<xsl:attribute name="LocationRef">{concat('L', ancestor::LocationAddressGroup/LocationNumber)}</xsl:attribute>
<IsSummaryInd>1</IsSummaryInd>
<xsl:apply-templates select="('5PPS18', '5PPS04', '5PPS02', '5PPS15', '5PPS05') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="HomeownersAndDwellingFireCoverageAndAdjustmentsGroup"/>
<xsl:where-populated>
<PropertyScheduleModifications>
<xsl:apply-templates select="('5PPS14', '5PPS10', '5PPS13', '5PPS09') ! br:get-element(., current())" mode="data_element"/>
</PropertyScheduleModifications>
</xsl:where-populated>
<xsl:apply-templates select="AdditionalOtherInterestGroup"/>
<IsScheduledInd>{if (PersonalPropertyItemDescriptionGroup) then 1 else 0}</IsScheduledInd>
</PropertySchedule>
<xsl:apply-templates select="PersonalPropertyItemDescriptionGroup"/>
</xsl:template>
<xsl:template match="PersonalPropertyItemDescriptionGroup">
<PropertySchedule>
<xsl:attribute name="id">{concat('I', if (ItemNumber) then ItemNumber else DeletedItemNumber)}</xsl:attribute>
<xsl:attribute name="LocationRef">{concat('L', ancestor::LocationAddressGroup/LocationNumber)}</xsl:attribute>
<xsl:attribute name="PropSummaryRef">{concat('S', ancestor::PersonalPropertyScheduleSummaryGroup/SummaryNumber)}</xsl:attribute>
<IsSummaryInd>0</IsSummaryInd>
<xsl:apply-templates select="('5PPI26', '5PPI05', '5PPI08', '5PPI18', '5PPI09') ! br:get-element(., current())" mode="data_element"/>
<ItemDefinition>
<xsl:apply-templates select="('5PPI22', '5PPI17', '5PPI23', '5PPI02', '5PPI27', '5PPI03') ! br:get-element(., current())" mode="data_element"/>
</ItemDefinition>
<xsl:where-populated>
<PropertyScheduleModifications>
<xsl:apply-templates select="('5PPI16', '5PPI14', '5PPI15', '5PPI13', '5PPI10', '5PPI11', '5PPI12') ! br:get-element(., current())" mode="data_element"/>
</PropertyScheduleModifications>
</xsl:where-populated>
<xsl:apply-templates select="AdditionalOtherInterestGroup"/>
<xsl:where-populated>
<SalesReceiptAppraisal>
<xsl:apply-templates select="('5PPI24', '5PPI21', '5PPI04', '5PPI25') ! br:get-element(., current())" mode="data_element"/>
</SalesReceiptAppraisal>
</xsl:where-populated>
<IsScheduledInd>1</IsScheduledInd>
</PropertySchedule>
</xsl:template>
<xsl:template match="WaterUnitLiabilityGroup" mode="walgroup">
<xsl:apply-templates select=".[not(WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E')]" mode="watercraft"/>
<xsl:apply-templates select=".[WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E']" mode="watercraft_accessory"/>
</xsl:template>
<xsl:template match="WaterUnitLiabilityGroup" mode="watercraft">
<Watercraft>
<xsl:attribute name="id" select="concat('W', CompanyIdForUnit)"/>
<xsl:apply-templates select="." mode="basic_watercraft_info"/>
<xsl:apply-templates select="('6WAS20', '6WAS17', '6WAS24', '6WAS14', '6WAL12', '6WAS02') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<LayUpPeriod>
<xsl:apply-templates select="('6WAS06') ! br:get-element(., current())" mode="data_element"/>
</LayUpPeriod>
</xsl:where-populated>
<xsl:apply-templates select="('6WAS23', '6WAS29', '6WAS30', '6WAS18') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="AdditionalOtherInterestGroup, HomeownersAndDwellingFireCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="('6WAL34', '6WAS25', '6WAS26', '6WAS27', '6WAS28', '6WAS31', '6WAS32', '6WAS33') ! br:get-element(., current())" mode="data_element"/>
</Watercraft>
<xsl:if test="WaterUnitSupplementaryGroup/FuelTypeCode">
<WatercraftAccessory>
<xsl:attribute name="id" select="concat('WA', CompanyIdForUnit)"/>
<xsl:attribute name="WatercraftRef" select="concat('W', CompanyIdForUnit)"/>
<xsl:apply-templates select="('6WAS19') ! br:get-element(., current())" mode="data_element"/>
</WatercraftAccessory>
</xsl:if>
</xsl:template>
<xsl:template match="WaterUnitLiabilityGroup" mode="watercraft_accessory">
<WatercraftAccessory>
<xsl:attribute name="id" select="concat('WA', CompanyIdForUnit)"/>
<xsl:if test="WaterUnitSupplementaryGroup/AttachedTo">
<xsl:attribute name="WatercraftRef" select="concat('W', WaterUnitSupplementaryGroup/AttachedTo)"/>
</xsl:if>
<xsl:apply-templates select="." mode="basic_watercraft_info"/>
<xsl:apply-templates select="('6WAL20', '6WAS19', '6WAS16', '6WAS15') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="HomeownersAndDwellingFireCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="('6WAL57', '6WAL58', '6WAL59') ! br:get-element(., current())" mode="data_element"/>
</WatercraftAccessory>
</xsl:template>
<xsl:template match="WaterUnitLiabilityGroup" mode="basic_watercraft_info">
<xsl:attribute name="LocationRef">{concat('L', ancestor::LocationAddressGroup/LocationNumber)}</xsl:attribute>
<xsl:where-populated>
<ItemIdInfo>
<xsl:apply-templates select="('6WAL01', '6WAL14') ! br:get-element(., current())" mode="data_element"/>
</ItemIdInfo>
</xsl:where-populated>
<xsl:apply-templates select="('6WAL02') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<ItemDefinition>
<xsl:apply-templates select="('6WAL02') ! br:get-element(., current())" mode="item-definition"/>
<xsl:choose>
<xsl:when test="WaterUnitTypeCode = '6'">
<xsl:apply-templates select="('6WAL47') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6WAL05') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6WAL48') ! br:get-element(., current())" mode="data_element"/>
</xsl:when>
<xsl:when test="WaterUnitTypeCode = '7'">
<xsl:apply-templates select="('6WAL49') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6WAL04') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6WAL50') ! br:get-element(., current())" mode="data_element"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="('6WAL45') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6WAL04') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6WAL46') ! br:get-element(., current())" mode="data_element"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="('6WAS22', '6WAS01', '6WAL03') ! br:get-element(., current())" mode="data_element"/>
</ItemDefinition>
</xsl:where-populated>
<xsl:apply-templates select="
('6WAS03', '6WAS21', '6WAS05', '6WAS04', '6WAL43', '6WAL07', '6WAL44', '6WAL08', '6WAL11', '6WAL19', '6WAL42', '6WAL06', '6WAL15') ! br:get-element(., current())" mode="data_element"/>
</xsl:template>
<xsl:template match="HomeownersAndDwellingFireCoverageAndAdjustmentsGroup">
<Coverage>
<CoverageCd>{if (normalize-space(CoverageCode)='') then 'NOCOV' else br:key-with-fallback('plota-coverage-codes-list', CoverageCode)}</CoverageCd>
<CoverageDesc>
<xsl:value-of select="(DescriptionField, key('plota-coverage-codes-list', CoverageCode, $CODELOOKUP))[1]"/>
</CoverageDesc>
<xsl:apply-templates select="
('6CVH39', '6CVH11', '6CVH40', '6CVH28', '6CVH34', '6CVH12') ! br:get-element(., current())" mode="data_element"/>
<xsl:if test="not(CoverageCode = ('DWELL', 'PP'))">
<xsl:apply-templates select="
('6CVH35', '6CVH13', '6CVH36', '6CVH14') ! br:get-element(., current())" mode="data_element"/>
</xsl:if>
<xsl:apply-templates select="
('6CVH18', '6CVH19', '6CVH20', '6CVH21', '6CVH22',
'6CVH24', '6CVH25', '6CVH06', '6CVH07', '6CVH29', '6CVH02', '6CVH30', '6CVH03', '6CVH05') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<Form>
<xsl:apply-templates select="('6CVH09', '6CVH31', '6CVH10') ! br:get-element(., current())" mode="data_element"/>
</Form>
</xsl:where-populated>
<xsl:apply-templates select="('6CVH04') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
<xsl:if test="CoverageCode = ('DWELL', 'PP') and (SecondDeductible or DeletedSecondDeductible)">
<Coverage>
<CoverageCd>WNDSD</CoverageCd>
<xsl:apply-templates select="
('6CVH35', '6CVH13') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
<xsl:if test="CoverageCode = ('DWELL', 'PP') and (ThirdDeductible or DeletedThirdDeductible)">
<Coverage>
<CoverageCd>THEFT</CoverageCd>
<xsl:apply-templates select="
('6CVH36', '6CVH14') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:if>
</xsl:template>
<xsl:template match="ResidenceEmployeesGroup">
<ResidenceEmployees>
<xsl:apply-templates select="('6REG01', '6REG02', '6REG03', '6REG04', '6REG05') ! br:get-element(., current())" mode="data_element"/>
</ResidenceEmployees>
</xsl:template>
<xsl:template match="PersonalUmbrellaAndExcessLiabilityGroup" mode="persumbrella">
<xsl:where-populated>
<PersUmbrella>
<xsl:apply-templates select="('5PUL01', '5PUL09') ! br:get-element(., current())" mode="data_element"/>
</PersUmbrella>
</xsl:where-populated>
</xsl:template>
<xsl:template match="*" mode="numof_coverages">
<xsl:variable name="NumOfCovGroup" select="ancestor::PersonalUmbrellaAndExcessLiabilityGroup/HomeownersAndDwellingFireCoverageAndAdjustmentsGroup"/>
<xsl:if test="name() = 'DeletedNumberOfAutomobiles' and not($NumOfCovGroup[CoverageCode = 'AUTO'])">
<xsl:apply-templates select="." mode="persumb_numof_cov"/>
</xsl:if>
<xsl:if test="name() = 'DeletedNumberOfRecreationalVehicles' and not($NumOfCovGroup[CoverageCode = 'RECVH'])">
<xsl:apply-templates select="." mode="persumb_numof_cov"/>
</xsl:if>
<xsl:if test="name() = 'DeletedNumberOfResidences' and not($NumOfCovGroup[CoverageCode = ('RESID', 'RES##')])">
<xsl:apply-templates select="." mode="persumb_numof_cov"/>
</xsl:if>
<xsl:if test="name() = 'DeletedNumberOfRentedDwellings' and not($NumOfCovGroup[CoverageCode = 'RENT'])">
<xsl:apply-templates select="." mode="persumb_numof_cov"/>
</xsl:if>
<xsl:if test="name() = 'DeletedNumberOfOfficesStudios' and not($NumOfCovGroup[CoverageCode = 'OFICE'])">
<xsl:apply-templates select="." mode="persumb_numof_cov"/>
</xsl:if>
<xsl:if test="name() = 'DeletedNumberOfWatercraft' and not($NumOfCovGroup[CoverageCode = ('BOAT', 'BOT##')])">
<xsl:apply-templates select="." mode="persumb_numof_cov"/>
</xsl:if>
<xsl:if test="name() = 'DeletedNumberOfYouthfulOperators' and not($NumOfCovGroup[CoverageCode = ('YDDRV', 'YDR##')])">
<xsl:apply-templates select="." mode="persumb_numof_cov"/>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="persumb_numof_cov">
<Coverage>
<CoverageCd>
<xsl:value-of select="key('plota-cov-code-by-pulname-list', name(), $CODELOOKUP)/@xmlCode"/>
</CoverageCd>
<Option>
<OptionTypeCd>Num1</OptionTypeCd>
<OptionValue>{.}</OptionValue>
</Option>
</Coverage>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'DFIRE']">
<xsl:param name="Policy"/>
<xsl:message>In template for dwelling fire</xsl:message>
<xsl:apply-templates select="$Policy" mode="dwelling_fire"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="dwelling_fire">
<DwellFireLineBusiness>
<xsl:apply-templates select="." mode="home_fire_mh_processing"/>
</DwellFireLineBusiness>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'PUMBR']">
<xsl:param name="Policy"/>
<xsl:message>In template for personal umbrella</xsl:message>
<xsl:apply-templates select="$Policy" mode="pers_umb"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="pers_umb">
<PersUmbrellaLineBusiness>
<xsl:apply-templates select="." mode="home_fire_mh_processing"/>
</PersUmbrellaLineBusiness>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'MHOME']">
<xsl:param name="Policy"/>
<xsl:message>In template for mobile home</xsl:message>
<xsl:apply-templates select="$Policy" mode="pers_mhome"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="pers_mhome">
<HomeLineBusiness>
<xsl:apply-templates select="." mode="home_fire_mh_processing"/>
</HomeLineBusiness>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'INMRP']">
<xsl:param name="Policy"/>
<xsl:message>In template for personal inland marine</xsl:message>
<xsl:apply-templates select="$Policy" mode="pers_im"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="pers_im">
<PersInlandMarineLineBusiness>
<xsl:apply-templates select="." mode="home_fire_mh_processing"/>
</PersInlandMarineLineBusiness>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'BOAT']">
<xsl:param name="Policy"/>
<xsl:message>In template for boat</xsl:message>
<xsl:apply-templates select="$Policy" mode="pers_boat"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="pers_boat">
<WatercraftLineBusiness>
<xsl:apply-templates select="('5BPI04') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="DriverGroup"/>
<xsl:apply-templates select="LocationAddressGroup/WaterUnitLiabilityGroup" mode="walgroup"/>
</WatercraftLineBusiness>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'FLOOD']">
<xsl:param name="Policy"/>
<xsl:message>In template for flood</xsl:message>
<xsl:apply-templates select="$Policy" mode="flood"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="flood">
<HomeLineBusiness>
<xsl:apply-templates select="('5BPI04') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="LocationAddressGroup/BuildingConstructionInformationGroup/AdditionalOtherInterestGroup"/>
<Dwell>
<xsl:apply-templates select="('5BCI38') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6MHT21', '6MHT05') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6FRU12', '6FRU09', '6FRU10', '6FRU11') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<Construction>
<xsl:apply-templates select="('6FRU15', '6FRU05', '6FRU16', '6FRU06', '6FRU07') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5BCI01') ! br:get-element(., current())"/>
<xsl:apply-templates select="('6FRU02') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5BCI45') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('6FRU20', '6FRU21', '6FRU24', '6FRU25', '6FRU26', '6FRU27') ! br:get-element(., current())" mode="data_element"/>
</Construction>
</xsl:where-populated>
<xsl:where-populated>
<DwellOccupancy>
<xsl:apply-templates select="('5BCI39') ! br:get-element(., current())" mode="data_element"/>
</DwellOccupancy>
</xsl:where-populated>
<xsl:where-populated>
<DwellRating>
<xsl:apply-templates select="('6FRU03', '6FRU14') ! br:get-element(., current())" mode="data_element"/>
</DwellRating>
</xsl:where-populated>
<xsl:where-populated>
<BldgImprovements>
<xsl:apply-templates select="('5BCI02') ! br:get-element(., current())" mode="data_element"/>
</BldgImprovements>
</xsl:where-populated>
<DwellInspectionValuation>
<xsl:apply-templates select="('5BCI17', '5BCI04', '5BCI07') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<GarageInfo>
<xsl:apply-templates select="('5BCI55', '5BCI56', '5BCI57', '5BCI58', '5BCI59', '5BCI60', '5BCI61') ! br:get-element(., current())" mode="data_element"/>
</GarageInfo>
</xsl:where-populated>
</DwellInspectionValuation>
<xsl:apply-templates select="MobileHomeTrailerGroup"/>
<xsl:apply-templates select="LocationAddressGroup/BuildingConstructionInformationGroup/CommercialLinesCoverageGroup"/>
<xsl:apply-templates select="('5BCI40', '5BCI13', '5BCI14', '5FCI07', '5BCI15', '5BCI23', '5BCI25', '5BCI16', '5BCI26', '5BCI27', '5BCI21', '5BCI03') ! br:get-element(., current())" mode="data_element"/>
<xsl:where-populated>
<DwellStateSupplement>
<xsl:apply-templates select="('6FRU18') ! br:get-element(., current())"/>
</DwellStateSupplement>
</xsl:where-populated>
<FloodInfo>
<xsl:apply-templates select="('5BCI33', '5BCI34', '5BCI35', '5BCI11', '5BCI12', '5BCI09', '5BCI24', '5BCI72', '5BCI28', '5BCI29', '5BCI30', '5BCI31', '5BCI37', '5BCI18') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5BCI41') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5BCI19') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5BCI43') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5BCI22') ! br:get-element(., current())"/>
<FloodCommunityInfo>
<xsl:apply-templates select="('5FCI02', '5FCI03', '5FCI06', '5FCI04', '5FCI08', '5BCI06') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5BCI42') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="('5BCI20') ! br:get-element(., current())"/>
<xsl:apply-templates select="('5FCI09', '5FCI10', '5FCI17') ! br:get-element(., current())" mode="data_element"/>
</FloodCommunityInfo>
<xsl:apply-templates select="('5BCI66', '5BCI44', '5BCI46', '5BCI47', '5BCI48', '5BCI49', '5BCI50', '5BCI51', '5BCI52', '5BCI53', '5BCI54', '5BCI62', '5BCI63', '5BCI65') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="FloodEquipmentGroup/EquipmentTypeCd"/>
<xsl:apply-templates select="('5BCI71', '5BCI68', '5BCI69', '5BCI70', '5BCI73', '5BCI74', '5BCI75', '5BCI36', '5BCI64', '5BCI76', '5BCI77', '5BCI78', '5BCI79', '5BCI80', '5BCI81', '5BCI82') ! br:get-element(., current())" mode="data_element"/>
</FloodInfo>
</Dwell>
<xsl:apply-templates select="('5BPI53') ! br:get-element(., current()/..)" mode="data_element"/>
</HomeLineBusiness>
</xsl:template>
<xsl:template match="EquipmentTypeCd">
<FloodEquipmentInfo>
<StoredEquipmentTypeCd>{.}</StoredEquipmentTypeCd>
<StoredEquipmentDesc>{ancestor::FloodEquipmentGroup/EquipmentDescription}</StoredEquipmentDesc>
</FloodEquipmentInfo>
</xsl:template>
<xsl:template match="CommercialLinesCoverageGroup">
<Coverage>
<CoverageCd>{if (normalize-space(CoverageCode)='') then 'NOCOV' else br:key-with-fallback('plota-coverage-codes-list', CoverageCode)}</CoverageCd>
<CoverageDesc>
<xsl:value-of select="(Description, key('plota-coverage-codes-list', CoverageCode, $CODELOOKUP))[1]"/>
</CoverageDesc>
<xsl:apply-templates
select="('5CVG04', '5CVG07', '5CVG10', '5CVG13', '5CVG16', '5CVG19', '5CVG22', '5CVG28', '5CVG29', '5CVG30', '5CVG31', '5CVG32', '5CVG33', '5CVG34', '5CVG35', '5CVG37', '5CVG39', '5CVG41', '5CVG42', '5CVG43', '5CVG44', '5CVG45', '5CVG46', '5CVG47', '5CVG48', '5CVG49', '5CVG50', '5CVG51', '5CVG52', '5CVG53', '5CVG26', '5CVG27', '5CVG57', '5CVG58', '5CVG55', '5CVG56', '5CVG59') ! br:get-element(., current())"
mode="data_element"/>
<xsl:where-populated>
<Form>
<xsl:apply-templates select="('5CVG60', '5CVG61') ! br:get-element(., current())" mode="data_element"/>
</Form>
</xsl:where-populated>
<xsl:apply-templates select="('5CVG59') ! br:get-element(., current())" mode="data_element"/>
</Coverage>
</xsl:template>
<xsl:template match="br:LOBLevel[@lob = 'PPKGE']">
<xsl:param name="Policy"/>
<xsl:message>In template for personal package</xsl:message>
<xsl:apply-templates select="$Policy" mode="pers_pkg"/>
</xsl:template>
<xsl:template match="BasicPolicyInformationGroup" mode="pers_pkg">
<xsl:apply-templates select="descendant::HomeownersAndDwellingFireRatingUnderwritingGroup"/>
<xsl:apply-templates select="descendant::DriverGroup"/>
<xsl:apply-templates select="descendant::VehicleGroup"/>
<xsl:apply-templates select="descendant::PersonalPropertyScheduleSummaryGroup"/>
<xsl:apply-templates select="descendant::WaterUnitLiabilityGroup[not(WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E')]" mode="watercraft"/>
<xsl:apply-templates select="descendant::WaterUnitLiabilityGroup[WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E']" mode="watercraft_accessory"/>
<xsl:apply-templates select="PackageInformationGroup" mode="pers_pkg"/>
</xsl:template>
<xsl:template match="PackageInformationGroup" mode="pers_pkg">
<xsl:variable name="perspkg-lob-table"
select="
map {
'AUTOP': 'Auto',
'HOME': 'Home',
'DFIRE': 'DwellFire',
'PUMBR': 'Umbrella',
'INMRP': 'PersInlandMarine',
'BOAT': 'Watercraft'
}"/>
<xsl:element name="{'PersPkg' || $perspkg-lob-table(LineOfBusinessCode) || 'LineBusiness'}">
<xsl:if test="descendant::HomeownersAndDwellingFireRatingUnderwritingGroup">
<xsl:attribute name="DwellRefs">
<xsl:for-each select="descendant::HomeownersAndDwellingFireRatingUnderwritingGroup">
<xsl:value-of select="concat('DW', substring(Header, 13, 4), ' ')"/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::BasicPolicyInformationGroup/DriverGroup">
<xsl:attribute name="DriverRefs">
<xsl:for-each select="ancestor::BasicPolicyInformationGroup/DriverGroup">
<xsl:value-of select="concat('D', CompanyDriversNumber, ' ')"/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="descendant::VehicleGroup">
<xsl:attribute name="VehRefs">
<xsl:for-each select="descendant::VehicleGroup">
<xsl:value-of select="concat('V', CompanyVehicleNumber, ' ')"/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="descendant::PersonalPropertyScheduleSummaryGroup">
<xsl:attribute name="PropScheduleRefs">
<xsl:for-each select="descendant::PersonalPropertyScheduleSummaryGroup">
<xsl:value-of select="concat('S', SummaryNumber, ' ')"/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="descendant::WaterUnitLiabilityGroup[not(WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E')]">
<xsl:attribute name="WatercraftRefs">
<xsl:for-each select="descendant::WaterUnitLiabilityGroup[not(WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E')]">
<xsl:value-of select="concat('W', CompanyIdForUnit, ' ')"/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="descendant::WaterUnitLiabilityGroup[WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E']">
<xsl:attribute name="DwellRefs">
<xsl:for-each select="descendant::WaterUnitLiabilityGroup[WaterUnitTypeCode = '6' or WaterUnitTypeCode = '7' or WaterUnitTypeCode = 'A' or WaterUnitTypeCode = 'E']">
<xsl:value-of select="concat('WA', CompanyIdForUnit, ' ')"/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="('5PIG01', '5PIG02', '5PIG05', '5PIG07', '5PIG03', '5PIG08', '5PIG10', '5PIG12', '5PIG04', '5PIG14', '5PIG11') ! br:get-element(., current())" mode="data_element"/>
<xsl:apply-templates select="AdditionalOtherInterestGroup, descendant::HomeownersAndDwellingFireRatingUnderwritingGroup/AdditionalOtherInterestGroup, descendant::PersonalUmbrellaAndExcessLiabilityGroup/HomeownersAndDwellingFireCoverageAndAdjustmentsGroup"/>
<xsl:apply-templates select="descendant::PersonalUmbrellaAndExcessLiabilityGroup/*[contains(name(), 'DeletedNumberOf') and not(node() = 0 or node() = '?' or normalize-space(node()) = '')]" mode="numof_coverages"/>
<xsl:apply-templates select="descendant::PersonalUmbrellaAndExcessLiabilityGroup" mode="persumbrella"/>
<xsl:apply-templates select="UnderwritingQuestionGroup"/>
</xsl:element>
</xsl:template>
<xsl:template match="PolicyActivityGroup">
<RemarkText>{ActivityDescription}</RemarkText>
</xsl:template>
<xsl:template match="RemarksGroup">
<xsl:variable name="ParentOccurrence" select="
if (not(substring(Header, 11, 2) = 'A1')) then
substring(Header, 17, 4) || DataElementReferenced || ' Occ ' || number(substring(Header, 23, 4)) || ' - '
else
''"/>
<RemarkText>{$ParentOccurrence || RemarksText}</RemarkText>
</xsl:template>
<xsl:template match="AttachmentsGroup">
<FileAttachmentInfo>
<xsl:if test="AttachmentDescription or AdditionalDescription">
<AttachmentDesc>{if (AdditionalDescription) then concat(AttachmentDescription, ': ', AdditionalDescription) else AttachmentDescription}</AttachmentDesc>
</xsl:if>
<xsl:apply-templates select="('5ATT01', '5ATT03') ! br:get-element(., current())" mode="data_element"/>
</FileAttachmentInfo>
</xsl:template>
<!--<xsl:template match="*[contains(name(), 'Name')][starts-with(., 'C') or starts-with(., 'G')][not(name() = 'ManufacturerNameAndModelDescriptionOfUnit')]">-->
<xsl:template match="*[contains(name(), 'Name')][matches(., '^[CG]')][not(contains(name(), 'ManufacturerNameAndModelDescriptionOf'))]">
<CommlName>
<CommercialName>
<xsl:choose>
<xsl:when test="ancestor::BasicInsuredInformationGroup/SupplementaryNameGroup[NameTypeCode = 'ETC']">{node() => substring(2, string-length(node()) - 1) => concat(ancestor::BasicInsuredInformationGroup/SupplementaryNameGroup[NameTypeCode='ETC']/SupplementaryName) =>
normalize-space()}</xsl:when>
<xsl:otherwise>{node() => substring(2, string-length(node()) - 1) => normalize-space()}</xsl:otherwise>
</xsl:choose>
</CommercialName>
</CommlName>
</xsl:template>
<!--<xsl:template match="*[contains(name(), 'Name')][starts-with(., 'P')][not(name() = 'ManufacturerNameAndModelDescriptionOfUnit')]">-->
<xsl:template match="*[contains(name(), 'Name')][matches(., '^[P]')][not(contains(name(), 'ManufacturerNameAndModelDescriptionOf'))]">
<xsl:variable name="name" select="br:unpack(., (1, 8, 16, 11, 20, 4)) ! normalize-space()"/>
<PersonName>
<xsl:for-each select="'NamePrefix', 'GivenName', 'OtherGivenName', 'Surname', 'NameSuffix'">
<xsl:variable name="value-index" select="position() + 1"/>
<xsl:where-populated>
<xsl:element name="{.}">{$name[$value-index]}</xsl:element>
</xsl:where-populated>
</xsl:for-each>
</PersonName>
</xsl:template>
<xsl:template match="*[contains(name(), 'Name')][matches(., '^[F]')][not(contains(name(), 'ManufacturerNameAndModelDescriptionOf'))]">
<xsl:variable name="name" select="br:unpack(., (1, 8, 27, 20, 4)) ! normalize-space()"/>
<FamilyName>
<xsl:for-each select="'NamePrefix', 'FamilyNames', 'Surname', 'NameSuffix'">
<xsl:variable name="value-index" select="position() + 1"/>
<xsl:where-populated>
<xsl:element name="{.}">{$name[$value-index]}</xsl:element>
</xsl:where-populated>
</xsl:for-each>
</FamilyName>
</xsl:template>
<xsl:template match="*[contains(name(), 'QualifierTypeCode')]">
<QualifierTypeCd>{(.)}</QualifierTypeCd>
</xsl:template>
<xsl:template match="*[contains(name(), 'SocialSecurityNumber')]">
<TaxIdentity>
<TaxIdTypeCd>SSN</TaxIdTypeCd>
<TaxId>{.}</TaxId>
</TaxIdentity>
</xsl:template>
<xsl:template match="DeletedInterestHolderAccountNo[not(ancestor::AdditionalOtherInterestGroup/InterestHolderAccountNumber)]">
<AccountNumberId>{.}</AccountNumberId>
</xsl:template>
<xsl:template match="CertificateDate">
<xsl:choose>
<xsl:when test="ancestor::AdditionalOtherInterestGroup/CertificateRequiredIssuedCode = 'R'">
<CertificateRequiredDt>{br:al3-to-xml-date(.)}</CertificateRequiredDt>
</xsl:when>
<xsl:otherwise>
<CertificateIssuedDt>{br:al3-to-xml-date(.)}</CertificateIssuedDt>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="DeletedBaseFloodElevation[not(ancestor::BuildingConstructionInformationGroup/BaseFloodElevation)]">
<BaseFloodElevation>
<NumUnits>{.}</NumUnits>
<UnitMeasurementCd>FOT</UnitMeasurementCd>
</BaseFloodElevation>
</xsl:template>
<xsl:template match="DeletedCertificateDateRequiredIssued[not(ancestor::AdditionalOtherInterestGroup/CertificateDate)]">
<xsl:choose>
<xsl:when test="ancestor::AdditionalOtherInterestGroup/CertificateRequiredIssuedCode = 'R'">
<CertificateRequiredDt>{br:al3-to-xml-date('20' || .)}</CertificateRequiredDt>
</xsl:when>
<xsl:otherwise>
<CertificateIssuedDt>{br:al3-to-xml-date('20' || .)}</CertificateIssuedDt>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="DeletedHeatingCodeYear">
<xsl:sequence select="br:ImprovementCodeYear(., 'Heating')"/>
</xsl:template>
<xsl:template match="DeletedPlumbingCodeYear">
<xsl:sequence select="br:ImprovementCodeYear(., 'Plumbing')"/>
</xsl:template>
<xsl:template match="DeletedPolicyDateRequiredIssued[not(ancestor::AdditionalOtherInterestGroup/PolicyDateRequiredIssued)]">
<xsl:choose>
<xsl:when test="ancestor::AdditionalOtherInterestGroup/PolicyRequiredIssuedCode = 'R'">
<PolicyRequiredDt>{br:al3-to-xml-date('20' || .)}</PolicyRequiredDt>
</xsl:when>
<xsl:otherwise>
<PolicyIssuedDt>{br:al3-to-xml-date('20' || .)}</PolicyIssuedDt>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template
match="DeletedDatePurchased[not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/PurchaseDate) and not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/DwellingInspectionInformationGroup/PurchasePriceDate) and not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/DwellingInspectionInformationGroup/DeletedPurchasePriceDate) and not(ancestor::MobileHomeTrailerGroup/DatePurchased)]">
<PurchaseDt>{br:al3-to-xml-date(br:figure-century(substring(., 1, 2), substring($CurrentDate, 3, 2)) || .)}</PurchaseDt>
</xsl:template>
<xsl:template match="DeletedLowestAdjacentGrade[not(ancestor::BuildingConstructionInformationGroup/LowestAdjacentGrade)]">
<LowestAdjacentGradeElevation>
<NumUnits>{.}</NumUnits>
<UnitMeasurementCd>FOT</UnitMeasurementCd>
</LowestAdjacentGradeElevation>
</xsl:template>
<xsl:template match="DeletedLowestFloorElevation[not(ancestor::BuildingConstructionInformationGroup/LowestFloorElevation)]">
<LowFloorElevation>
<NumUnits>{.}</NumUnits>
<UnitMeasurementCd>FOT</UnitMeasurementCd>
</LowFloorElevation>
</xsl:template>
<xsl:template match="DeletedPurchasePriceDate[not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/PurchaseDate) and not(ancestor::DwellingInspectionInformationGroup/PurchasePriceDate)]">
<PurchaseDt>{br:al3-to-xml-date(br:figure-century(substring(., 1, 2), substring($CurrentDate, 3, 2)) || .)}</PurchaseDt>
</xsl:template>
<xsl:template match="DeletedReplacementCost[not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/DwellingInspectionInformationGroup/ReplacementCost)]">
<EstimatedReplacementCostAmt>
<Amt>{.}</Amt>
</EstimatedReplacementCostAmt>
</xsl:template>
<xsl:template match="DeletedRoofingCodeYear">
<xsl:sequence select="br:ImprovementCodeYear(., 'Roofing')"/>
</xsl:template>
<xsl:template match="DeletedWiringCodeYear">
<xsl:sequence select="br:ImprovementCodeYear(., 'Wiring')"/>
</xsl:template>
<xsl:template match="FullTermPremium[ancestor::PriorPolicyHistoryGroup]">
<PolicyAmt>
<Amt>{br:format-currency(., 2)}</Amt>
</PolicyAmt>
</xsl:template>
<xsl:template match="LocationNumber[ancestor::PaymentMethodInformationGroup]">
<BranchId>{.}</BranchId>
</xsl:template>
<xsl:template match="ManufacturerNameAndModelDescriptionOfUnit[not(ancestor::WaterUnitLiabilityGroup/ManufacturerNameDescriptionOfUnit) and not(ancestor::WaterUnitLiabilityGroup/ManufacturerNameDescriptionOfTrailer)]">
<Manufacturer>{.}</Manufacturer>
</xsl:template>
<xsl:template match="ManufacturerNameAndModelDescriptionOfMotor[not(ancestor::WaterUnitLiabilityGroup/ManufacturerNameDescriptionOfMotor)]">
<Manufacturer>{.}</Manufacturer>
</xsl:template>
<xsl:template match="MethodOfPaymentCode[ancestor::PaymentMethodInformationGroup]">
<AcctTypeCd>{br:key-with-fallback('method-payment-codes-list', .)}</AcctTypeCd>
</xsl:template>
<xsl:template match="MonthAndYearBuilt[ancestor::BuildingConstructionInformationGroup]">
<YearBuilt>{substring(., 1, 4)}</YearBuilt>
</xsl:template>
<xsl:template match="OtherInsuranceWithCompanyCode[not(ancestor::BasicPolicyInformationGroup/UnderwritingQuestionGroup/*[starts-with(name(), 'QuestionCodeNumber')] = 'GENRL22')]">
<QuestionAnswer>
<QuestionCd>GENRL22</QuestionCd>
<YesNoCd>
<xsl:value-of select="
if (. = 'Y' or . = 'D') then
'YES'
else
'NO'"/>
</YesNoCd>
</QuestionAnswer>
</xsl:template>
<xsl:template match="PolicyDateRequiredIssued">
<xsl:choose>
<xsl:when test="ancestor::AdditionalOtherInterestGroup/PolicyRequiredIssuedCode = 'R'">
<PolicyRequiredDt>{br:al3-to-xml-date(.)}</PolicyRequiredDt>
</xsl:when>
<xsl:otherwise>
<PolicyIssuedDt>{br:al3-to-xml-date(.)}</PolicyIssuedDt>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="ProtectionDeviceCode">
<xsl:choose>
<xsl:when test="@group_element = '6HRU27'">
<ProtectionDeviceBurglarCd>{br:key-with-fallback('protective-device-burgfire-codes-list', .)}</ProtectionDeviceBurglarCd>
</xsl:when>
<xsl:when test="@group_element = '6HRU26'">
<ProtectionDeviceFireCd>{br:key-with-fallback('protective-device-burgfire-codes-list', .)}</ProtectionDeviceFireCd>
</xsl:when>
<xsl:when test="@group_element = '6HRU28'">
<ProtectionDeviceSmokeCd>{br:key-with-fallback('protective-device-smoke-codes-list', .)}</ProtectionDeviceSmokeCd>
</xsl:when>
<xsl:when test="@group_element = '6HRU29'">
<ProtectionDeviceSprinklerCd>{br:key-with-fallback('protective-device-sprinkler-codes-list', .)}</ProtectionDeviceSprinklerCd>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template
match="DatePurchased[not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/PurchaseDate) and not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/DwellingInspectionInformationGroup/PurchasePriceDate) and not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/DwellingInspectionInformationGroup/DeletedPurchasePriceDate)]">
<PurchaseDt>{br:al3-to-xml-date(.)}</PurchaseDt>
</xsl:template>
<xsl:template match="PurchasePriceDate[not(ancestor::HomeownersAndDwellingFireRatingUnderwritingGroup/PurchaseDate)]">
<PurchaseDt>{br:al3-to-xml-date(.)}</PurchaseDt>
</xsl:template>
<xsl:template match="SerialNumber[ancestor::SnowmobileLiabilityGroup]">
<VehIdentificationNumber>{.}</VehIdentificationNumber>
</xsl:template>
<xsl:template match="SwimmingPoolCode">
<AboveGroundInd>
<xsl:choose>
<xsl:when test=". = '1' or . = '2' or . = '5' or . = '7' or . = '8'">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</AboveGroundInd>
</xsl:template>
<xsl:template match="WaterUnitTypeCode" mode="item-definition">
<ItemTypeCd>{br:key-with-fallback('watercraft-definition-type-codes-list', .)}</ItemTypeCd>
</xsl:template>
<xsl:template match="DataElement" mode="br:mapping">
<xsl:variable name="attributes" select="@* except @al3Elements"> </xsl:variable>
<xsl:for-each select="tokenize(@al3Elements, ' ')">
<DataElement>
<xsl:attribute name="al3Elements" select="."/>
<xsl:for-each select="$attributes">
<xsl:copy-of select="."/>
</xsl:for-each>
</DataElement>
</xsl:for-each>
</xsl:template>
<xsl:function name="br:unpack" as="xs:string*">
<!-- For splitting fixed width data strings.
This isn't a "real" unpack, but it will take a string and a sequence of lengths, then
return [length] characters of the string, in order: unpack("abcd" (1,1,2)) would return
'a', 'b', 'cd' -->
<xsl:param name="input-string" as="xs:string"/>
<xsl:param name="offsets" as="xs:numeric*"/>
<xsl:variable name="args" select="br:convert-offset-seq($offsets)"/>
<xsl:variable name="partial" select="substring($input-string, ?, ?)"/>
<xsl:sequence select="$args ! apply($partial, .)"/>
</xsl:function>
<xsl:function name="br:convert-offset-seq" as="array(xs:numeric)*">
<!-- Takes a sequence of lengths and converts it to a sequence of
pairs showing the start position of each length -->
<xsl:param name="offsets" as="xs:numeric*"/>
<xsl:sequence
select="
fold-left($offsets, (), function ($result, $input) {
let $s := if (empty($result)) then
1
else
apply(function ($x, $y) {
$x + $y
}, $result[last()])
return
($result, [$s, $input])
})
"
/>
</xsl:function>
<xsl:function name="br:al3-to-xml-date" as="xs:string">
<xsl:param name="al3-date" as="xs:string"/>
<xsl:sequence select="
if ($al3-date => ends-with('000000')) then
''
else
$al3-date => br:unpack((4, 2, 2)) => string-join('-')"/>
</xsl:function>
<xsl:function name="br:figure-century" as="xs:string">
<xsl:param name="yy" as="xs:string"/>
<xsl:param name="threshold"/>
<xsl:sequence select="
if ($yy &gt; $threshold) then
'19'
else
'20'"/>
</xsl:function>
<xsl:function name="br:key-with-fallback" as="xs:string">
<xsl:param name="table" as="xs:string"/>
<xsl:param name="value" as="xs:string"/>
<xsl:variable name="LookupValue" select="key($table, $value, $CODELOOKUP)/@xmlCode"/>
<xsl:sequence select="
if (not($LookupValue = '') and not(empty($LookupValue))) then
$LookupValue
else
$value"/>
</xsl:function>
<xsl:function name="br:format-currency" as="xs:double">
<xsl:param name="al3-currency-amount" as="xs:string"/>
<xsl:param name="decimal-positions" as="xs:integer"/>
<xsl:variable name="NegativeValueFlag" select="
if (substring($al3-currency-amount, string-length($al3-currency-amount), 1) = '-') then
true()
else
false()"/>
<xsl:variable name="NumericCurrencyAmt"
select="
if ($decimal-positions = 0) then
number(substring($al3-currency-amount, 1, string-length($al3-currency-amount) - 1))
else
number(substring($al3-currency-amount, 1, string-length($al3-currency-amount) - 1)) div 100"/>
<xsl:sequence select="
if ($NegativeValueFlag = true()) then
$NumericCurrencyAmt * -1
else
$NumericCurrencyAmt"/>
</xsl:function>
<xsl:function name="br:format-phone" as="xs:string">
<xsl:param name="al3-phone-number" as="xs:string"/>
<xsl:sequence select="'+1-' || substring($al3-phone-number, 1, 3) || '-' || substring($al3-phone-number, 4, 7)"/>
</xsl:function>
</xsl:stylesheet>
(4-4/6)