You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stephan Coboos <cr...@gmx.net> on 2004/03/23 13:29:52 UTC
Include XML string into the pipline via transformer
Hello,
I need to include xml coming from a database as string into the pipline
via my own transformer. (Please do not ask why writing my own
transformer. I need it..). I had seen, including xml coming form sources
(xml files) is very easy using the SourceUtil. But how can I include xml
which exists not as source but as string? Is there already a tool
avaiable which makes it easy like the SourceUtil?
Any examples?
Thank you very much.
Regards
Stephan
Re: Include XML string into the pipline via transformer
Posted by Vadim Gritsenko <va...@reverycodes.com>.
Stephan Coboos wrote:
> Hello,
>
> I need to include xml coming from a database as string into the
> pipline via my own transformer. (Please do not ask why writing my own
> transformer. I need it..). I had seen, including xml coming form
> sources (xml files) is very easy using the SourceUtil. But how can I
> include xml which exists not as source but as string? Is there already
> a tool avaiable which makes it easy like the SourceUtil?
>
> Any examples?
XSPUtil.java:
public static void includeString(String string, ComponentManager
manager, ContentHandler contentHandler)
throws RuntimeException {
XSPUtil.includeInputSource(new InputSource(new
StringReader(String.valueOf(string))), manager,
contentHandler);
}
Vadim
Re: Include XML string into the pipline via transformer
Posted by Jorg Heymans <jh...@domek.be>.
in transform(Document doc) you can access the document in a DOM like
fashion ie
Element a = document.createElement("myelement");
Element b = document.createElement("myelementchild");
Element addedParameter = document.createElement("parameter");
addedParameter.setAttribute("name", "output");
Element addedParameterValue = document.createElement("value");
addedParameterValue.appendChild(document.createTextNode("some text here"));
addedParameter.appendChild(addedParameterValue);
b.appendChild(addedParameter);
a.appendChild(reqparams);
document.appendChild(req);
I don't know if there is an "easier" way than this.
HTH
Jorg
Stephan Coboos wrote:
> Hello,
>
> I need to include xml coming from a database as string into the pipline
> via my own transformer. (Please do not ask why writing my own
> transformer. I need it..). I had seen, including xml coming form sources
> (xml files) is very easy using the SourceUtil. But how can I include xml
> which exists not as source but as string? Is there already a tool
> avaiable which makes it easy like the SourceUtil?
>
> Any examples?
>
> Thank you very much.
>
> Regards
> Stephan
>