Skip to content

Improve XSD → Ballerina Type Generator to Support Complex Schema Features (xs:include, attributeGroup, annotation, xs:any) #8565

@daneshk

Description

@daneshk

Area

Area/Tooling

Current Limitation

We need to consume complex XML messages from third-party systems, such as IATA AIDX, and from other industry-standard XML formats. These messages are typically defined using multiple XSD files with reusable structures, but the Ballerina XSD tool currently does not fully support several important schema constructs. As a result, type generation fails or produces incomplete models, requiring manual intervention and limiting adoption.

When generating Ballerina records with the bal xsd tool, we face limitations because it cannot process certain XSD constructs commonly used in real-world schemas. This prevents automatic mapping of XML to Ballerina types, increasing development effort.

Current Limitations Identified

xs:include schemaLocation="...": Tool doesn't load external XSD references, making multi-file schemas unusable
xs:attributeGroup ref="...": Attribute groups are ignored, resulting in missing fields in generated types
xs:annotation: Documentation/metadata not captured or discarded
xs:any: Dynamic/unknown XML content not supported or mapped

Impact

  • We cannot directly generate Ballerina records for industry formats such as AIDX, FIXML, UBL, SWIFT, and GS1.
  • Manual modelling is required → time-consuming, error-prone, not scalable
  • Reduces the feasibility of Ballerina as an integration platform for XML-heavy systems
  • Potential blocker for real deployments

Suggested Improvement

Extend the bal xsd type generator to support the following features:

  • Support xs:include for external schema references
  • Support xs:attributeGroup mapping to Ballerina record fields
  • Handle and preserve xs:annotation (at minimum read/ignore gracefully)
  • Provide mapping strategy for xs:any
    e.g. map / xml / configurable mapping

Version

1.1.2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions