业务分析师告诉业务规则这已经改变了。现在,他们希望我首先检查(计数)以查看是否有多个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>
答案 0 :(得分:0)
如果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>
<强>结果强>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Vehicle>
<VehicleMakeCode>ABCA</VehicleMakeCode>
</Vehicle>
<Vehicle>
<VehicleMakeCode/>
</Vehicle>
</root>
答案 1 :(得分:-1)
这是我的问题的解决方案。
<j:VehicleMakeCode>
<xsl:variable name="vVehicleMake">
<xsl:value-of select="../Vehicle/VehicleMake/@Word"/>
</xsl:variable>
<xsl:variable name="vVehicleMakeCode" select="document(concat($gEnvPath,'\ConfigFiles\VehicleMakeMapping.xml'))/VehicleMakeMapping/Mapping[MncisCode=$vVehicleMake]/NcicCode"/>
<xsl:value-of select="$vVehicleMakeCode"/>
</j:VehicleMakeCode>