Rules for Mapping Existing EDIFACT MIGs to XML DTDs

11th October 1999

The following rules should be applied when mapping an existing UN/EDIFACT Message Implementation Guide (MIG) to an XML Document Type Defintion (DTD).

  1. The outermost element of the message should indicate the purpose of the message

    Example:

    <!ELEMENT FirmBooking (MessageID, Date*, Requirements*, FreeText*,
    
                           TermsGroup*,  RefersTo*, GovernmentReqsGroup*,
    
                           ChargeRatesGroup*, TransportDetailsGroup*,
    
                           NameAndAddressGroup*, GoodsIdentityGroup*,
    
                           EquipmentDetailsGroup*)                              >
    
    <!ATTLIST FirmBooking
    
              xmlns                 CDATA  #FIXED         "http://www.tieke.fi/transport/IFTMBF"
    
              xmlns:UN-EDIFACT      CDATA  #FIXED         "http://www.un.org/edifact/D96B/"
    
              xmlns:ISIS            CDATA  #FIXED         "http://www.tieke.fi/isis-xmledi"
    
              UN-EDIFACT:Id         CDATA  #FIXED         "IFTMBF:D:96B:UN:FI0076"
    
              UN-EDIFACT:Attributes CDATA  #FIXED         "0062 ReferenceNumber
    
                                                           0068 AccessReference"
    
              ReferenceNumber       CDATA                 #REQUIRED
    
              AccessReference       CDATA                 #IMPLIED              >
    
    
    
    

    Note: The ISIS namespace is used to define the constraints that apply to elements. As there are no standards for defining such constraints at present this technique is currently project specific.

    To be determined: Whether the S010 status identifiers need to be recorded in the message, or are part of the message transport protocol's handshake information.

  2. Message headers and trailers should be ignored
    Data elements associated with the message header should be assigned to the root element of the message.
    Example: See ReferenceNumber and AccessReference attributes in example above.

  3. Segment groups which contain a single segment should be ignored
    Constraints relating to the repetition of the group should become constraints that apply to the segment that makes up the group's contents.
    Example: The group referred to as GR3 in the Finnish subset of the IFTMBF message only contains a single, non-repeatable, RFF element. The group constraints can be expressed as constraints on the RefersTo element that represents the RFF element, without the addition of a specific ReferencesGroup element.

  4. Segment groups which contain repeatable groups of elementsshould be represented by an XML element whose content model indicates the elements that form the group
    Example:
    
    <!ELEMENT TransportDetailsGroup  (TransportDetails, Date*, Locations*)* >
    
    <!ELEMENT DangerousGoodsGroup    (DangerousGoods, FreeText*,
    
                                      MeasurementsGroup*, SplitGoodsGroup*)* >
    
    
    
    
  5. Where the structure of a segment depends on the value assigned to one of the data elements within it, the name of the segment should be replaced by the name of the value of the controlling data element

    Example: When CustomStatus is chosen as the subject qualifier of a free text segment then, and only then, a text reference must be used.

    <!ELEMENT GovernmetnReqsGroup (GovernmentRequirements, (CustomsStatus?, FreeText*)?) >
    
    <!ELEMENT CustomsStatus (TextID) >
    
    <!ATTLIST CustomsStatus
    
    UN-EDIFACT:Segment    CDATA  #FIXED  "FTX"
    
    UN-EDIFACT:Attributes CDATA  #FIXED  "4451 SubjectQualifier
    
                                          4453 FunctionCode
    
                                          3453 LanguageCode
    
                                          4447 FormatType"
    
    SubjectQualifier      CDATA  #FIXED  "CustomsStatus"
    
    FunctionCode          CDATA          #IMPLIED
    
    LanguageCode          CDATA  #FIXED  "ISO 639"
    
    FormatType            CDATA          #IMPLIED
    
    ISIS:Constraints      ENTITY #FIXED  "CustomsStatus.constraints"  >
    
    <!ELEMENT FreeText        (Line, (Line, (Line, (Line,Line?)?)?)?)    >
    
    <!ATTLIST FreeText
    
    UN-EDIFACT:Segment    CDATA  #FIXED  "FTX"
    
    UN-EDIFACT:Attributes CDATA  #FIXED  "4451 SubjectQualifier
    
                                          4453 FunctionCode
    
                                          3453 LanguageCode
    
                                          4447 FormatType"
    
    SubjectQualifier      (Order|Delivery|
    
                           Transportation|
    
                           CustomsDeclaration|
    
                           SpecialInstructions|
    
                           GoodsDescription|
    
                           DGS-AdditionalInformation|
    
                           DGS-TechnicalName)    #REQUIRED
    
    FunctionCode          CDATA                  #IMPLIED
    
    LanguageCode          CDATA  #FIXED          "ISO 639"
    
    FormatType            CDATA                  #IMPLIED
    
    ISIS:Constraints      ENTITY #FIXED          "FreeText.constraints"  >
    
    
    
    
    
    
  6. Each segment should be represented by a single element

    Example:

    
    <!ELEMENT NumberOfUnits     (#PCDATA)                                        >
    
    <!ATTLIST NumberOfUnits
    
              UN-EDIFACT:Segment    CDATA  #FIXED    "EQN"
    
              UnitsQualifier        CDATA            #IMPLIED
    
              ISIS:Constraints      ENTITY #FIXED    "NumberOfUnits.constraints" >
    
    
    
    
  7. Where a segment contains multiple occurrences of the same composite a separate element should be declared for the composite, and the model of the containing element should indicate the number of times the composite can occur

    Example:

    
    <!ELEMENT ProductIDs       (ItemID, (ItemID, (ItemID, (ItemID, ItemID?)?)?)?)   >
    
    <!ATTLIST ProductIDs
    
              UN-EDIFACT:Segment    CDATA  #FIXED          "PIA"
    
              ISIS:Constraints      ENTITY #FIXED          "ProductIDs.constraints" >
    
    
    
    
  8. Where a segment contains multiple different composites a separate element should be assigned to each composite that does not consist entirely of data elements whose values need to be assigned from coded lists

    Example:

    
    <!ELEMENT Requirements    (ContractType?, (Service, Service?)?,
    
                               Priority?, NatureOfCargo?)                                >
    
    <!ATTLIST Requirements
    
              UN-EDIFACT:Segment    CDATA  #FIXED          "TSR"
    
              ISIS:Constraints      ENTITY #FIXED          "Requirements.constraints" >
    
    <!ELEMENT ContractType   (#PCDATA)                                                >
    
    <!ATTLIST ContractType
    
              UN-EDIFACT:Composite  CDATA  #FIXED          "C536"
    
              Qualifier             CDATA                  #IMPLIED
    
              Agency                (AssignedByOriginator|
    
                                     AssignedByCarrier)    #IMPLIED
    
              ISIS:Constraints      ENTITY #FIXED          "ContractType.constraints" >
    
    
    
    
    
    
  9. Where a segment, or a composite, contains multiple uncoded data elements a separate element should be assigned to each data element

    Example:

    
    <!ELEMENT Service        (#PCDATA)                                            >
    
    <!ATTLIST Service
    
              UN-EDIFACT:Element    CDATA  #FIXED          "7273"
    
              Qualifier             CDATA                  #IMPLIED
    
              Agency                (AssignedByOriginator|
    
                                     AssignedByCarrier)    #IMPLIED
    
              ISIS:Constraints      ENTITY #FIXED          "Service.constraints"  >
    
    
    
    
  10. Each data element within a segment or composite whose value must conform to a predefined list of codes should be represented as an attribute of the element representing its containing segment

    Example:

    
    <!ELEMENT MessageID       (#PCDATA)                                           >
    
    <!ATTLIST MessageID
    
              UN-EDIFACT:Segment    CDATA  #FIXED      "BGM"
    
              UN-EDIFACT:Attributes CDATA  #FIXED      "1001 MessageTypeCode
    
                                                        1131 Qualifier
    
                                                        3055 Agency
    
                                                        1000 MessageTypeName
    
                                                        1225 MessageFunction
    
                                                        1056 Version
    
                                                        1060 RevisionNo
    
                                                        4343 ResponseType"
    
              MessageTypeCode       CDATA              #IMPLIED
    
              Qualifier             CDATA              #IMPLIED
    
              Agency                CDATA              #IMPLIED
    
              MessageTypeName       CDATA              #IMPLIED
    
              MessageFunction       CDATA              #IMPLIED
    
              Version               CDATA              #IMPLIED
    
              RevisionNo            CDATA              #IMPLIED
    
              ResponseType          CDATA              #IMPLIED
    
              ISIS:Constraints      ENTITY #FIXED      "MessageID.constraints"    >
    
    
    
    
  11. Where the MIG limits the permitted set of attribute values a list of permitted values should be defined as part of the attribute declaration

    Example:

    
    <!ELEMENT Temperature      (#PCDATA)                                          >
    
    <!ATTLIST Temperature
    
              UN-EDIFACT:Segment    CDATA  #FIXED          "TMP"
    
              UN-EDIFACT:Attributes CDATA  #FIXED          "6245 TemperatureQualifier
    
                                                            6411 MeasurementUnit"
    
              TemperatureQualifier  CDATA  #FIXED          "TransportTemperature"
    
              MeasurementUnit       (Celsius|Kelvin|
    
                                     Fahrenheit)           #IMPLIED
    
              ISIS:Constraints      ENTITY #FIXED          "Temperature.constraints"  >
    
    
    
    
  12. Where there is no constraint on which set of values is permitted from a coded list a parameter entity definition should be used to indicate the code list from which the value should be selected
    The contents of the referenced parameter entity may either be "CDATA" or "NMTOKEN", or it can be a reference to the system identifier of an external entity that contains the definition of the permitted values for the code list.

    Example:

    
    <!ENTITY % Stages "(PreCarriage|MainCarriage|FirstCarrier|
    
                        SecondCarrier|ThirdCarrier|OnCarriage)"  >
    
    <!ENTITY % Directions SYSTEM "direction.txt" >
    
    <!ENTITY % Owners     "CDATA" >
    
    
    
    <!ELEMENT TransportDetails (ConveyanceNumber?, Mode?, Means?,
    
                                Carrier?, Excess?, Identification?)              >
    
    <!ATTLIST TransportDetails
    
              UN-EDIFACT:Segment    CDATA  #FIXED  "TDT"
    
              UN-EDIFACT:Attributes CDATA  #FIXED  "8051 StageQualifier
    
                                                    8101 DirectionCode
    
                                                    8281 OwnershipCode"
    
              StageQualifier        %Stages;       #REQUIRED
    
              DirectionCode         %Directions;   #IMPLIED
    
              OwnershipCode         %Owners;       #IMPLIED
    
              ISIS:Constraints      ENTITY #FIXED  "TransportDetails.constraints" >
    
    
    
    
  13. Where only one value is permitted from a code list that value should be assigned as a fixed default value for the attribute
    Fixed values do not have to be transmitted with the XML message: they can be inferred from the XML document type definition (DTD).

    Example: See TemperatureQualifier in Temperature example above.

  14. Where one of the attribute values is more likely to be used than the others that value should be declared as the default value
    Default values do not need to be transmitted with the message: they can be inferred from the DTDs. Attributes assigned default values only need to be specified for those occurrences for which an abnormal value is required.

    Example:

    
    <!ELEMENT Date            (#PCDATA)                                           >
    
    <!ATTLIST Date
    
              UN-EDIFACT:Segment    CDATA  #FIXED          "DTM"
    
              UN-EDIFACT:Attributes CDATA  #FIXED          "2005 Of
    
                                                            2379 Format"
    
              Of                    (Document|Departure|
    
                                     Arrival)              "Document"
    
              Format                (Date|Period)          "Date"
    
              ISIS:Constraints      ENTITY #FIXED          "Date.constraints"     >
    
    
    
    
  15. The constraints that apply to elements that contain contents should be recorded in an attribute called ISIS:Constraints that references an entity declared in the DTD that identifies an XML file containing details of the constraints to be applied
    This attribute name is qualified by the ISIS name space to indicate that the structure of this XML file has been defined by the ISIS XML/EDI Pilot Project consortium rather than a recognized standards body. It is anticipated that more detailed constraints will be needed at a later stage, and that these will probably be provided by referencing XML Schemas containing relevant datatype specifications.
    Note: The referenced entity must be an unparsed XML entity, not a parameter entity. The notation used for the unparsed entity will need to be defined within the DTD, but otherwise is applicaiton dependent. The exact format of the XML-encoded constraints file used within the ISIS project is still to be determined.

    Example:

    
    <!ENTITY   ConveyanceNumber.constraints
    
      SYSTEM   "../Constraints/ConveyanceNumber.xml"
    
      NOTATION "ISIS-Constraints"                       >
    
    <!ELEMENT ConveyanceNumber (#PCDATA)                                        >
    
    <!ATTLIST ConveyanceNumber
    
              UN-EDIFACT:Element    CDATA  #FIXED "8028"
    
              ISIS:Constraints      ENTITY #FIXED "ConveyanceNumber.constraints" >
    
    
    
    
  16. References to parts of other messages, or other parts of the same message, should be represented as XML Simple Links using XPath locators
    Where the element being referenced has a unique identifier the path should reference that identifier, e.g. xlink:href='messages/message1234//id("item2345")'. Alternatively the reference can be to an element with specific contents, e.g. xlink:href='[ReferenceNumber="Message1234"]'

    Example:

    
    <!ELEMENT RefersTo    EMPTY >
    
    <!ATTLIST RefersTo
    
              UN-EDIFACT:Segment CDATA  #FIXED "RFF"
    
              DocType            CDATA  #REQUIRED
    
              DocID              CDATA  #IMPLIED
    
              Line               CDATA  #IMPLIED
    
              Version            CDATA  #IMPLIED
    
              RevisionNo         CDATA  #IMPLIED
    
              xlink:href         CDATA  #REQUIRED
    
              xmlns:xlink        CDATA  #FIXED "http://www.w3.org/XML/XLink/0.9"
    
              xlink:type         CDATA  #FIXED "simple"
    
              xlink:role         CDATA  #FIXED "reference"
    
              xlink:show         CDATA  #FIXED "new"
    
              xlink:actuate      CDATA  #FIXED "user"
    
              ISIS:Constraints   ENTITY #FIXED "RefersTo.constraints"          >