You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Claude Warren <cl...@histio.org> on 2000/09/18 20:58:25 UTC

Embeding XML from java object.

Hello,

I have a java object that produces XML output.  This is not a servlet.
I  can not seem to get the XML that is output by the object formatted by
the xsl.  What am I doing wrong???  I am using cocoon 1.7.4, Apache
Server, Apache JServe engine, Linux, IBM java 1.1.8.

XML page:

<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="test-pre.xsl" type="text/xsl"?>

<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<page>
<xsp:logic>
  Class.forName("com.imaginary.sql.msql.MsqlDriver");
  String dburl = "jdbc:msql://histio.org/hs";
  java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
"test",
null);
  org.histio.db.Member member = new org.histio.db.Member();
  member.setConnection( con );
  member.setID( "1" );
<xsp:content>
<xsp:expr>
org.histio.util.xml.XMLTranslator.toXML( member )
</xsp:expr>
</xsp:content>
</xsp:logic>
</page>
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>

<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<page>
<xsp:logic>
  Class.forName("com.imaginary.sql.msql.MsqlDriver");
  String dburl = "jdbc:msql://localhost/hs";
  java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
"test",
null);
  org.histio.db.Member member = new org.histio.db.Member();
  member.setConnection( con );
  member.setID( "1" );
<xsp:content>
<xsp:expr>
org.histio.util.xml.XMLTranslator.toXML( member )
</xsp:expr>
</xsp:content>
</xsp:logic>
</page>
</xsp:page>

The output that I get is the XML from the object.  If I reverse the
order of the <?cocoon-process type="xsp"?> and <?cocoon-process
type="xslt"?> lines I don't even get that.  Any suggestions would be
appreciated



Re: Embeding XML from java object.

Posted by Claude Warren <cl...@histio.org>.
Given that there are multiple ways of doing this:
1. insert the XML text in the document before it is parsed.
2. parse the XML into a document inside XSP and insert that into the document
tree.
3. parse the XML into a document inside the java Object and insert the returned
document into the document tree.

What is the most efficient and how can it be done.

I would prefer #1 above as it provides the the greatest flexibility.

Torsten Curdt wrote:

> > I was afraid that someone would say that.  I am hoping that there
> > is a way to
> > take the string input and parse it as though it were an included XML file.
> > Failing that, how can I call the parser from XSP and insert the
> > result into the
> > tree?
>
> It is possible but very(!) expensive (=time consuming)
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


RE: Embeding XML from java object.

Posted by Torsten Curdt <tc...@dff.st>.
> I was afraid that someone would say that.  I am hoping that there
> is a way to
> take the string input and parse it as though it were an included XML file.
> Failing that, how can I call the parser from XSP and insert the
> result into the
> tree?

It is possible but very(!) expensive (=time consuming)
--
Torsten


Re: Embeding XML from java object.

Posted by Claude Warren <cl...@histio.org>.
I was afraid that someone would say that.  I am hoping that there is a way to
take the string input and parse it as though it were an included XML file.
Failing that, how can I call the parser from XSP and insert the result into the
tree?

Paul Russell wrote:

