Skip to Content
author's profile photo Former Member
Former Member

XML Tranformations

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);


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?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:51 AM


    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 ",


    IResource resource = parent.createResource("FileName", null,aContent,true);

    Have a nice day


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.