Beruflich Dokumente
Kultur Dokumente
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
<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>
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
Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=1;RetrieveIds=Yes;DATABASE=http://myshare
pointsite.com/documents/;LIST={ AA7F477B-3BC8-40E9-9DEB-6275EAC1F505};