Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • IBM Web Experience Factory wiki
  • All Wikis
  • All Forums
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
Community Articles Product Documentation Learning Center IBM Redbooks This category Web Experience Factory 8 Documentation WebSphere Portlet Factory 7 Documentation WebSphere Portlet Factory 7.0.1 Documentation Custom Search Scope...
Search
Community Articles > Web Experience Factory > Best Practices for Web Experience Factory > The Javascript XML Transform Builder
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

Carl D
Contribution Summary:
  • Articles authored: 2
  • Articles edited: 2
  • Comments Posted: 1

Recent articles by this author

The Javascript XML Transform Builder

Quickly transform XML in Web Experience Factory using javascript instead of java code.

Leveraging the Model Container Builder

The model container builder is probably one of the least used yet most valuable builders provided by WPF. This article explores how to design an application to take advantage of it. As the name suggests, this builder has the ability to contain other models within it and switch out those models ...

Community articleThe Javascript XML Transform Builder

Added by Carl D | Edited by Carl D on June 23, 2012 | Version 20
  • Edit
  • More Actions Show Menu▼
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars
expanded Abstract
collapsed Abstract
Quickly transform XML in Web Experience Factory using javascript instead of java code.
Tags: XML, transform

The Javascript XML Transform builder will transform an XML document using server side javascript and E4X notation. This provides a more natural and intuitive way of manipulating XML, and an easy way to test the transformation in the designer without having to execute the model. The builder is an alternative to using java code and the IXml API to transform XML documents.


Here are some reasons why this is my preferred way of handling XML in WEF

  • Javascript is easier to work with than java for many web developers. If you've worked with HTML then odds are you're familiar with javascript, now you can use those skills instead of learning java.
  • The builder exposes the XML as javascript variables so the developer can focus on the business logic at hand instead of the details of the IXml java API.

Take for example the following simple XML:

<contacts>
    <person>
        <name>Carl</name>
        <car>Nissan</car>
    </person>
    <person>
        <name>Subash</name>
        <car>Honda</car>
    </person>
</contacts>

Javascript with E4X notation can then refer to elements like this:

contacts.person[0].name; // returns 'Carl'

XML can be created with a script:

function main(){
   var rowset = <rowset/>;

   for(var x=0; x < contacts.person.length(); x++){
       rowset.row[x] =  contacts.person[x].name + " drives a " + contacts.person[x].car;
   }

   return rowset;
 }
 
 main();

which produces this output:

<rowset>
    <row>Carl drives a Nissan</row>
    <row>Subash drives a Honda</row>
</rowset>

 

Check out my website for a video demonstration of this builder.


  • Edit
  • More Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (20)
collapsed Versions (20)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (20)Jun 23, 2012 4:17:00 PMCarl D  Will this be my last edit? probably not...
19Jun 19, 2012 9:58:38 PMCarl D  
18Jun 19, 2012 9:54:16 PMCarl D  
17Jun 19, 2012 9:52:24 PMCarl D  
16Jun 19, 2012 9:49:29 PMCarl D  Minor change
15Jun 19, 2012 9:47:08 PMCarl D  
14Jun 19, 2012 9:45:29 PMCarl D  
13Jun 19, 2012 9:36:19 PMCarl D  
12Jun 19, 2012 9:31:23 PMCarl D  
11Jun 19, 2012 9:29:04 PMCarl D  
10Jun 19, 2012 9:27:07 PMCarl D  
9Jun 19, 2012 5:33:40 PMCarl D  
8Jun 19, 2012 5:30:06 PMCarl D  
7Jun 19, 2012 5:21:06 PMCarl D  Minor change
6Jun 19, 2012 2:56:02 PMCarl D  Minor change
5Jun 19, 2012 2:52:22 PMCarl D  Minor change
4Jun 19, 2012 2:51:25 PMCarl D  Minor change
3Jun 19, 2012 2:49:30 PMCarl D  save draft
2Jun 19, 2012 2:23:06 PMCarl D  Still no preview on this site......?
1Jun 19, 2012 2:17:35 PMCarl D  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • BlogsIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkIBM Collaboration Solutions
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use