| 544 | { |
| 545 | |
| 546 | void addMetadataEntry(xmlTextWriterPtr w, const MetadataNode& input) |
| 547 | { |
| 548 | |
| 549 | std::function<void (const MetadataNode&) > collectMetadata = [&] (const MetadataNode& node) |
| 550 | { |
| 551 | xmlTextWriterStartElement(w, (const xmlChar*)"Metadata"); |
| 552 | xmlTextWriterWriteAttribute(w, (const xmlChar*)"name", (const xmlChar*)node.name().c_str()); |
| 553 | xmlTextWriterWriteAttribute(w, (const xmlChar*)"type", (const xmlChar*)node.type().c_str()); |
| 554 | xmlTextWriterWriteString(w, (const xmlChar*) node.value().c_str()); |
| 555 | for (auto& m : node.children()) |
| 556 | if (!m.empty()) |
| 557 | collectMetadata(m); |
| 558 | |
| 559 | xmlTextWriterEndElement(w); |
| 560 | }; |
| 561 | |
| 562 | xmlTextWriterStartElementNS(w, (const xmlChar*)"pc", |
| 563 | (const xmlChar*)"metadata", NULL); |
| 564 | |
| 565 | for (auto& m : input.children()) |
| 566 | if (!m.empty()) |
| 567 | collectMetadata(m); |
| 568 | |
| 569 | xmlTextWriterEndElement(w); |
| 570 | xmlTextWriterFlush(w); |
| 571 | } |
| 572 | |
| 573 | |
| 574 | } // anonymous namespace |