You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Hans-Guenter Stein <Ha...@siteos.de> on 2000/07/06 12:14:57 UTC
How to insert an xml-tree stored in a string?
How to insert an xml-subtree generated via some Java-functions into an
xml-document?
like:
<xsp:logic>
String aaa = "<a><a1>this is a1</a1><a2>this is a2</a2></a>";
</xsp:logic>
<xsp:expr>aaa</xsp:expr>
such that a subsequent processing instruction could work with the
inserted nodes
Re: How to insert an xml-tree stored in a string?
Posted by Hans-Guenter Stein <Ha...@siteos.de>.
I actually used the util-template code :-)
Torsten Curdt wrote:
> > > > How to insert an xml-subtree generated via some Java-functions into an
> > > > xml-document?
> > (...)
> > > > such that a subsequent processing instruction could work with the
> > > > inserted nodes
> > >
> > > That's exactly what I asked for in another thread.
> > > As far as I know now... You can't without parsing the
> > > String by yourself.
>
> [snip]
>
> > There is an XSP template written to include an
> > URI as DOM in a document. Using a string instead
> > of fetching an URI should be easy.
>
> ...probably still too slow (for me)
>
> Actually Hans-Guenther got it working... I doubt
> this template does it faster! But, well, prove
> me wrong and I'll be happy ;-)
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
RE: How to insert an xml-tree stored in a string?
Posted by Torsten Curdt <tc...@dff.st>.
> > > How to insert an xml-subtree generated via some Java-functions into an
> > > xml-document?
> (...)
> > > such that a subsequent processing instruction could work with the
> > > inserted nodes
> >
> > That's exactly what I asked for in another thread.
> > As far as I know now... You can't without parsing the
> > String by yourself.
[snip]
> There is an XSP template written to include an
> URI as DOM in a document. Using a string instead
> of fetching an URI should be easy.
...probably still too slow (for me)
Actually Hans-Guenther got it working... I doubt
this template does it faster! But, well, prove
me wrong and I'll be happy ;-)
--
Torsten
Re: How to insert an xml-tree stored in a string?
Posted by Sebastien Koechlin I-VISION <sk...@n-soft.com>.
Torsten Curdt a écrit :
>
> > How to insert an xml-subtree generated via some Java-functions into an
> > xml-document?
(...)
> > such that a subsequent processing instruction could work with the
> > inserted nodes
>
> That's exactly what I asked for in another thread.
> As far as I know now... You can't without parsing the
> String by yourself.
>
> You can
>
> 1)add a single node with "xspCurrentNode.appendChild()"
> 2)or add a tree you build up by yourself
> 3)or use use the cocoon parser to do so (I guess)
>
> See the XSPSqlLibary.java how it works...
> I'm trying on this, too, because I don't like
> the approach to have the sql string in my pages.
> I'm thinking of a bean doing this and giving back
> a tree which represents the query result.
You should look at the util taglib and the file
src/org/apache/cocoon/processor/xsp/library/java/util.xsl
in cocoon archive.
There is an XSP template written to include an
URI as DOM in a document. Using a string instead
of fetching an URI should be easy.
--
Sebastien Koechlin
Re: How to insert an xml-tree stored in a string?
Posted by Hans-Guenter Stein <Ha...@siteos.de>.
I got it working but the solution is rather slow (see code below)
I wonder whether there is a solution that works a little faster. Any ideas??
<xsp:logic>
// the mysql.showTableXML returns a string containing
// the contents of a table enclosed in xml-tags
String out=mysql.showTableXML("spiele");
</xsp:logic>
<xsp:expr>
this.xspParser.parse(
new InputSource(
new StringReader(
String.valueOf(out)
)
)
).getDocumentElement()
</xsp:expr>
Torsten Curdt wrote:
> > How to insert an xml-subtree generated via some Java-functions into an
> > xml-document?
> >
> > like:
> >
> > <xsp:logic>
> > String aaa = "<a><a1>this is a1</a1><a2>this is a2</a2></a>";
> > </xsp:logic>
> > <xsp:expr>aaa</xsp:expr>
> >
> > such that a subsequent processing instruction could work with the
> > inserted nodes
>
> That's exactly what I asked for in another thread.
> As far as I know now... You can't without parsing the
> String by yourself.
>
> You can
>
> 1)add a single node with "xspCurrentNode.appendChild()"
> 2)or add a tree you build up by yourself
> 3)or use use the cocoon parser to do so (I guess)
>
> See the XSPSqlLibary.java how it works...
> I'm trying on this, too, because I don't like
> the approach to have the sql string in my pages.
> I'm thinking of a bean doing this and giving back
> a tree which represents the query result.
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
RE: How to insert an xml-tree stored in a string?
Posted by Torsten Curdt <tc...@dff.st>.
> How to insert an xml-subtree generated via some Java-functions into an
> xml-document?
>
> like:
>
> <xsp:logic>
> String aaa = "<a><a1>this is a1</a1><a2>this is a2</a2></a>";
> </xsp:logic>
> <xsp:expr>aaa</xsp:expr>
>
> such that a subsequent processing instruction could work with the
> inserted nodes
That's exactly what I asked for in another thread.
As far as I know now... You can't without parsing the
String by yourself.
You can
1)add a single node with "xspCurrentNode.appendChild()"
2)or add a tree you build up by yourself
3)or use use the cocoon parser to do so (I guess)
See the XSPSqlLibary.java how it works...
I'm trying on this, too, because I don't like
the approach to have the sql string in my pages.
I'm thinking of a bean doing this and giving back
a tree which represents the query result.
--
Torsten