The XUpdateResolver component (Flash Professional only)

The XUpdateResolver component converts changes made to the data in your application into XUpdate statements that can be processed by an external data source. XUpdate is a standard for describing changes that are made to an XML document and is supported by a variety of XML databases, such as Xindice and XHive.

Note: You can also use the XUpdateResolver component to send data updates to any external data source that can parse the XUpdate language—for example, an ASP page, a Java servlet, or a ColdFusion component. For more information, see the XUpdate specification.

The XUpdateResolver component communicates with the DataSet component using the DataSetDeltaToXUpdateDelta encoder. This encoder is responsible for creating XPath statements that uniquely identify nodes within an XML file based on the information contained within the DataSet component's DeltaPacket. This information is used by the XUpdateResolver component to generate XUpdate statements. For more information on the DataSetDeltaToXUpdateDelta encoder, see Schema encoders (Flash Professional only).

The XUpdateResolver component works only with Flash Player 7.

XUpdateResolver component parameter

The XUpdateResolver component has one parameter, the includeDeltaPacketInfo parameter (Boolean type). When this parameter is set to true, the update packet includes additional information from the data set that can be used by an external data source to generate results that can be sent back to your application. This information includes a unique transaction and operation ID that is used internally by the data set.

Note: The additional information that is included in the update packet invalidates the XUpdate. This is expected behavior. You would choose to add this information only if you were going to store it within a server object and use it to generate a result packet. In this scenario, your server object would pull the information out of the update packet for it s own needs and then pass on the (now valid) XUpdate to the database.

Example (with false setting):

<xupdate:modifications version="1.0" xmlns:xupdate="http://www.xmldb.org/xupdate">
    <xupdate:remove select="/datapacket/row[@id='100']"/>
</xupdate:modifications>

Example (with true setting):

<xupdate:modifications version="1.0" xmlns:xupdate="http://www.xmldb.org/xupdate" 
      transId="46386292065:Wed Jun 25 15:52:34 GMT-0700 2003">
    <xupdate:remove select="/datapacket/row[@id='100']" opId="0123456789"/>
</xupdate:modifications>

Common workflow for the XUpdateResolver component

The typical workflow for the XUpdateResolver component is as follows.

To use an XUpdateResolver component:

  1. Add two instances of the XMLConnector component and one instance each of the DataSet component and XUpdateResolver component to your application and give them instance names.
  2. Select the first XMLConnector component, and use the Parameters tab of the Component Inspector panel to enter the URL for the external XML data source that you want to access.
  3. With the XMLConnector component still selected, click the Schema tab of the Component Inspector panel and import a sample XML file to generate your schema.

    Note: You may need to create a virtual schema for your XML file if you want to access a subelement of the array that you are binding to the data set. For more information, see Virtual XML schemas.

  4. Use the Bindings tab of the Component Inspector panel to bind an array within the XMLConnector component to the dataProvider property of the DataSet component.
  5. Select the DataSet component and use the Schema tab of the Component Inspector panel to create the DataSet fields that will be bound to the fields of the object within the array.
  6. Use the Bindings tab of the Component Inspector panel to bind data elements (DataSet fields) to the visual components in your application.
  7. Select the Schema tab of the XUpdateResolver component. With the deltaPacket component property selected, use the Schema Attributes pane to set the encoder property to the DataSetDeltaToXUpdateDelta encoder.
  8. Select Encoder Options and enter the rowNodeKey value that uniquely identifies the row node within the XML file.

    Note: The rowNodeKey value combines an XPath statement with a field parameter to define how unique XPath statements should be generated for the update data contained within the DeltaPacket. See information on the DataSetDeltaToXUpdateDelta encoder in Schema encoders (Flash Professional only).

  9. Click the Bindings tab and create a binding between the XUpdateResolver component's deltaPacket property and the DataSet component's deltaPacket property.
  10. Create another binding from the xupdatePacket property to the second XMLConnector component to send the data back to the external data source.

    Note: The xupdatePacket property contains the formatted DeltaPacket (XUpdate statements) that will be sent to the server.

  11. Add a trigger to initiate the data binding operation: use the Trigger Data Source behavior attached to a button, or add ActionScript.

    Note: In addition to these steps, you an also create bindings to apply the result packet sent back from the server to the data set via the XUpdateResolver component.

    For more information, see XUpdateResolver component.

Updates sent to an external data source

Update packets sent to the server are in XUpdate format. The following is a sample XUpdate packet:

<?xml version="1.0"?> 
<xupdate:modifications version="1.0" xmlns:xupdate="http://www.xmldb.org/xupdate">
   <xupdate:insert-after select="/addresses/address[1]" > 
      <xupdate:element name="address">
         <xupdate:attribute name="id">2</xupdate:attribute>
         <fullname>Lars Martin</fullname> 
         <born day='2' month='12' year='1974'/> 
         <town>Leizig</town> 
         <country>Germany</country> 
      </xupdate:element> 
   </xupdate:insert-after> 
</xupdate:modifications> 

Receiving results from an external data source

Once the server has finished with the update packet, either successfully or unsuccessfully, it should send back a result packet containing errors or additional XML updates resulting from the update operation. If there are no messages, the results packet should still be sent, but it will have no operation result nodes.

The following is a sample result packet for an update packet that has no errors and contains no XML updates:

<results_packet nullValue="{_NULL_}" transID="46386292065:Wed Jun 25 15:52:34 GMT-0700 2003"/> 

A sample results packet (with XML updates) follows:

<results_packet nullValue="{_NULL_}" transID="46386292065:Wed Jun 25 15:52:34 GMT-0700 2003"> 
    <operation op="remove" id="11295627479" msg="The record could not be found"/> 
    <operation op="update" id="02938027477"> 
       <attribute name="id" curValue="105" msg="Invalid field value" /> 
    </operation>
 </results_packet> 

The results packet can contain an unlimited number of operation nodes. Operation nodes contain the results of operations from the update packet. Each operation node should have the following attributes/child nodes: