Zipper for creating xml requests?

908 views Asked by At

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 ?)

3

There are 3 answers

0
dfeuer On

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.

0
Gerrit On

Once had the occasion to test this tool: camprocessor It did actually work and produce valid XML files that you could customize with data from databases.

There is some guidance on this at OASIS

0
paul On

Create an XMLHttpRequest Object

All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) have a built-in XMLHttpRequest object.

Syntax for creating an XMLHttpRequest object:

xmlhttp=new XMLHttpRequest();