> What your method is returning is a string, rather than XML -
> I'm not the expert at this, but I suspect if you return a DOM
> fragment, you might have more luck. Failing that, you need to
> parse the XML you're returning, rather than just plonking the
> string into the DOM tree.
>
> On Mon, Sep 18, 2000 at 09:02:37PM -0400, Claude Warren wrote:
> > After further testing I found that the output being generated was:
> >
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
> > "http://www.w3.org/TR/REC-html40/strict.dtd">
> > <html><head><title>xsp test page</title></head><body>
> >
> >
> > &lt;idcard id=&quot;1&quot;&gt;
> > &lt;name&gt;
> > &lt;family&gt;F_name&lt;/family&gt;
> > &lt;given&gt;G_name&lt;/given&gt;
> > &lt;sort&gt;F_NAME, G_NAME&lt;/sort&gt;
> > &lt;display&gt;G_name F_name&lt;/display&gt;
> > &lt;/name&gt;
> > &lt;address&gt;
> > &lt;line&gt;addr 1&lt;/line&gt;
> > &lt;line&gt;addr 2&lt;/line&gt;
> > &lt;line&gt;addr 3&lt;/line&gt;
> > &lt;line&gt;addr 4&lt;/line&gt;
> > &lt;locality&gt;city&lt;/locality&gt;
> > &lt;region&gt;state&lt;/region&gt;
> > &lt;postalcode&gt;zip code&lt;/postalcode&gt;
> > &lt;country&gt;USA&lt;/country&gt;
> > &lt;/address&gt;
> > &lt;phone prefered=&quot;true&quot;&gt;
> > &lt;type&gt;voice&lt;/type&gt;
> > &lt;number&gt;+1 803 555 1212&lt;/number&gt;
> > &lt;/phone&gt;
> > &lt;phone prefered=&quot;false&quot;&gt;
> > &lt;type&gt;fax&lt;/type&gt;
> > &lt;number&gt;+1 803 555 2121&lt;/number&gt;
> > &lt;/phone&gt;
> > &lt;email prefered=&quot;true&quot;&gt;
> > G_name F_name &lt;eaddr@server.com&gt;&lt;/email&gt;
> > &lt;/idcard&gt;
> >
> >
> > </body></html>
> >
> >
> > So the output is being converted from the "<" to "&lt;" form.  How can I
> > stop this so that the input will be processed correctly?"
> >
> >
> > Claude Warren wrote:
> >
> > > Hello,
> > >
> > > I have a java object that produces XML output.  This is not a servlet.
> > > I  can not seem to get the XML that is output by the object formatted by
> > > the xsl.  What am I doing wrong???  I am using cocoon 1.7.4, Apache
> > > Server, Apache JServe engine, Linux, IBM java 1.1.8.
> > >
> > > XML page:
> > >
> > > <?xml version="1.0"?>
> > > <?cocoon-process type="xsp"?>
> > > <?cocoon-process type="xslt"?>
> > > <?xml-stylesheet href="test-pre.xsl" type="text/xsl"?>
> > >
> > > <xsp:page language="java"
> > > xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> > > <page>
> > > <xsp:logic>
> > >   Class.forName("com.imaginary.sql.msql.MsqlDriver");
> > >   String dburl = "jdbc:msql://histio.org/hs";
> > >   java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
> > > "test",
> > > null);
> > >   org.histio.db.Member member = new org.histio.db.Member();
> > >   member.setConnection( con );
> > >   member.setID( "1" );
> > > <xsp:content>
> > > <xsp:expr>
> > > org.histio.util.xml.XMLTranslator.toXML( member )
> > > </xsp:expr>
> > > </xsp:content>
> > > </xsp:logic>
> > > </page>
> > > <?xml version="1.0"?>
> > > <?cocoon-process type="xsp"?>
> > > <?cocoon-process type="xslt"?>
> > > <?xml-stylesheet href="test.xsl" type="text/xsl"?>
> > >
> > > <xsp:page language="java"
> > > xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> > > <page>
> > > <xsp:logic>
> > >   Class.forName("com.imaginary.sql.msql.MsqlDriver");
> > >   String dburl = "jdbc:msql://localhost/hs";
> > >   java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
> > > "test",
> > > null);
> > >   org.histio.db.Member member = new org.histio.db.Member();
> > >   member.setConnection( con );
> > >   member.setID( "1" );
> > > <xsp:content>
> > > <xsp:expr>
> > > org.histio.util.xml.XMLTranslator.toXML( member )
> > > </xsp:expr>
> > > </xsp:content>
> > > </xsp:logic>
> > > </page>
> > > </xsp:page>
> > >
> > > The output that I get is the XML from the object.  If I reverse the
> > > order of the <?cocoon-process type="xsp"?> and <?cocoon-process
> > > type="xslt"?> lines I don't even get that.  Any suggestions would be
> > > appreciated
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> --
> Paul Russell                               <pa...@luminas.co.uk>
> Technical Director,                   http://www.luminas.co.uk
> Luminas Ltd.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Embeding XML from java object.

Posted by Paul Russell <pa...@luminas.co.uk>.
What your method is returning is a string, rather than XML -
I'm not the expert at this, but I suspect if you return a DOM
fragment, you might have more luck. Failing that, you need to
parse the XML you're returning, rather than just plonking the
string into the DOM tree.

