You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by YP <pe...@club-internet.fr> on 2000/10/11 10:42:05 UTC

Embedding XML results in an XSP page(might respond to "PI problem")

Hello,

I felt difficult to embed computed XML in a XSP page.


1) Direct text insertion does not work:

<xsp:logic> String xmlStr = new String ("<Hello> hello world </Hello>"
); </xsp:logic> 
<xsp:expr> xmlStr </xsp:expr>

Produces a text node that contains "&lt;Hello&gt; hello world
&lt;/Hello&gt;" that is not processed by XSLT.

This might be the response to Monica in "PI problem" message.

2) The following method works:
    <!-- Proper imports are expected -->
   <xsp:logic>
        <![CDATA[
	String xmlStr = new String ("<Hello> hello world </Hello>" )
	Reader reader  = new StringReader(xmlStr);
	InputSource    inputSource = new InputSource(reader);
	Document doc = xspParser.parse(inputSource);
	]]>
  </xsp:logic>

  <!-- The result is inserted this way -->
  <xsp:expr> doc.getFirstChild() </xsp:expr>


I do not understand exactly why "<xsp:expr> doc </xsp:expr>" fails. 
There is an issue with the document owner that causes a null pointer
exception in Xerces.

As I have not found other method, I would appreciate all this stuff
being handled automatically by the XSP processor. For example, extending
the <xsp:expr> tag in such a way:
    <xsp:expr type="xmlstring"> xmlStr </xsp:expr>
The attribute "type" being used to direct the XSP to parse the string.


In addition, It is also possible to build a Document Object using the
DOM API and to insert it in the XSP page using the <xsp:exp> tag (a
thread can be open on this subject).

Cheers,

Yvon