Guest
Welcome login
Share/Save
Share/Save
TIBCOmmunity > Blogs > General Interface Blog > Tags
Home   Members Communities

General Interface Blog

1 Posts tagged with the bulder tag
3

Author: Luke Birdeau

 

The XML Mapping utility does allow you to specify which records in your CDF document actually get mapped. There is a API call exposed by the jsx3.net.Service class called setCDFRecords that can be called from a mapping rule. For example, assume you have a CDF document in the XML Cache called myXML:

 


<data jsxid="jsxroot">
<record jsxid="a" checked="1" jsxtext="a"/>
<record jsxid="b" checked="0" jsxtext="b"/>
<record jsxid="c" checked="1" jsxtext="c"/>
<record jsxid="d" checked="1" jsxtext="d"/>
</data>

 

Next, Create a CDF Document mapping rule using the XML Mapping Utility for the outbound message you are creating. Set its path/value field to: myXML. Add an additional mapping rule (a Script type this time) and set the following as its path/value:

 

setCDFRecords("record[@checked='1']");

 

Here is what happened:

 

Any time a CDF Document mapping is encountered, all record nodes that are immediate children of the root node (data) are placed in a collection (jsx3.util.Collection). Then when a CDF Record mapping is encountered, the first record in the collection is assigned as the CDF Context and the ensuing rules are run. When a CDF Attribute mapping is encountered, the record referenced by the CDF Context is used. The mapper then repeats this as long as there are more records in the collection. By calling setCDFRecords, you effectively tell the system to not use its default query:

 

currentRecordContext.selectNodes("record");

rather, use a custom query. In your case:

 

currentRecordContext.selectNodes("record[@checked='1']");

 

 

NOTE setCDFRecords() goes with your CDF Document mapping as an additional script mapping rule.

 

 

Example We want to map the jsxtext attribute from record with jsxselected checked to WSDL Schema structure

 


<element name = "PersonSearch">
<complexType>
<sequence>
<element name = "QueryTarget" type = "xsd:string" maxOccurs = "unbounded"/>
</sequence>
</complexType>
</element>

 

In the Mapping utility, select the rule tree node PersonSearch.

  1. 1. Add a CDF Document mapping and enter the name of the CDF Document you wish to map to (its cache id).

  2. 2. Next add a Script mapping to the PersonSearch node and set its value to:

setCDFRecords("record[@jsxselected='1']");

 

Next, select the rule named, QueryTarget.

  1. 1. Add a CDF Record Mapping (records don't need a value).

  2. 2. Next, add a CDF Attribute mapping and enter jsxtext as the named CDF attribute on that record that you want to map to.

 

So to recap, you should have two mappings on the PersonSearch rule and two mappings on the QueryTarget rule.

 

3 Comments Permalink