Abstract:
Provide a document type which is defined to be a holder for other, arbitrary XML data.
Problem:
Different sets of data need to be delivered to a system in a consistent way.
Context:
This pattern applies when different sets of data need to be used in some system. The structure of the data itself varies, or is not known at the time the system is being built.
Forces:
This pattern allows for Flexibility by allowing elements from other documents to be embedded into a consistent holder.
This pattern allows for a separation of concerns between different document types. Mixing issues such as transport with document data is usually not a good idea.
Solution:
Create a document type which will act as a holder for the varying set of data.
Examples:
This example shows a very simple envelope which consists of sender and a receiver children elements. Note the use of two different namespaces to allow an XML parser to read the document, which contains elements from both the Envelope (envelope.dtd) and the embedded data (my-stuff.dtd)
<e:Envelope xmlsns:e="http://xmlpatterns.com/envelope.dtd">
<e:sender name="bob"/>
<e:receiver name="http://xmlpatterns.com/message-receiver.cgi"/>
<myStuff:message xmlsns:e="http://xmlpatterns.com/my-stuff.dtd">
This is my message
</myStuff:message>
</e:Envelope>
Discussion:
The Envelope is used as a delivery mechanism for XML data. Document types created for holding domain data should not be responsible, for defining transport ways to do deal with things such as transport, security, delivery and packaging. The envelope provide for a clear separation between these things and the data itself.
Related Patterns:
This is similar to the Catch-All Element(http://www.xmlpatterns.com/CatchAllElementMain.shtml), except that the the document type of the Envelope pattern exists solely as an holder for other data and, the Catch-All Element is for embedding new elements within exsisting data.
Known Uses:
SOAP (Simple Object Access Protocol)(http://www.w3c.org/TR/SOAP/) is an Envelope for doing remote transport of messages.
-
Envelope Pattern (2 messages)
- Posted by: Toivo Lainevool
- Posted on: June 17 2000 02:38 EDT
Threaded Messages (2)
- Envelope Pattern by Philipp Meier on August 23 2000 16:04 EDT
- Envelope Pattern by Jiao Jackie on September 13 2001 06:52 EDT
-
Envelope Pattern[ Go to top ]
- Posted by: Philipp Meier
- Posted on: August 23 2000 16:04 EDT
- in response to Toivo Lainevool
Toivo, I like you small but effective Pattern. However I found a little typo in your XML example: The second namespace declaration should be xmlns:mystuff="..." not xmlns:e="..."
<e:Envelope xmlsns:e="http://xmlpatterns.com/envelope.dtd">
<e:sender name="bob"/>
<e:receiver name="http://xmlpatterns.com/message-receiver.cgi"/>
<myStuff:message xmlsns:myStuff="http://xmlpatterns.com/my-stuff.dtd">
This is my message
</myStuff:message>
</e:Envelope> -
Envelope Pattern[ Go to top ]
- Posted by: Jiao Jackie
- Posted on: September 13 2001 06:52 EDT
- in response to Philipp Meier
reertewr