On Mon, Sep 18, 2000 at 09:02:37PM -0400, Claude Warren wrote:
> After further testing I found that the output being generated was:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
> "http://www.w3.org/TR/REC-html40/strict.dtd">
> <html><head><title>xsp test page</title></head><body>
> 
> 
> &lt;idcard id=&quot;1&quot;&gt;
> &lt;name&gt;
> &lt;family&gt;F_name&lt;/family&gt;
> &lt;given&gt;G_name&lt;/given&gt;
> &lt;sort&gt;F_NAME, G_NAME&lt;/sort&gt;
> &lt;display&gt;G_name F_name&lt;/display&gt;
> &lt;/name&gt;
> &lt;address&gt;
> &lt;line&gt;addr 1&lt;/line&gt;
> &lt;line&gt;addr 2&lt;/line&gt;
> &lt;line&gt;addr 3&lt;/line&gt;
> &lt;line&gt;addr 4&lt;/line&gt;
> &lt;locality&gt;city&lt;/locality&gt;
> &lt;region&gt;state&lt;/region&gt;
> &lt;postalcode&gt;zip code&lt;/postalcode&gt;
> &lt;country&gt;USA&lt;/country&gt;
> &lt;/address&gt;
> &lt;phone prefered=&quot;true&quot;&gt;
> &lt;type&gt;voice&lt;/type&gt;
> &lt;number&gt;+1 803 555 1212&lt;/number&gt;
> &lt;/phone&gt;
> &lt;phone prefered=&quot;false&quot;&gt;
> &lt;type&gt;fax&lt;/type&gt;
> &lt;number&gt;+1 803 555 2121&lt;/number&gt;
> &lt;/phone&gt;
> &lt;email prefered=&quot;true&quot;&gt;
> G_name F_name &lt;eaddr@server.com&gt;&lt;/email&gt;
> &lt;/idcard&gt;
> 
> 
> </body></html>
> 
> 
> So the output is being converted from the "<" to "&lt;" form.  How can I
> stop this so that the input will be processed correctly?"
> 
> 
> Claude Warren wrote:
> 
> > Hello,
> >
> > I have a java object that produces XML output.  This is not a servlet.
> > I  can not seem to get the XML that is output by the object formatted by
> > the xsl.  What am I doing wrong???  I am using cocoon 1.7.4, Apache
> > Server, Apache JServe engine, Linux, IBM java 1.1.8.
> >
> > XML page:
> >
> > <?xml version="1.0"?>
> > <?cocoon-process type="xsp"?>
> > <?cocoon-process type="xslt"?>
> > <?xml-stylesheet href="test-pre.xsl" type="text/xsl"?>
> >
> > <xsp:page language="java"
> > xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> > <page>
> > <xsp:logic>
> >   Class.forName("com.imaginary.sql.msql.MsqlDriver");
> >   String dburl = "jdbc:msql://histio.org/hs";
> >   java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
> > "test",
> > null);
> >   org.histio.db.Member member = new org.histio.db.Member();
> >   member.setConnection( con );
> >   member.setID( "1" );
> > <xsp:content>
> > <xsp:expr>
> > org.histio.util.xml.XMLTranslator.toXML( member )
> > </xsp:expr>
> > </xsp:content>
> > </xsp:logic>
> > </page>
> > <?xml version="1.0"?>
> > <?cocoon-process type="xsp"?>
> > <?cocoon-process type="xslt"?>
> > <?xml-stylesheet href="test.xsl" type="text/xsl"?>
> >
> > <xsp:page language="java"
> > xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> > <page>
> > <xsp:logic>
> >   Class.forName("com.imaginary.sql.msql.MsqlDriver");
> >   String dburl = "jdbc:msql://localhost/hs";
> >   java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
> > "test",
> > null);
> >   org.histio.db.Member member = new org.histio.db.Member();
> >   member.setConnection( con );
> >   member.setID( "1" );
> > <xsp:content>
> > <xsp:expr>
> > org.histio.util.xml.XMLTranslator.toXML( member )
> > </xsp:expr>
> > </xsp:content>
> > </xsp:logic>
> > </page>
> > </xsp:page>
> >
> > The output that I get is the XML from the object.  If I reverse the
> > order of the <?cocoon-process type="xsp"?> and <?cocoon-process
> > type="xslt"?> lines I don't even get that.  Any suggestions would be
> > appreciated
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

