简体   繁体   中英

How to find a type declaration in an XSD?

I'm reviewing the XML for the UPS Shipping API, and the XSD contains this block:

  <xsd:complexType name="PackageType">
    <xsd:sequence>
      <xsd:element name="Description" type="xsd:string" minOccurs="0"/>
      <xsd:element name="PackagingType" type="PackagingTypeType" minOccurs="0"/>
      <xsd:element name="Dimensions" type="DimensionsType" minOccurs="0"/>
      <xsd:element name="DimWeight" type="PackageWeightType" minOccurs="0"/>
      <xsd:element name="PackageWeight" type="PackageWeightType" minOccurs="0"/>
      <xsd:element name="LargePackageIndicator" type="xsd:string" minOccurs="0"/>

...

I'd like to see what the possible values for PackageWeightType are, but I can't figure out how to backtrack. The top of the XSD is

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:ups="http://www.ups.com/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="201707">
  <xsd:include schemaLocation="IF.xsd"/>

but there's nothing in IF.xsd that I can see that would help me in my quest.

What are my next steps?

The same XSD that houses PackageType ( ShipConfirmRequest.xsd , version 201707) also contains PackageWeightType :

<xsd:complexType name="PackageWeightType">
    <xsd:sequence>
        <xsd:element name="UnitOfMeasurement" type="UnitOfMeasurementType"/>
        <xsd:element name="Weight" type="xsd:string"/>
    </xsd:sequence>
</xsd:complexType>

and UnitOfMeasurementType as well:

<xsd:complexType name="UnitOfMeasurementType">
    <xsd:sequence>
        <xsd:element name="Code" type="xsd:string"/>
        <xsd:element name="Description" type="xsd:string" minOccurs="0"/>
    </xsd:sequence>
</xsd:complexType>

Generally, to find a declaration:

  1. Search first in the XSD in which you see its use.
  2. Search next in the included/imported XSD files, and their included/imported XSDs, recursively. (Typically, if all files are in a common directory, grepping the directory tree recursively will suffice.)

If the component is in the same namespace, you need only look in the original XSD and the transitive closure of the included XSDs. If the component is in a different namespace, you can typically find the XSD based upon the referenced namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM