XML Parser - How to Determine Entity Field Types
Step by step guide
This is a simple step by step guide in a purpose to demonstrate how to determine entity field types.
Step 1 - create an SDK project
File → new → Openlegacy SDK Project
Choose XML backend solution in the SDK project wizard.
Enter your Host, user, and password if needed (this example doesn't require a real backend ).
Click Finish.
step 2 - Edit ol-xml.yml
Go to →
ol-xml.yml
.
2. Add the chains of elements that must be represented as a collection (e.g., list):
collections:
# Set of xml paths, that relates to collections
- EngineDocList.EngineDoc.OrderFormDoc.OrderItemList
- EngineDocList.EngineDoc.ConfigDoc.CompList
- EngineDocList.EngineDoc.ConfigDoc.CompList.Comp.ConfigActionList
- EngineDocList.EngineDoc.ConfigDoc.CompList.Comp.ConfigActionList.ConfigAction.ValueList
3. Add the chains of elements that must be represented as structures:
structures:
# Set of xml paths, that relates to collections
- EngineDocList
- EngineDocList.EngineDoc.User
- EngineDocList.EngineDoc.Instructions
- EngineDocList.EngineDoc.Instructions.RoutingList
- EngineDocList.EngineDoc.Instructions.RoutingList.Routing
- EngineDocList.EngineDoc.MessageList
- EngineDocList.EngineDoc.OrderFormDoc
- EngineDocList.EngineDoc.OrderFormDoc.Consumer
- EngineDocList.EngineDoc.OrderFormDoc.Consumer.ShipTo
- EngineDocList.EngineDoc.OrderFormDoc.Consumer.ShipTo.Location
- EngineDocList.EngineDoc.OrderFormDoc.Consumer.ShipTo.Location.Address
- EngineDocList.EngineDoc.OrderFormDoc.Consumer.PaymentMech
- EngineDocList.EngineDoc.OrderFormDoc.Consumer.PaymentMech.CreditCard
- EngineDocList.EngineDoc.OrderFormDoc.Transaction.CurrentTotals
- EngineDocList.EngineDoc.OrderFormDoc.Transaction.CurrentTotals.Totals
- EngineDocList.EngineDoc.ConfigDoc
- EngineDocList.EngineDoc.ConfigDoc.CompList.Comp
- EngineDocList.EngineDoc.ConfigDoc.CompList.Comp.ConfigActionList.ConfigAction
- EngineDocList.EngineDoc.ConfigDoc.CompList.Comp.ConfigActionList.ConfigAction.ValueList.Value
4. Add the chains of elements that must be represented as types:
types:
# Set of xml paths, that relates to primitives
StartDate: java.lang.String
Money: java.math.BigDecimal
Numeric: java.math.BigDecimal
S32: java.lang.Long
ExpirationDate: java.lang.String
String: java.lang.String
DateTime: java.util.Date
5. Edit the typeAttribute
Step 3 - Generate entity from XML
Go to → src/main/resources/sample
Right-click on
call1.request.xml
→Openlegact → Generate model.Your entity should be generated like this:
Without edit the ol-xml.yml
the entity would look like this: