You are on page 1of 6

SharePoint to BI Integration

1) Enable the RSS feed in the list setting or site collection


2) Create a folder in the <cognos_Installation_Path>\war directory
called RemoteXMLDS. This is the directory where you will store all of the
files that you will be asked to create as part of this tutorial.
3) Create a file called RemoteXMLDS.jsp and copy the contents of the code
snippet below into that file. Save this file in the folder you created in step 1.
<%@ page import="javax.xml.transform.*"%>

<%@ page import="javax.xml.transform.stream.*"%>


<%
String aSeparator = System.getProperty("file.separator");
java.io.File tempFile;
out.clearBuffer();
//
// If using the Tomcat server supplied with IBM Cognos BI, the
servletContext
// will be "<cognos_install_root>\webapps\RemoteXMLDS"
//
String sContext = getServletContext().getRealPath("") + aSeparator;
//
// Build full path to XSLT file used to transform the source XML into
the format
// required for an IBM Cognos BI XML data source
//
String xslInput = "RemoteXMLDS.xsl";
String xslFilePath = sContext + aSeparator + xslInput;
//
// ** Modify the following to point to the list id. **
// ex. String sXMLSrc =
"http://server.xyz.com/depart/ops/ad/_layouts/listfeed.aspx?
List={D1199996-0927-4AC4-B536-C003B04F81DF}";
//
String sXMLSrc = http://picspdv01:701/_layouts/15/listfeed.aspx?
List={AA7F477B-3BC8-40E9-9DEB-6275EAC1F505}";
if ((tempFile = new java.io.File(xslFilePath)).exists())
{
TransformerFactory trFactory = TransformerFactory.newInstance();
Transformer aTransformer = trFactory.newTransformer(new

StreamSource(xslFilePath));
aTransformer.transform(new StreamSource(sXMLSrc), new
StreamResult(out));
}
else
{
out.println("Did not find XSLT file [" + xslFilePath + "]");
}
tempFile = null;
out.flush();
out.close();
%>

4) Create two empty folders within the RemoteXMLDS folder. Call one classes
and the other lib.
5) The next step is to create the XSLT processor (Xalan-J) that will transform the
XML returned from the SharePoint RSS feed into a format understood by
Cognos.
To do this we need several jar files:
xalan.jar
xercesImpl.jar
xml-apis.jar
Check to see if these already reside in
the <cognos_Installation_Path>\bin folder. If they do not, you can find
them in the following repository:
http://mvnrepository.com/artifact/xalan/serializer/2.7.1

6) Copy the jar files into the <cognos_Installation_Path>\bin directory and


the <cognos_Installation_Path>\war\RemoteXMLDS\lib directory
Using objects from the javax.xml.transform library, which is found in the
xalan.jar, you will need to create a file with the necessary schema that
represents the SharePoint data source format. To do this you will create a
template of the schema you are trying to transform.
This template will represent the format of the data in the RSS feed. In the
example below our feed contains 3 sections per data row: a title, a link and a
description. The template below will be used to transform the RSS feed into
these three sections.
7) Using the file below as a guide, create a file called RemoteXMLDS.xsl that
represents the data in your SharePoint List. You can copy the file below and
then modify the elements to represent the format of your List.
<?xml version="1.0" encoding="UTF-8"?>

<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://developer.cognos.com/schemas/xmldata/1/"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:message>Start: Fields to Consider in the
transformation</xsl:message>
<xsl:element name="dataset">
<xsl:element name="metadata">
<xsl:element name="item">
<xsl:attribute name="name">title</xsl:attribute>
<xsl:attribute name="type">xs:string</xsl:attribute>
<xsl:attribute name="length">256</xsl:attribute>
</xsl:element>
<xsl:element name="item">
<xsl:attribute name="name">link</xsl:attribute>
<xsl:attribute name="type">xs:string</xsl:attribute>
<xsl:attribute name="length">256</xsl:attribute>
</xsl:element>
<xsl:element name="item">
<xsl:attribute name="name">description</xsl:attribute>
<xsl:attribute name="type">xs:string</xsl:attribute>
<xsl:attribute name="length">256</xsl:attribute>
</xsl:element>
</xsl:element>
<xsl:apply-templates/>
</xsl:element>
<xsl:message>End: Fields to Consider in the transformation</xsl:message>
</xsl:template>
<xsl:template match="channel">
<xsl:element name="data">
<xsl:apply-templates select="item"/>
</xsl:element>
</xsl:template>
<xsl:template match="item">
<xsl:if test='starts-with(./link, "http://<SharePoint_Site>/<loc>")'>
<xsl:element name="row">
<xsl:element name="value"><xsl:value-of
select="./title"/></xsl:element>
<xsl:element name="value"><xsl:value-of select="./link"/></xsl:element>
<xsl:element name="value"><xsl:value-of
select="./description"/></xsl:element>
</xsl:element>
</xsl:if>

