Skip to content

feature request: implicit container tags #27

@afflux

Description

@afflux

I'm parsing AUTOSAR XML files that often wrap repeating elements in a container element. To parse this, I need many constructs like this:

#[derive(XmlRead, Debug, Clone)]
#[xml(tag = "COMPU-INTERNAL-TO-PHYS")]
struct CompuInternalToPhys<'a> {
    #[xml(child = "COMPU-SCALES", default)]
    compu_scales: CompuScales<'a>,
}

#[derive(XmlRead, Debug, Clone, Default)]
#[xml(tag = "COMPU-SCALES")]
struct CompuScales<'a>(#[xml(child = "COMPU-SCALE")] Vec<CompuScale<'a>>);

#[derive(XmlRead, Debug, Clone)]
#[xml(tag = "COMPU-SCALE")]
struct CompuScale<'a> { 
    [...]
}

I'd love to be able to specify the container type on the field of the outer structure like this:

#[derive(XmlRead, Debug, Clone)]
#[xml(tag = "COMPU-INTERNAL-TO-PHYS")]
struct CompuInternalToPhys<'a> {
    #[xml(container = "COMPU-SCALES", child = "COMPU-SCALE", default)]
    compu_scales: Vec<CompuScale<'a>>,
}

#[derive(XmlRead, Debug, Clone)]
#[xml(tag = "COMPU-SCALE")]
struct CompuScale<'a> { 
    [...]
}

If this is something you'd consider adding, I'd be happy to provide a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions