XML Document Examples - Executable XML

In this example, we are going to create an XML document that inserts territories into the territory code table.

  1. Select the Group Information object.  Expand it, and select the group to which you wish to add the new XML document entity.

  2. Right click on the group and select Create->Entity.

  3. Click on the XML Document bullet.

  4. Click on the Next button at the bottom right of the screen.

  5. In the Entity Name property, type TERRITORY_XML as the entity name.

  6. Leave the Datasource property set to (use default), since there is only one datasource for the Xephr install.

  7. In the Based On property, select XML_TEMPLATE, which is the template that we created earlier.

  8. Leave the Default Mode property set to Run Report.   

  9. Leave the Body Style, Editable Field Style, Non- Editable Field Style, Lov Style, and Link Style properties set to (from parent).

  10. Click on the Next button at the bottom right of the screen.

  11. In the Block Name property, enter INSERT_TERRITORY as the name of the block.

  12. In the Block Type property, select Executable Block.

  13. Set the Query Type property to Simple Query.

  14. Leave the Datasource property set to (use parent).

  15. In the Table property, select the name of the table or view into which you are inserting the data.  Since our datasource is set to use the Oracle 9i database for NDS Applications, we will select the view TERRITORY_CODE_UVW.

  16. Leave the Create Heading checkbox set to off since we do not want a extra label field created to contain a heading.

  17. Click on the Next button at the bottom right of the screen.

  18. The Adding Fields screen is displayed.

  19. Click on the Field header to set that flag to on for all columns displayed.

  20. A key must be selected to continue.  Set the Key checkbox to on for the TERRITORY and ORG_UNIT_ID fields, as they are the keys for this table.

  21. No entries need to be made in the Filters property or the Ordering and Grouping property.

  22. Click on the Next button to continue.

  23. The Ordering Fields screen is displayed next.  The columns are initially ordered as they were listed on the previous screen.  To move a field up or down, highlight the desired field by selecting it, and click on the Move Up or Move Down buttons on the right of the screen.  Move the fields until they are in the following order:
    TERRITORY
    DESCRIPTION
    LOCAL_FLAG
    ORG_UNIT_ID

  24. This is the order in which the field values need to be passed for the record to be inserted.

  25. Click on the Next button when you have finished moving the fields.

  1. The Option to Add More screen is displayed.  We need to add the block for the XML document returned from the executable block.

  2. Set the Add Block or Labels checkbox to on.  The entity in its current form will be displayed.  

  3. Since we are adding the next block to the main screen entity, select the TERRITORY_XML entity.

  4. Click on the Add Block button at the bottom right of the screen.

  5. In the Block Name property, enter TERRITORY as the name of the block.

  6. Set the Query Type property to Simple Query.

  7. In the Block Type property, select Standard Block.

  8. Leave the Datasource property set to (use parent).

  9. In the Table property, select the name of the table or view from which you are obtaining the data.  Since our datasource is set to use the Oracle 9i database for NDS Applications, we will select the view TERRITORY_CODE_UVW.

  10. Leave the Create Heading checkbox set to off.

  11. Click on the Next button at the bottom right of the screen.

  12. The Adding Fields screen is displayed.  Click on the Field header to set that flag to on for all columns displayed.

  13. A key must be selected to continue.  Set the Key checkbox to on for the TERRITORY and ORG_UNIT_ID fields, as they are the keys for this table.

  14. No entries need to be made in the Filters property or the Ordering and Grouping property.

  15. Click on the Next button to continue.

  16. The Ordering Fields screen is displayed next.  The columns are initially ordered as they were listed on the previous screen.  To move a field up or down, highlight the desired field by selecting it, and click on the Move Up or Move Down buttons on the right of the screen.  Move the fields until they are in the following order:
    TERRITORY
    DESCRIPTION
    LOCAL_FLAG
    ORG_UNIT_ID

  17. Click on the Next button when you have finished moving the fields.

  1. The Option to Add More screen is displayed.  We have no more blocks to add, so click on the Finish button.

  1. The new entity is added to the initially selected group.  

  2. Click on the Save button in the main toolbar to save the new XML document entity.

  3. Now we need to construct the URL for the insert.  The format is as follows.  The bolded characters need to be replaced with the actual values.
    http://xephr_virtual_host_location/
    exec/
    xml_doc_name

    ?XEPHR_USER=user_name
    &XEPHR_PWD=hashed_user_password
    &XEPHR_NOJVM=Y
    &xml=<xml_doc_name>
    <xml executable's parent block name (if it has one)>
    <xml_executable_block_name>
    <FIELD1>value</FIELD1>
    <FIELD2>value</FIELD2>
    <xml executable child block name (if it has one)>
    <FIELD3>value</FIELD3>
    <FIELD4
    >value</FIELD4>
    </xml executable child block name (if it has one)>
    </xml_executable_block_name>
    </xml executable's parent block name (if it has one)>
    </xml_doc_name>

  4. In our example:
    http://test10.ndsasp.com/xephr/
    exec/
    TERRITORY_XML

    ?XEPHR_USER=train
    &XEPHR_PWD=94efdd6f628eda9c1ae893467c9652808443ef3e
    &XEPHR_NOJVM=Y
    &xml=<TERRITORY_XML>
    <INSERT_TERRITORY>
    <TERRITORY>T</TERRITORY>
    <DESCRIPTION>Territory</DESCRIPTION>
    <LOCAL_FLAG>N</LOCAL_FLAG>
    <ORG_UNIT_ID>100</ORG_UNIT_ID>
    </NSERT_TERRITORY>
    </TERRITORY_XML>

  5. Now we cut and paste this into a browser.  http://test10.ndsasp.com/xephr/exec/TERRITORY_XML?XEPHR_USER=train&XEPHR_PWD=94efdd6f628eda9c1ae893467c9652808443ef3e&XEPHR_NOJVM=Y&xml=<TERRITORY_XML><INSERT_TERRITORY><TERRITORY>T</TERRITORY><DESCRIPTION>Territory</DESCRIPTION><LOCAL_FLAG>N</LOCAL_FLAG><ORG_UNIT_ID>100</ORG_UNIT_ID></INSERT_TERRITORY></TERRITORY_XML>

  6. It inserts the record and displays the XML Document:

  7. If we run the TERRITORIES editable list that we created earlier, we can see the new record.

Xephr is a registered trademark of NDS Systems, LC.

Copyright © 2007 NDS Systems LC.