</xsl:template>
</xsl:transform>

8) Create a new file called web.xml. This file will be used to tell the Apache
Tomcat server how to locate the jsp file. Copy the contents of the code
snippet below into this new file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app id="WebApp">
<display-name>RemoteXMLDS</display-name>
<welcome-file-list>
<welcome-file>RemoteXMLDS.jsp</welcome-file>
</welcome-file-list>
</web-app>

9) Your RemoteXMLDS folder should have the following contents:

10)

Create a new XML file called build.xml and copy the contents of the code
snippet below into this file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="RemoteXMLDS" default="war" basedir="../..">
<description>Remote XML data source for IBM Cognos BI</description>
<property name="context_root" value="RemoteXMLDS"/>
<property name="war_name" value="${context_root}.war"/>
<target name="clean">
<delete quiet="true" dir="temp/war/${context_root}"/>
<delete quiet="true" file="temp/war/${context_root}.war"/>
</target>
<target name="move_files" depends="clean">
<copy todir="temp/war/${context_root}/lib">
<fileset dir="webapps/p2pd/WEB-INF/lib">
<include name="xalan.jar"/>
<include name="serializer.jar"/>
<include name="xercesImpl.jar"/>
<include name="xml-apis.jar"/>

</fileset>
<fileset dir="war/${context_root}/lib"/>
</copy>
<copy file="war/${context_root}/lib/xalan.jar" todir="temp/war/$
{context_root}/lib"/>
<copy file="war/${context_root}/lib/serializer.jar" todir="temp/war/$
{context_root}/lib"/>
<copy file="war/${context_root}/lib/xercesImpl.jar" todir="temp/war/$
{context_root}/lib"/>
<copy file="war/${context_root}/lib/xml-apis.jar" todir="temp/war/$
{context_root}/lib"/>
<copy file="war/${context_root}/RemoteXMLDS.xsl" todir="temp/war/$
{context_root}"/>
<copy file="war/${context_root}/RemoteXMLDS.jsp" todir="temp/war/$
{context_root}"/>
</target>
<target name="gen_war" depends="move_files">
<war warfile="temp/war/${context_root}.war" webxml="war/$
{context_root}/web.xml">
<classes dir="war/${context_root}/classes"/>
<lib dir="temp/war/${context_root}/lib"/>
<fileset dir="temp/war/${context_root}">
<include name="RemoteXMLDS.bat"/>
<include name="RemoteXMLDS.xsl"/>
<include name="RemoteXMLDS.jsp"/>
</fileset>
</war>
</target>
<target name="war" depends="gen_war">
<move file="temp/war/${context_root}.war" tofile="war/${context_root}/$
{war_name}" overwrite="true"/>
<delete quiet="true" dir="temp/war/${context_root}"/>
</target>
</project>

This build.xml job will copy the JARs and the other files you have created
into the war file. You will then use an ant service to create the war file from
the build.xml.
11)
Create a new BAT file called build.bat and copy the contents of the
code snippet below into the file:
@echo of
:: Change the Java path to reflect your Java location
..\..\bin64\jre\7.0\bin\java -classpath "../../bin/ant-

launcher.jar;../../bin/ant.jar;../../bin/xmlapis.jar;../../bin/xercesImpl.jar" org.apache.tools.ant.Main %*
12)
After the build.bat command runs you should see an additional file in
your folder called RemoteXMLDS.war
13)
Copy
the RemoteXMLDS.war into <cognos_Installation_Path>\webapps folde
r. The Cognos BI Apache Tomcat Server will eventually see this new war file
and will deploy it, creating a folder in the webapps directory
called RemoteXMLDS. At this point you are ready to test the .jsp file.
14)
Open a browser and type in the following URL:
<Server>:9300/RemoteXMLD/RemoteXML.jsp

15)
The result of the SharePoint Feed is 1 row with 3 columns (values). The
first two columns contain single values, but the third column contains a set of
10 name/value pairs. We will need to add logic within FM to parse this data
and store each of the 10 values into unique columns in an FM Query Subject.

16)
In the data connections connection string we will have to send
the connection string.
<Server>:9300/RemoteXMLD/RemoteXML.jsp

Apply the connection string :Another approach is:


a) http://picspdv01:701/_api/Web/Lists/GetByTitle('Test_BI_Cognos')/Items?
$select=Title,Description,Link
b) Data Source=PICSPDV01;Initial Catalog=SharePoint_Config;Integrated
Security=True;Enlist=False;Pooling=True;Min Pool Size=0;Max Pool Size=100;Connect
Timeout=15
c)

Microsoft ACE OLEDB 12.0

Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=1;RetrieveIds=Yes;DATABASE=http://myshare
pointsite.com/documents/;LIST={ AA7F477B-3BC8-40E9-9DEB-6275EAC1F505};

You might also like