Hi there,
I have done the following things for executing XDQL in Content Server 6.5 SP2, but I am not getting any output.
I have written the following Java code (taken for documentum guides):
public static void main(String[] args) throws Exception {
IDfSessionManager sessionManager = null;
IDfSession sess = null;
try {
MyClass m = new MyClass();
DctmSessionHandler dctmSessionHandler = new DctmSessionHandler();
List docbases = new ArrayList();
docbases.add("docbase_name");
IDfClientX clientx = new DfClientX();
sessionManager = dctmSessionHandler.getSessionManager("dmuser","dmpassword", docbases);
sess = sessionManager.getSession("docbase_name");
IDfDocument dfDocument = (IDfDocument) sess.getObject( new DfId(("0900007b80009f17")));
m.testTransformXml2HtmlUsingStylesheetObject(clientx, sess, dfDocument);
} catch (Exception ex) {
ex.printStackTrace();
}
}
void testTransformXml2HtmlUsingStylesheetObject(IDfClientX clientx, // for operation factory
IDfSession session, // required for transformation
IDfDocument docStylesheet) // XSL stylesheet in repository
throws DfException, IOException {
IDfXMLTransformOperation transform = clientx.getXMLTransformOperation();
transform.setSession(session);
transform.setTransformation(docStylesheet);
FileOutputStream out = new FileOutputStream("C:/NewsMLNewsletter.htm");
transform.setDestination(out);
IDfXMLTransformNode node = (IDfXMLTransformNode) transform
.add("C:/NewsMLNewsletter.xml");
if (node == null) { // See the DFC documentation on handling
// manipulation errors.
}
node.setOutputFormat("html");
// Execute the operation
try {
System.out.println("Before Execute !!!");
boolean execResult = transform.execute();
if(execResult){
System.out.println("Execution successful !!!");
}else{
System.out.println("Execution failed !!!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
This java code expects a XML file at local disk (at C:\) and an XSL in the content server. As an output it generates a htm file at local disk (at C:\). I have kept the following XSL in the Content Server:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java" xmlns:xalan-nodeset="http://xml.apache.org/xalan" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="DMS_SESSION_ID" select="'default value'"/>
<xsl:template match="newsletter">
<html>
<head>
<title></title>
</head>
<body>
<h1><xsl:value-of select="title"/></h1>
<xsl:call-template name="XDQL"/>
</body>
</html>
</xsl:template>
<xsl:template name="XDQL">
<xsl:variable name="dql">
select r_object_id from dm_document where object_name='insights'
</xsl:variable>
<xsl:variable name="clientx" select="java:com.documentum.com.DfClientX.new()"/>
<xsl:variable name="xdql" select="java:getXmlQuery($clientx)"/>
<xsl:variable name="init" select="java:init($xdql)"/>
<xsl:variable name="param" select="java:setDql($xdql, $dql)"/>
<xsl:variable name="includeContent" select="java:includeContent($xdql,true())"/>
<xsl:variable name="setContentEncoding" select="java:setContentEncoding($xdql,'dom')"/>
<xsl:variable name="setContentFormat" select="java:setContentFormat($xdql,'xml')"/>
<xsl:variable name="rootNode" select="java:setRootNode($xdql, 'root')"/>
<xsl:variable name="execute" select="java:execute($xdql,'DF_READ_QUERY',
$DMS_SESSION_ID)"/>
<xsl:variable name="myResult" select="java:getXMLDOM($xdql)"/>
<!--<xsl:variable name="myResult" select="java:getChildNodes($myResult)"/>-->
<xsl:value-of select="$myResult"/>
</xsl:template>
</xsl:stylesheet>
The XML file that is getting used at local disk looks like the following:
<?xml version="1.0"?>
<!-- edited with XML Spy v4.3 U (http://www.xmlspy.com) by K Chalasani (Documentum) -->
<newsletter>
<title>
TerraNews Newsletter
</title>
<intro>
Welcome to the first Aggregated Newsletter from
TerraNews, gathering all the important news of the
past several years in one place from
the various
Terra News Agencys across the world and beyond.
</intro>
<Topics>
<topictitle>
Today's Headlines
</topictitle>
</Topics>
</newsletter>
I have ensured that the r_object_ids mentioned in the program are present in the Content Server. After execution of this java program I am getting the following html output which shows that XDQL part has not returned anything. Otherwise it would have printed something against the XSL line "<xsl:value-of select="$myResult"/>".
<html xmlns:java="http://xml.apache.org/xslt/java" xmlns:xalan-nodeset="http://xml.apache.org/xalan">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<h1>
TerraNews Newsletter
</h1>
</body>
</html>
To test further I have executed XDQL DFC APIs as should below. This code returns the full XML content specified by the given r_object_id.
public static void main(String[] args) throws Exception {
DctmSessionHandler dctmSessionHandler = new DctmSessionHandler();
IDfSessionManager sessionManager = null;
IDfSession sess = null;
List docbases = new ArrayList();
docbases.add("docbase_name");
sessionManager = dctmSessionHandler.getSessionManager("dmuser","dmpassword", docbases);
sess = sessionManager.getSession("docbase_name");
IDfClientX clientx = new DfClientX();
IDfXmlQuery xdql = clientx.getXmlQuery();
xdql.init();
xdql.setDql("select r_object_id from dm_document where object_name='insights'");
xdql.includeContent(true);
xdql.setContentEncoding("dom");
xdql.setContentFormat("xml");
xdql.setRootNode("root");
xdql.execute(DfXmlQuery.DF_READ_QUERY,sess);
System.out.println(xdql.getXMLString());
}
Can anyone please look into this and tell me what wrong I am doing when I am trying to get the same XML data using XDQL from my XSL file? I am stuck with this for last 5 days. I have visited many sites and got many PDF documents on the same issue. But none of the solutions worked for me.
Any type of help is appreciated.
Thanks in advance for your valuable time.
-Raj Kumar