Guest
Welcome login


TIBCOmmunity > Blogs > General Interface Blog > 2009 > February > 05
Home   Members Communities

General Interface Blog

General Interface Blog

Previous Next
Authority
5

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.

 

Comments

Click to view Mukesh Kumar's profile
Dabbler
Posted by Mukesh Kumar

Hi Luke

 

Is there an existing example application which does this.?

 

I wanted to create a rule based of current cach, say IndexCache, as input for mapping and create filter output using some attrubure as filters.

I was not able to use Cache id as input. basically I could not go too far without that.

 

Any help is appreciated.

 

Mukesh

Click to view Darren Hwang's profile
Authority
Posted by Darren Hwang in response to: Mukesh Kumar

You could transform/filter into new document, and set the new document back as IndexCache. However this means you will loose your original unfiltered data. One way to avoid that is to clone the document before filtering.

 

But you shouldn't have to do the clone to begin with

 

You should point your mapping rule to an empty XML document, e.g."request_doc_xml" with content "<data />". Then after you have created your filtered document, set the cache content of "request_doc_xml" with your filetered document.

 

1. Mapping rule input document = "request_doc_xml", new id.

2. Keeping Source data xml document as "IndexCache", but not used in mapping rule.

3. Filter Index Cache with XSL and create newDocument

4. Cache.setDocument("request_doc_xml", newDocument)

5. Service.doCall()

 

Click to view LeoPaul Pradeep's profile
Dabbler
Posted by LeoPaul Pradeep in response to: Mukesh Kumar

Hi Mukesh,

 

I face a similar kind of problem. Please send me the code to (leopaul6@gmail.com) or explain me in a detailed manner. This would help me a lot.

 

Thanks in Advance

 

Leo

 

Click to view Subu's profile
Dabbler
Posted by Subu in response to: LeoPaul Pradeep

Hello there,

 

I am using RESTful service POST, that takes input as XML in below form.

Value for UserName, UserPassword, userRole are coming from textbox.

URL of RESFful service is

http://myServer:8080/MyApp_V1/resources/Services/addUser?timestamp=1274873894998

 

I am not sure how to create the mapping rule for the same and integrate the service with UI.

 

Please help me with a sample application which uses Outbound Doc XML and RESTful services in Inbound Doc.

 

 

Input XML format:

Test1 Test1 admin false ]]>

 

 

 

Click to view Subu's profile
Dabbler
Posted by Subu in response to: Subu

input xml


<LoginROOT>
<userName>Test1</userName>
<userPassword>Test1</userPassword>
<userRoleList>
 <userRole>admin</userRole> 
 <userActiveStatus>false</userActiveStatus>
</userRoleList>
</LoginROOT>

 



General Interface Blog

General Interface Blog