Question

Writing nested XML files based on XSD

  • 4 November 2022
  • 1 reply
  • 12 views

Badge +21

Looking at this article writing using the XSD XML Writer: https://community.safe.com/s/article/XSD-Driven-XML

 

It seems that it is not possible to nest features together using xml_id and xml_parentid and having multiple features to write.

 

For that example I want to be able to have two featurewriters as shown below, the cap:alert and the cap:info. The way they are grouped together is that the cap:info has an xml_id and xml_parent_id which links it to the correct cap:info. I thought that woudl work, but no.... Is there no way to write complex nested xml-features other than "merging them in the workspace"?

image


1 reply

Userlevel 2
Badge +13

Hello @Sigbjørn Herstad​, thanks for posting! I think its possible to write nested feature types using ID's with FME's XSD-Driven XML Writer. I think you'd also need to manually assign the parent/child ID's in the workspace. To write to alert and info as seperate feature types, we need to remove any info{} lists from the alert feature type (as we will be writing them seperately). We can use an AttributeRemover to remove the list: info{}.

 

Next, use a seperate data stream to Explode the list: info{}. Once the list(s) are exploded into features, an AttributeCreator can be used to assign xml_parent_id and xml_id. I've added a screenshot to help illustrate the process:

 

image 

To add the info feature type: Writers > Import Feature Types > Feature Paths: 'cap:alert cap:alert/cap:info'. If you don't map the feature path or do not map it correctly, you likely won't get the correct output (important step!). I've attached the workspace to this post, you can find it attached as 2b-XSD-DrivenWriter-info.fmw. Please let me know if you have any questions about the workspace/process. I hope this answers your original question! Let me know. Happy to help, Kailin Opaleychuk

Reply