on 03-09-2006 6:59 PM
Hi All,
I was able to transform a XML into a HTML, using a XSL, and save it in my local disc (I used an exemple that I found in SDN).
Some code:
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xmlS = new StreamSource(profile.getProperty("xml"));
Source xslS = new StreamSource(profile.getProperty("xsl"));
Transformer transformer = tFactory.newTransformer(xslS);
template = tFactory.newTemplates(xslS);
transformer = template.newTransformer();
File f = new File(profile.getProperty("html"));
Result result = new StreamResult(f);
transformer.transform(xmlSource, result);
Now I´m trying to pass the same document directy to the KM. Using :
user = WPUMFactory.getUserFactory().getEP5User(request.getUser());
rContext = new ResourceContext(user);
RID rid = RID.getRID("/documents/EXP");
res = ResourceFactory.getInstance().getResource(rid, rContext);
ICollection parent = (ICollection) res;
IContent nContent = new Content(dataStream, "text/html", dataStream.available());
IResource ficheiro = parent.createResource("File", null, nContent);
ficheiro.updateContent(nContent);
Like it is, this code creates and resource. My problem is that I don´t know how to pass the content from my file to it - newContent - and show it in the KM.
Can anybody help me?
Hi
Try this code
String FileContent="your file content";
ICollection parent = (ICollection)ResourceFactory.getInstance().getResource(rid, resourceContext);
//Prepare the content
IContent newsContent = MimeUtils.getContentFromString(FileContent,"text/xml ");//"text/plain"
//Retrieve a collection with context
IContent aContent = new Content(newsContent.getInputStream(), "text/xml ",
newsContent.getContentLength());
IResource resource = parent.createResource("FileName", null,aContent,true);
Have a nice day
Nir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.