如何检查加拿大或美国州代码?

时间:2015-05-12 20:19:25

标签: xml xslt

我想从XML文档中显示VehicleLicensePlateState代码,具体取决于是否是加拿大州代码(例如AB,BC等)或美国州代码(WI,IL等)。

首先,我需要检查XML文档中是否找到加拿大或美国的VehicleLicensePlateState代码。

如果两者都找不到,我想显示JurisdictionText(在XML文档中路径为/ Integration / Citation / Agency / @Word)

我的IXML文档一次只能有一个VehicleLicensePlateState代码,而不是美国或加拿大,但不能同时拥有两个。

为了检查Canadian VehicleLicensePlateState代码,有一个查找.xsd文档。

还有一个带有US VehicleLicensePlateState代码的.xsd文档。我已经为每个发布了缩写代码。

根据我当前的XML文档,输出应该如下所示

<nc:IdentificationJurisdiction>
    <nc:JurisdictionUSPostalServiceCode>QC</nc:JurisdictionUSPostalServiceCode>
</nc:IdentificationJurisdiction>

XML代码

 <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="67079943" xmlns="">
    <Case InternalID="876" ID="457" Op="A" xmlns:user="http://tylertechnologies.com">
        <Charge Op="A" ID="10906070" PartyID="16770190" InternalChargeID="1616713734" InternalPartyID="1614673227" xmlns:reslib="urn:reslib">
            <Vehicle>
                <VehicleLicensePlateState>QC</VehicleLicensePlateState>
            </Vehicle>
        </Charge>
    </Case>
    <Citation Op="A" ID="5385325" xmlns:user="http://tylertechnologies.com">
        <Agency Op="A" Word="DCCON00E1"></Agency>
    </Citation>
</Integration>

XSL代码

<nc:IdentificationJurisdiction> 
<nc:JurisdictionCanadianProvinceCode>
    <xsl:value-of select="../Vehicle/VehicleLicensePlateState"/>
</nc:JurisdictionCanadianProvinceCode>
<nc:JurisdictionText>
    <xsl:value-of select="/Integration/Citation/Agency/@Word"/>
</nc:JurisdictionText>
<nc:JurisdictionUSPostalServiceCode>
    <xsl:value-of select="../Vehicle/VehicleLicensePlateState"/>
</nc:JurisdictionUSPostalServiceCode>

加拿大VehicleLicensePlateState代码文档

    <?xml version="1.0" encoding="US-ASCII"?>
<xs:schema xmlns:structures="http://release.niem.gov/niem/structures/3.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:appinfo="http://release.niem.gov/niem/appinfo/3.0/" xmlns:can="http://release.niem.gov/niem/codes/canada_post/3.0/" xmlns:ct="http://release.niem.gov/niem/conformanceTargets/3.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://release.niem.gov/niem/codes/canada_post/3.0/" version="1" xsi:schemaLocation="http://release.niem.gov/niem/appinfo/3.0/ ../../../appinfo/3.0/appinfo.xsd http://release.niem.gov/niem/conformanceTargets/3.0/ ../../../conformanceTargets/3.0/conformanceTargets.xsd" ct:conformanceTargets="http://reference.niem.gov/niem/specification/naming-and-design-rules/3.0/#ReferenceSchemaDocument">
    <xs:annotation>
        <xs:documentation>Province codes for Canada</xs:documentation>
    </xs:annotation>
    <xs:import namespace="http://release.niem.gov/niem/structures/3.0/" schemaLocation="../../../structures/3.0/structures.xsd"/>
    <xs:simpleType name="CanadianProvinceCodeSimpleType">
        <xs:annotation>
            <xs:documentation>A data type for provinces in Canada.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:enumeration value="MB">
                <xs:annotation>
                    <xs:documentation>Manitoba</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="QC">
                <xs:annotation>
                    <xs:documentation>Qu&#xe9;bec</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="CanadianProvinceCodeType">
        <xs:annotation>
            <xs:documentation>A data type for provinces in Canada.</xs:documentation>
        </xs:annotation>
        <xs:simpleContent>
            <xs:extension base="can:CanadianProvinceCodeSimpleType">
                <xs:attributeGroup ref="structures:SimpleObjectAttributeGroup"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>

美国VehicleLicensePlateState代码文档

    <?xml version="1.0" encoding="US-ASCII"?>
<xs:schema xmlns:structures="http://release.niem.gov/niem/structures/3.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:appinfo="http://release.niem.gov/niem/appinfo/3.0/" xmlns:usps-3.0.1="http://publication.niem.gov/niem/codes/usps_states/3.0/1/" xmlns:ct="http://release.niem.gov/niem/conformanceTargets/3.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://publication.niem.gov/niem/codes/usps_states/3.0/1/" version="1" xsi:schemaLocation="http://release.niem.gov/niem/appinfo/3.0/ ../../../../appinfo/3.0/appinfo.xsd http://release.niem.gov/niem/conformanceTargets/3.0/ ../../../../conformanceTargets/3.0/conformanceTargets.xsd" ct:conformanceTargets="http://reference.niem.gov/niem/specification/naming-and-design-rules/3.0/#ReferenceSchemaDocument">
    <xs:annotation>
        <xs:documentation>U.S. Postal Service Supplement</xs:documentation>
    </xs:annotation>
    <xs:import namespace="http://release.niem.gov/niem/structures/3.0/" schemaLocation="../../../../structures/3.0/structures.xsd"/>
    <xs:simpleType name="USStateCodeSimpleType">
        <xs:annotation>
            <xs:documentation>A data type for states.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:enumeration value="AA">
                <xs:annotation>
                    <xs:documentation>Armed Forces Americas (except Canada)</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="HI">
                <xs:annotation>
                    <xs:documentation>HAWAII</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="IL">
                <xs:annotation>
                    <xs:documentation>ILLINOIS</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="USStateCodeType">
        <xs:annotation>
            <xs:documentation>A data type for states.</xs:documentation>
        </xs:annotation>
        <xs:simpleContent>
            <xs:extension base="usps-3.0.1:USStateCodeSimpleType">
                <xs:attributeGroup ref="structures:SimpleObjectAttributeGroup"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>

0 个答案:

没有答案
相关问题