Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zipper for creating xml requests?

How can one create an XML request conforming to an XSD such that the request is valid?

One way would be to create the whole request and then verify it on the XSD. Is there a way to create a request while walking the schema?

The first thought that came to mind was of Zipper, but I am really not sure if they can be used here.

Maybe I have not understood it well, but it seems Zipper's are great if there is already some structure defined and things need to be changed in that structure. Can Zipper be used for a changing structure? (E.g Appending a sequence to an array of sequence ?)

like image 979
Akshat Avatar asked Jan 24 '14 01:01

Akshat


1 Answers

As Tomalak said in a comment,

That's like trying to create meaningful strings by walking the regex. It doesn't work that way.

A zipper helps you take a meandering walk through a structure, inspecting parts and optionally modifying them; in the end, you have the option of "zipping up" the zipper to get a modified version of the original. There are at least two major problems with your idea:

  1. The structure of an XSD is not the same as, or even terribly similar to, the structure of the documents it encodes. If you were to use a zipper to modify an XSD so as to produce XML valid according to that XSD, you will end up restructuring it completely, and the type system will not help you get this right.

  2. A zipper is a way of focusing on part of some data structure. Before you think too hard about the zipper, you should think about what data structure you're unzipping. Depending on what you're doing, you may or may not find it useful to use a zipper, but the zipper and its invariants will always relate back to the structure and its invariants.

like image 66
dfeuer Avatar answered Oct 10 '22 02:10

dfeuer