HI,
I want to know if there is a way to save and generate a dcr from cssdk.
I know how to play with dcr as xml file but how do we generate it to get the xml from configured xsl/tpl?
Apprecicate your valuable inputs.
A DCR is just an XML file that is located within a specific directory structure, conforms to the structure defined in the DCT and has a specific EA associated with it. There's is nothing specific in CSSDK to deal with producing DCRs (as far as I know).
Hi,
For generating DCRs, there is no method in CSSDK. But for generating output using tpl and xsl from the DCRs we have some method in cssdk.For more information please see the com.interwoven.cssdk.transform.XSLTransformer docs.
Thanks
Kalam
I went through forums here where we have issue with cssdk parsing xmls due to some BOM issue.
I am facing the same while using XSL Transformer.
I tried converting the stream to reader in java but i am getting null pointer exception at the point of creation of reader.I suppose we need to do this in cssdk reader object,since i am connecting locally.
Now,how we do that..or how can we get cssdk xsl transform to work!
Thanks.
In some circumstances, I have had issues feeding the CSSimpleFile#getInputStream() directly to a transformation engine, not necessarily because of the BOM but because there's weird null characters in front of it... in any case, the fix (for me) in those situations has always been to read the InputStream into a String, then content.replaceAll("^.*<?xml","<?xml"), then feed via StringReader to the Transformer.
Can you post your code snippet here?
Provided with the usual disclaimer, no guarantees etc etc. Something like this:
public String xslTransform(CSSimpleFile path, InputStream xsl) throws IOException, TransformerException, SAXException { // Need to read this ourselves instead of just passing // path.getInputStream to the parser, because // it looks like the IWOV API introduces some spacing before the // <?xml ?>, causing the parse to fail StringBuffer xml = new StringBuffer(); BufferedReader in = new BufferedReader(new InputStreamReader(path.getInputStream(true), "UTF-8")); String line = null; while ((line = in.readLine()) != null) { xml.append(line).append("\n"); } in.close(); // just to be sure, remove anything that might have been before // the processing instruction String xmlOut = xml.toString(); xmlOut = xmlOut.replaceFirst("^.*<", "<"); Source xmlSource = new StreamSource(new ByteArrayInputStream(xmlOut.getBytes("UTF-8"))); InputSource inSource = new InputSource(xsl); inSource.setEncoding("UTF-8"); Transformer transformer = TransformerFactory.newInstance().newTransformer(new SAXSource(XMLReaderFactory.createXMLReader(), inSource)); if (transformer == null) { throw new TransformerException("Could not create a transformer; XSL might be broken"); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); transformer.transform(xmlSource, new StreamResult(baos)); return baos.toString(); }
HI ,
Finally i got it working. I have been changing code a lot and what worked i will pase the snippet below..
But i cleared code a lot..removed spaces in xml/xsl files and commented all file readers
/* this works though
try {
int r=xslsrc.getReader().read();
System.out.println((char)r);
} catch (IOException e1) {
TODO Auto-generated catch block
e1.printStackTrace();
}
*/
CSVPath xslfilepath =new CSVPath(xslName);
CSSimpleFile xslFile = (CSSimpleFile) client .getFile(xslfilepath);
/*use this*/ xslsrc=new StreamSource(new InputStreamReader(xslFile.getInputStream(true),"UTF-8"));
instead of - //xslsrc=new StreamSource(xslFile.getInputStream(true));
inputSource =new StreamSource(new InputStreamReader(inputFile.getInputStream(true),"UTF-8"));
/*transformer*/
com.interwoven.cssdk.transform.XSLTransformer.transform(inputSource,xslsrc,out);
@Everybody esp rpoulin-Really appreciate your help here.