Skip to content

Commit 450a71b

Browse files
committed
xml: generate random IDs for annotations if none were assigned
1 parent 9be4437 commit 450a71b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/xml.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,7 @@ impl<'a> XmlToStamConverter<'a> {
16771677
None
16781678
};
16791679

1680+
let mut have_id = false;
16801681
if let Some(template) = &element_config.id {
16811682
let context = self.context_for_node(&node, begin, end, template.as_str(), resource_id, inputfile, doc_num);
16821683
let compiled_template = self.template_engine.template(template.as_str());
@@ -1692,6 +1693,16 @@ impl<'a> XmlToStamConverter<'a> {
16921693
)?;
16931694
if !id.is_empty() {
16941695
builder = builder.with_id(id);
1696+
have_id = true;
1697+
}
1698+
}
1699+
1700+
if !have_id {
1701+
//generate a random ID if we have none
1702+
if let Some(resource_id) = resource_id {
1703+
builder = builder.with_id(stam::generate_id(&format!("{}-",resource_id), ""));
1704+
} else {
1705+
builder = builder.with_id(stam::generate_id("", ""));
16951706
}
16961707
}
16971708

0 commit comments

Comments
 (0)