XML Generator Template Issues
I’m trying to use a XML Generating template to bind some JSON to XML. It looks like it should work to me but it never binds correctly. I’ve simplified the template down just to the piece that is failing. The input JSON looks like : [{"import-record":{"@type-name":"mentoring","native":{"field":[{"@type":"person-list","@name":"c-advisee","people":[{"person":{"last-name":"Ouyang","first-names":"Mengyao"}},{"person":{"last-name":"Liu","first-names":"Jingyi"}},{"person":{"last-name":"Giannakakis","first-names":"Georgios"}},{"person":{"last-name":"Cao","first-names":"Sufeng"}},{"person":{"last-name":"Fiedler","first-names":"Jacob S."}}]}]}}}] And my template looks like: <?xml version='1.0' encoding='UTF-8'?> <import-record type-id="$import-record.at-type-id" type-name="$import-record.at-type-name"> <native>#foreach($field in $import-record.native.field) <field name="$field.at-name"> <people>#foreach($person in $field.people.person) <person> <links>#foreach($link in $person.links.link) <link type="$link.at-type" privacy="$link.at-privacy" href="$link.at-href" id="$link.at-id"/>#end </links> <last-name>$person.last-name</last-name> <initials>$person.initials</initials> <first-names>$person.first-names</first-names> <addresses>#foreach($address in $person.addresses.address) <address type="$address.at-type" iso-country-code="$address.at-iso-country-code">#foreach($line in $address.line) <line type="$line.at-type">$line.value</line>#end <grid href="$address.grid.at-href" longitude="$address.grid.at-longitude" latitude="$address.grid.at-latitude" id="$address.grid.at-id"/> </address>#end </addresses> <email-address>$person.email-address</email-address> <identifiers>#foreach($identifier in $person.identifiers.identifier) <identifier scheme="$identifier.at-scheme">$identifier.value</identifier>#end </identifiers> </person>#end </people> </field>#end </native> </import-record> Pipeline sequence is: The output out of XML Generator is: "xml": "<?xml version="1.0" encoding="UTF-8"?><import-record type-name="mentoring"><native> <field name="c-advisee"><people> </people></field> </native></import-record>" I don’t understand given the template and the data why the values are not populating?4.8KViews0likes5CommentsTip: Generate XML with Velocity template with array/list data
Spent some time with null checks in the velocity template and would like to share the findings: If you have data in an array such as this example: [ { "Lines": [ { "TEST1": null, "TEST2": "Text" } ] } ] If you try to do a null and empty value check using standard velocity methods (such as this) you will run in to problems when the input data is from an array. Normally when doing null and empty checks you can simply use #if($TEST1 && $TEST1 != "") dosomething #end But when processing data in the array this will not work (the evaluation will be true even if the JSON input value is null: #if($Lines[0].TEST1 && $TEST1 != "") dosomething #end This will work (null value, empty value or if the variable does not exist in the array): #if($Lines[0].TEST1 != "***NO DATA***" && $Lines[0].TEST1 != "") dosomething #end Same think if you are in a #foreach loop #foreach($Line in $Lines) #if($Line.TEST1 != "***NO DATA***" && $Line.TEST1 != "") dosomething #end #end The thing where the value is set to ***NO DATA*** seem to be a SnapLogic behaviour, maybe someone can confirm this? I hope this will save someone a few hours.4.3KViews3likes1CommentInvalid XML Character (Unicode: 0x8)
I’m using the XML Generator snap. I’ve already stripped out the usual suspect characters (&, <, >, ", ", %) but I am still getting the following error. Writing document to error view with behavior: continue; reason=An invalid XML character (Unicode: 0x8) was found in the element content of the document. I’m processing a VERY large file, so that preview function isn’t helping much. Does anyone have a suggestion on how I can locate and replace the offending unicode character?Parsing XML created using XML Generator: a simpler way
I’m trying to test a pipeline that receives incoming payload as XML and processes it using some static XML specified in the XML Generator SNAP. My problem is, I would like the XML Generator generated XML to be converted to JSON… Right now it looks like the XML Parser cannot directly serve as a downstream snap to the XML Generator snap… so I"m having to do the following to test with the generated XML: That’s right, I need to output the XML to a file and then read the file and parse that… Can someone please tell me if there’s an easier way of going from XML Generator → XML Parser?3KViews0likes2CommentsAn XML Generator & XML Formatter Snaps example
Here’s an example illustrating the use case of the snaps XML Generator, XML formatter and File writer. The 1st snap “XML Generator” of the pipeline generates a document format data with the given xml input configured in the snap on “Edit XML *” in snap settings. The 2nd snap “XML Formatter” accepts the document format and encapsulates the data into XML formates and provides the the binary output which can be an input to the File writer snap which accepts the binary input. Attached is the .slp for pipeline reference.XMLGenerator_Formatter_2017_03_1.slp (4.1 KB)4.6KViews1like1Comment