业务分析师告诉业务规则这已经改变了。现在他们希望我首先检查(计数)以查看是否有多个 NcicCode(在 VehicleMakeMapping 查找文档中)与 MncisCode(在输入文档中)匹配。如果 VehicleMakeMapping 查找文档中有多个 NcicCode,则仅使用第一个 NcicCode 作为输出。还要检查是否存在完全匹配(1 到 1),并在存在完全匹配的情况下使用 NcicCode。否则,如果没有与 MncisCode 匹配的 NcicCode,则不显示任何内容(不执行任何操作)。
我现在使用的新 XML 文件如下所示:
<VehicleMakeMapping>
<Mapping>
<NcicCode>AUHE</NcicCode>
<MncisCode>AUST</MncisCode>
<Description>Austin-Healy</Description>
</Mapping>
<Mapping>
<NcicCode>JEEP</NcicCode>
<MncisCode>JEEP</MncisCode>
<Description>Jeep (for model years 1989 throughresent)</Description>
</Mapping>
<Mapping>
<NcicCode>JEP</NcicCode>
<MncisCode>JEEP</MncisCode>
<Description>Jeep (for model years prior to 1970)</Description>
</Mapping>
<Mapping>
<NcicCode>AUPR</NcicCode>
<MncisCode>AUST</MncisCode>
<Description>Austin Products, Inc.Subsidiary Austin Industries, Inc.</Description>
</Mapping>
<Mapping>
<NcicCode>CHRS</NcicCode>
<MncisCode>CHRY</MncisCode>
<Description>Chrysler Boat Co.</Description>
</Mapping>
<Mapping>
<NcicCode>CHRY</NcicCode>
<MncisCode>CHRY</MncisCode>
<Description>Chrysler</Description>
</Mapping>
</VehicleMakeMapping>
这些显示例如 NCIC 代码 MRCU 必须转换为 DCCIS 代码 MERC 等。
Xml doc
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="IXML Case Notification Test" MessageID="67078058" xmlns="">
<Case InternalID="1616807927" ID="11747370" xmlns:user="http://tylertechnologies.com">
<Charge ID="10547226" PartyID="16580814" CurrSentenceID="155092098" InternalChargeID="1616447618" InternalPartyID="1614482843" xmlns:reslib="urn:reslib">
<ChargeOffenseDate>03/26/2014</ChargeOffenseDate>
<Vehicle>
<VehicleLicensePlateState>DC</VehicleLicensePlateState>
<VehicleLicensePlateNumber>050KTU</VehicleLicensePlateNumber>
<VehicleType Word="PASSVEH">Jeep (for model years prior to 1970)</VehicleType>
<VehicleMake Word="JEEP">Austin-Healy</VehicleMake>
<CommercialVehicleFlag>false</CommercialVehicleFlag>
<HazardousVehicleFlag>false</HazardousVehicleFlag>
<VehicleInactive>false</VehicleInactive>
</Vehicle>
</Charge>
</Case>
xslt
<xsl:template name="ChargeDetails">
<ext:Vehicle>
<nc:ItemStyleText>
<xsl:value-of select="Vehicle/VehicleType"/>
</nc:ItemStyleText>
<nc:VehicleCMVIndicator>
<xsl:value-of select="/Integration/Case/Charge/Vehicle/CommercialVehicleFlag"/>
</nc:VehicleCMVIndicator>
<j:VehicleMakeCode>
<xsl:variable name="vVehicleMake">
<xsl:value-of select="Vehicle/VehicleMake/@Word"/> </xsl:variable>
<xsl:variable name="vVehicleMakeCode" select="document(concat($gEnvPath,'\Schemas\CourtXML\ConfigFiles\VehicleMakeMapping.xml'))/VehicleMakeMapping/Mapping[MncisCode=$vVehicleMake]/MncisCode"/> <xsl:value-of select="$vVehicleMakeCode"/>
</j:VehicleMakeCode>
</ext:Vehicle>
如果 VehicleMakeMapping 查找中存在多个 NcicCode
文档,然后只需使用第一个 NcicCode 作为输出。
为了简化问题,让我们:
XML
<root>
<Vehicle>
<VehicleMake Word="ABC">not important</VehicleMake>
</Vehicle>
<Vehicle>
<VehicleMake Word="XYZ">not important</VehicleMake>
</Vehicle>
</root>
VehicleMakeMapping.xml
<VehicleMakeMapping>
<Mapping>
<NcicCode>ABCA</NcicCode>
<MncisCode>ABC</MncisCode>
<Description>abc</Description>
</Mapping>
<Mapping>
<NcicCode>ABCB</NcicCode>
<MncisCode>ABC</MncisCode>
<Description>abc abc</Description>
</Mapping>
<Mapping>
<NcicCode>ABCC</NcicCode>
<MncisCode>ABC</MncisCode>
<Description>abc abc abc</Description>
</Mapping>
</VehicleMakeMapping>
XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="map-doc" select="'path/to/VehicleMakeMapping.xml'"/>
<xsl:key name="mapping" match="Mapping" use="MncisCode" />
<xsl:template match="/root">
<xsl:copy>
<xsl:apply-templates select="Vehicle"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Vehicle">
<Vehicle>
<VehicleMakeCode>
<xsl:value-of select="key('mapping', VehicleMake/@Word, document($map-doc))[1]/NcicCode"/>
</VehicleMakeCode>
</Vehicle>
</xsl:template>
</xsl:stylesheet>
Result
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Vehicle>
<VehicleMakeCode>ABCA</VehicleMakeCode>
</Vehicle>
<Vehicle>
<VehicleMakeCode/>
</Vehicle>
</root>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)