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 > WebSphere Portlet Factory > IBM - Using Portlet Factory's IXml and XmlUtil Interfaces
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

Rob Flynn
Contribution Summary:
  • Articles authored: 237
  • Articles edited: 298
  • Comments Posted: 2

Recent articles by this author

JAX-WS Handler Sample using IBM Web Experience Factory

Overview The Web Experience Factory (WEF) 8.0 release contains an enhancement to the web service call builders that gives you an option to define a global JAXWS handler class. This handler makes it possible for models to intercept and process the inbound and outbound SOAP envelopes associated ...

WebSphere Dashboard Framework 7.0.1.1 Fix pack now available

The WebSphere Dashboard Framework 7.0.1.1 Fix pack has been released.

IBM Web Experience Factory Version 7.0.1.4 Fix Pack is now available

This fix pack includes new fixes and updates for Web Experience Factory Version 7.0.1. and is now available on Fix Central and can be downloaded from here: ...

IBM Web Experience Factory WCAG 2.0 Compliance

IBM Web Experience Factory, developed and tested compliant to WCAG 2.0, can produce output (web pages, sites and content) that can be WCAG 2.0 Level A and Level AA compliant. IBM Web Experience Factory neither enforces nor prevents this compliance. Application developers must know and understand ...

Yeah!!! New IBM Web Experience Factory V8.0 is announced!!!

A quick snapshot of what's new in IBM Web Experience Factory... IBM Web Experience Factory is all about making it quick and easy to develop applications (portlets) that are included as part of an exceptional web experience. We've seen our customers doing some awesome stuff, whether it be ...

Community articleIBM - Using Portlet Factory's IXml and XmlUtil Interfaces

Added by Rob Flynn | Edited by IBM contributor Rob Flynn on June 2, 2008 | Version 3
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: Code samples
Using Portlet Factory's IXml and XmlUtil Interfaces
ibm logo imageThis information is provided and maintained by IBM. Comments are welcome, but the information is not editable.

IXml and XMLUtil
Portlet Factory's IXml and XmlUtil interfaces are lightweight and powerful API's for working with XML data.  An integral component of Portlet Factory internals, they are useful for creating, parsing, and setting various XML data.
This article and sample application demonstrates how you can use these API's to manipulate XML data in your application. The application will parse an ATOM feed and create a new XML structure. The new XML is used to populate a Select input on a page, as shown in the following image.

The sample application contains one model, IXmlSample.model.  

IXmlSample.model
The atomFeed variable holds the ATOM feed XML to be parsed.   The ATOM feed is based on a Lotus Quickr REST service that returns a feed of document libraries:



   
                     Teamspace Documents
                     
            HR Docs
            application/*,image/*,*/*
   

   
            Sam's Library
            application/*,image/*,*/*
   

                     ...
   


The Select builder adds a Select input on the page.  A Select builder can easily get its data from IXml variable in the following general form:







Following this general form, the model contains a Variable builder, libraries, that is used for the Select builder's "Select Data" input.    The variable's Type input is set to XML.  Populated at runtime, libraries will contain data similar to this:


   
                     
                     http://server/dm/atom/library/123/feed
   

    ...

When the Action List main is called, the libraries variable is set to the return value of getLibraries method. And here is where the fun begins!
The getLibraries method uses IXml to parse the ATOM feed and create a new Xml variable suitable for the Select list.
Several XmlUtil and IXml methods are called:

  • XmlUtil.create() is used to create the elements in our new XML structure
  • IXml.findElement() is used to navigate, or skip down, to a particular place in the ATOM feed
  • IXml.getChildren() is used to get a List of child IXml elements.
  • IXml.getAttribute() is used to read in the value of an XML attribute
  • IXml.findElement() is used to find a subelement of an XML structure
  • IXml.getText() is used to retrieve the text value of an element
  • IXml.addChildWithText() is used to create Xml elements with text values.

Create new XML structure
IXml libs = XmlUtil.create("Libraries");

Get var that holds the ATOM feed
IXml atomFeed =  webAppAccess.getVariables().getXml("atomFeed");

Skip down to the elements
IXml collectionsXml = atomFeed.findElement("service/workspace");

For each lib, parse the title & feed url. Create a structure
that contains the title and value. Add the structure to
the structure
Iterator collections = collectionsXml.getChildren().iterator();
while(collections.hasNext())
{
    IXml collection = (IXml) collections.next();
    String colFeedUrl = collection.getAttribute("href");
    String colTitle = collection.findElement("atom:title").getText();

    IXml lib = XmlUtil.create("Library");
    lib.addChildWithText("label", colTitle);
    lib.addChildWithText("value", colFeedUrl);

    libs.addChildElement(lib);
}
return libs;


Installing the Sample
  • Create a new WebSphere Portlet Factory project.
  • Import the following zip as a WebSphere Portlet Factory archive IXmlSample.zip
  • The zip contains one model:  models\samples\IXmlSample.model.

Reference
 
For more information, see the IXml and XmlUtil javadoc that ships with Portlet Factory. This is accessible by select Start > All Programs > IBM WebSphere > Portlet Factory > Documentation > Java API Documentation.

expanded Attachments (0)
collapsed Attachments (0)
expanded Versions (20)
collapsed Versions (20)
Version Comparison     
VersionDateChanged by              Summary of changes
20Aug 3, 2010 10:59:21 AMKeshi Dai  
19Jan 15, 2010 7:54:35 PMRob Flynn  IBM contributor
18Dec 31, 2009 8:42:15 AMRob Flynn  IBM contributor
17Dec 31, 2009 8:40:40 AMRob Flynn  IBM contributor
16Dec 8, 2008 2:01:16 PMRob Flynn  IBM contributor
15Oct 27, 2008 4:33:53 PMDeAnna Steiner  IBM contributor
14Jul 8, 2008 4:21:02 PMS Alexander  IBM contributor
13Jun 23, 2008 10:34:09 AMRob Flynn  IBM contributor
12Jun 19, 2008 12:24:30 PMRob Flynn  IBM contributor
11Jun 19, 2008 12:24:19 PMRob Flynn  IBM contributor
10Jun 17, 2008 1:30:16 PMR Flynn  IBM contributor
9Jun 17, 2008 1:27:01 PMR Flynn  IBM contributor
8Jun 17, 2008 1:21:20 PMR Flynn  IBM contributor
7Jun 17, 2008 1:19:57 PMR Flynn  IBM contributor
6Jun 13, 2008 3:57:26 PMRob Flynn  IBM contributor
5Jun 13, 2008 12:41:25 PMRob Flynn  IBM contributor
4Jun 13, 2008 9:54:30 AMRob Flynn  IBM contributor
This version (3)Jun 2, 2008 2:02:29 PMRob Flynn  IBM contributor
2May 27, 2008 9:11:49 AMRob Flynn  IBM contributor
1May 22, 2008 9:44:14 AMRob Flynn  IBM contributor
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