cancel
Showing results for 
Search instead for 
Did you mean: 

XML Tranformations

Former Member
0 Kudos

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?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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