Online documentation - Websydian v6.0 |
Users Guide | Patterns Reference | WebsydianExpress | Search |
» Related Information |
---|
TransacXML Tutorial |
In this example the implementation and processing of repeating element fields are described by example.
The following example is also available in the model of the TransacXML tutorial available for download at our download site.
The example is based on a subset of a XML document holding comment lines for a product.
XML Document |
---|
<Comments> <ProductID>TestProduct</ProductID> <Comment>Comment number one</Comment> <Comment>Comment number two</Comment> <Comment>Comment number three</Comment> <Comment>Comment number four</Comment> <Comment>Comment number five</Comment> </Comment> |
First model the XML document within the Plex model
Source Object | Verb | Target Object | Comments |
---|---|---|---|
Comments | is a ENT | XMLElement | |
Comments.Fields | field FLD | Comment | |
ProductID | |||
Comments.Fields.Comment | is a FLD | RepeatingElementField | |
value VAL | Comment1 | Literal: Comment number one | |
Comment2 | Literal: Comment number two | ||
Comment3 | Literal: Comment number three | ||
Comment4 | Literal Comment number four | ||
Comment5 | Literal: Comment number five | ||
Comments.Fields.ProductID | is a FLD | ElementField | |
value VAL | ProductID | Literal: TestProduct | |
Comments | has FLD | Fields.ProductID | |
Fields.Comment |
Now create the functions for doing import and export of the XML document
Source Object | Verb | Target Object | Comments |
---|---|---|---|
ExportComments | is a FNC | ExportXMLDocument | |
message MSG | FileName | ||
ImportComments | is a FNC | ImportXMLDocument | |
message MSG | FileName | ||
ReturnedByGetNext | |||
ReturnedBySingleFetch | |||
local FLD | ParentElement | ||
PreviousElement | |||
ImportComments.ReturnedByGetNext | parameter FLD | Comments.Fields.ProductID | |
Comments.Fields.Comment | |||
ImportComments.ReturnedBySingleFetch | parameter FLD | Comments.Fields.Comment |
Add the following information to the message objects
Message Object | Content |
---|---|
ExportComments.FileName | RepeatingElementFieldExample.xml |
ImportComments.FileName | RepeatingElementFieldExample.xml |
ImportComments.ReturnedByGetNext | Returned by GetNext Comment: &(1:) |
ImportComments.PreviousElement | This is returned by the SingleFetch: ProductID....: &(1:) First Comment: &(2:) |
Open the action diagram for ExportComments and add the following code
Post Point Process XML document
Call RepeatingElementFieldExample.Comments.InsertRow
// Map [Local/OutputDocument<ObjectStoreReference>]
// Map [Local/OutputDocument<ObjectDocument>]
// Map [Local/OutputDocument<ObjectDocument>]
// Map <RepeatingElementFieldExample.Comments.Fields.ProductID.ProductID>
// Map <RepeatingElementFieldExample.Comments.Fields.Comment.Comment1>
Go Sub Check error
Call RepeatingElementFieldExample.Comments.Fields.Comment.InsertNext
// Map [Local/OutputDocument<ObjectStoreReference>]
// Map RepeatingElementFieldExample.Comments.InsertRow/Output<ObjectElement>
// Map [Local/OutputDocument<ObjectDocument>]
// Map <RepeatingElementFieldExample.Comments.Fields.Comment.Comment2>
Go Sub Check error
Call RepeatingElementFieldExample.Comments.Fields.Comment.InsertNext
// Map [Local/OutputDocument<ObjectStoreReference>]
// Map RepeatingElementFieldExample.Comments.InsertRow/Output<ObjectElement>
// Map [Local/OutputDocument<ObjectDocument>]
// Map <RepeatingElementFieldExample.Comments.Fields.Comment.Comment3>
Go Sub Check error
Call RepeatingElementFieldExample.Comments.Fields.Comment.InsertNext
// Map [Local/OutputDocument<ObjectStoreReference>]
// Map RepeatingElementFieldExample.Comments.InsertRow/Output<ObjectElement>
// Map [Local/OutputDocument<ObjectDocument>]
// Map <RepeatingElementFieldExample.Comments.Fields.Comment.Comment4>
Go Sub Check error
Call RepeatingElementFieldExample.Comments.Fields.Comment.InsertNext
// Map [Local/OutputDocument<ObjectStoreReference>]
// Map RepeatingElementFieldExample.Comments.InsertRow/Output<ObjectElement>
// Map [Local/OutputDocument<ObjectDocument>]
// Map <RepeatingElementFieldExample.Comments.Fields.Comment.Comment5>
Go Sub Check error
Pre Point Save output document
Format Message Message:
RepeatingElementFieldExample.ExportComments.Filename, Local/OutputDocument<FileName>
Open the action diagram of ImportComments and add the following code
Pre Point Load input document
Format Message Message: RepeatingElementFieldExample.ImportComments.Filename, Local/InputDocument<FileName>
Post Point Process XML document
Call RepeatingElementFieldExample.Comments.GetFirstOccurrence
// Map [Local/InputDocument<ObjectStoreReference>]
// Map [Local/InputDocument<ObjectDocument>]
// Map <ParentElement.NULL>
Go Sub Check error
Set Local<ParentElement> = RepeatingElementFieldExample.Comments.GetFirstOccurrence/Output<ObjectNode>
Call RepeatingElementFieldExample.Comments.SingleFetch
// Map [Local/InputDocument<ObjectStoreReference>]
// Map Local<ParentElement>
Go Sub Check error
Dialog Message Message: RepeatingElementFieldExample.ImportComments.ReturnedBySingleFetch
// Map
RepeatingElementFieldExample.Comments.SingleFetch/Data<RepeatingElementFieldExample.Comments.Fields.ProductID>
// Map RepeatingElementFieldExample.Comments.SingleFetch/Data<RepeatingElementFieldExample.Comments.Fields.Comment>
Call RepeatingElementFieldExample.Comments.Fields.Comment.GetFirst
// Map Local/InputDocument<ObjectStoreReference>
// Map Local<ParentElement>
Go Sub Check error
Set Local<PreviousElement> =
RepeatingElementFieldExample.Comments.Fields.Comment.GetFirst/Output<ObjectElement>
Call RepeatingElementFieldExample.Comments.Fields.Comment.GetNext
// Map Local/InputDocument<ObjectStoreReference>
// Map Local<ParentElement>
// Map Local<PreviousElement>
Set Local<PreviousElement> =
RepeatingElementFieldExample.Comments.Fields.Comment.GetNext/Output<ObjectElement>
While Environment<*Returned status> == <*Returned status.*Successful>
Set Local<ParentElement> =
RepeatingElementFieldExample.Comments.Fields.Comment.GetNext/Output<ObjectElement>
Dialog Message Message:
RepeatingElementFieldExample.ImportComments.ReturnedByGetNext
// Map
RepeatingElementFieldExample.Comments.Fields.Comment.GetNext/Data<RepeatingElementFieldExample.Comments.Fields.Comment>
Call RepeatingElementFieldExample.Comments.Fields.Comment.GetNext
// Map Local/InputDocument<ObjectStoreReference>
// Map Local<ParentElement>
// Map Local<PreviousElement>
Set Local<PreviousElement> =
RepeatingElementFieldExample.Comments.Fields.Comment.GetNext/Output<ObjectElement>
Generate, build and create an exe file for the following:
ExportComments
ImportComments
Run the ExportComments function and check the XML document created
Run the ImportComments function and check the dialog messages displayed