-- 
Paul Russell                               <pa...@luminas.co.uk>
Technical Director,                   http://www.luminas.co.uk
Luminas Ltd.

Re: Embeding XML from java object.

Posted by Claude Warren <cl...@histio.org>.
After further testing I found that the output being generated was:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><title>xsp test page</title></head><body>


&lt;idcard id=&quot;1&quot;&gt;
&lt;name&gt;
&lt;family&gt;F_name&lt;/family&gt;
&lt;given&gt;G_name&lt;/given&gt;
&lt;sort&gt;F_NAME, G_NAME&lt;/sort&gt;
&lt;display&gt;G_name F_name&lt;/display&gt;
&lt;/name&gt;
&lt;address&gt;
&lt;line&gt;addr 1&lt;/line&gt;
&lt;line&gt;addr 2&lt;/line&gt;
&lt;line&gt;addr 3&lt;/line&gt;
&lt;line&gt;addr 4&lt;/line&gt;
&lt;locality&gt;city&lt;/locality&gt;
&lt;region&gt;state&lt;/region&gt;
&lt;postalcode&gt;zip code&lt;/postalcode&gt;
&lt;country&gt;USA&lt;/country&gt;
&lt;/address&gt;
&lt;phone prefered=&quot;true&quot;&gt;
&lt;type&gt;voice&lt;/type&gt;
&lt;number&gt;+1 803 555 1212&lt;/number&gt;
&lt;/phone&gt;
&lt;phone prefered=&quot;false&quot;&gt;
&lt;type&gt;fax&lt;/type&gt;
&lt;number&gt;+1 803 555 2121&lt;/number&gt;
&lt;/phone&gt;
&lt;email prefered=&quot;true&quot;&gt;
G_name F_name &lt;eaddr@server.com&gt;&lt;/email&gt;
&lt;/idcard&gt;


</body></html>


So the output is being converted from the "<" to "&lt;" form.  How can I
stop this so that the input will be processed correctly?"


Claude Warren wrote:

> Hello,
>
> I have a java object that produces XML output.  This is not a servlet.
> I  can not seem to get the XML that is output by the object formatted by
> the xsl.  What am I doing wrong???  I am using cocoon 1.7.4, Apache
> Server, Apache JServe engine, Linux, IBM java 1.1.8.
>
> XML page:
>
> <?xml version="1.0"?>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="test-pre.xsl" type="text/xsl"?>
>
> <xsp:page language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> <page>
> <xsp:logic>
>   Class.forName("com.imaginary.sql.msql.MsqlDriver");
>   String dburl = "jdbc:msql://histio.org/hs";
>   java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
> "test",
> null);
>   org.histio.db.Member member = new org.histio.db.Member();
>   member.setConnection( con );
>   member.setID( "1" );
> <xsp:content>
> <xsp:expr>
> org.histio.util.xml.XMLTranslator.toXML( member )
> </xsp:expr>
> </xsp:content>
> </xsp:logic>
> </page>
> <?xml version="1.0"?>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="test.xsl" type="text/xsl"?>
>
> <xsp:page language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> <page>
> <xsp:logic>
>   Class.forName("com.imaginary.sql.msql.MsqlDriver");
>   String dburl = "jdbc:msql://localhost/hs";
>   java.sql.Connection con = java.sql.DriverManager.getConnection(dburl,
> "test",
> null);
>   org.histio.db.Member member = new org.histio.db.Member();
>   member.setConnection( con );
>   member.setID( "1" );
> <xsp:content>
> <xsp:expr>
> org.histio.util.xml.XMLTranslator.toXML( member )
> </xsp:expr>
> </xsp:content>
> </xsp:logic>
> </page>
> </xsp:page>
>
> The output that I get is the XML from the object.  If I reverse the
> order of the <?cocoon-process type="xsp"?> and <?cocoon-process
> type="xslt"?> lines I don't even get that.  Any suggestions would be
> appreciated
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org