You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by John Carroll <jc...@micromuse.com> on 2000/02/23 16:28:20 UTC

SQL Processor question

Hi,

I am successfully extracting data from an SQL database using cocoon and
the SQL processor.
The problem is that for every non-numeric XML element created by the
processor, it appends
'&#0;' on to the end  of the textual element content, i.e rather than

<field>Database field</field>

it produces

<field>Database field&#0;</field>

has anyone else seen this, or knows a workaround?

thanks,

John.



Re: dynamic file includes in xsp

Posted by Rick Tyler <ri...@ticketweb.com>.
I got it to work in case anyone is interested.

The following "includes" the XML generated by an external
CGI program, invoked with the same arguments as were passed
to the .xml:

  <xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">

    <xsp:structure>

      <xsp:include>java.net.*</xsp:include>
      <xsp:include>org.xml.sax.HandlerBase</xsp:include>
      <xsp:include>org.xml.sax.Parser</xsp:include>
      <xsp:include>org.xml.sax.helpers.ParserFactory</xsp:include>

    </xsp:structure>

    <page>

      <xsp:logic>

        class MyHandler extends HandlerBase
        {
          Document document;
          Stack xspNodeStack;
          Node xspCurrentNode, xspParentNode;

          public MyHandler (
            Document _document,
            Stack _xspNodeStack,
            Node _xspParentNode,
            Node _xspCurrentNode )
          {
            document = _document;
            xspNodeStack = _xspNodeStack;
            xspParentNode = _xspParentNode;
            xspCurrentNode = _xspCurrentNode;
          }

          public void startElement (
            String name,
            AttributeList attrList )
          {
            xspParentNode = xspCurrentNode;

            xspNodeStack.push( xspParentNode );

            xspCurrentNode = document.createElement( name );

            xspParentNode.appendChild( xspCurrentNode );

            if( attrList != null )
            {
              int numAttr = attrList.getLength();

              <![CDATA[
              for( int i = 0; i < numAttr; i++ )
              { ]]>
                ((Element) xspCurrentNode).setAttribute(
                  attrList.getName( i ),
                  attrList.getValue( i ) );
              }
            }
          }

          public void characters (
            char [] buf,
            int start,
            int length )
          {
            String text = new String( buf, start, length );

            xspCurrentNode.appendChild( document.createTextNode(
              text ) );
          }

          public void endElement ( String name )
          {
            xspCurrentNode = (Node) xspNodeStack.pop();
          }
        }

        MyHandler myHandler = new MyHandler(
          document, xspNodeStack, xspParentNode, xspCurrentNode );

        Parser parser = ParserFactory.makeParser(
          "org.apache.xerces.parsers.SAXParser" );

        parser.setDocumentHandler( myHandler );

        parser.setErrorHandler( myHandler );

        String url = "http://localhost/mycgi";

        String query = request.getQueryString();

        if( query != null )
          url += "?" + query;

        parser.parse( url );

      </xsp:logic>
    
    </page>

  </xsp:page>

- RT

Re: dynamic file includes in xsp

Posted by Mike Engelhart <me...@earthtrip.com>.
Rick Tyler wrote:

> Having explored a similar problem at great length over the past
> couple of weeks, I believe the only way to do what you want is
> to instantiate your own xml parser in order to parse the included
> XML and add to the DOM subtree which XSP must pass on to the next
> processing layer (i.e. XSLT).
I haven't tried this but I don't think you have to instantiate your own
parser as there is an "xspParser" variable implicitly defined in every XSP
page for your use.  Is that what you mean?

*****

Re: dynamic file includes in xsp

Posted by Rick Tyler <ri...@ticketweb.com>.
Duncan Werner wrote:
> 
> Is there a way to do file includes in XSP pages? Specifically, I'd like to
> include xml files in an xsp page based on parameters.

Having explored a similar problem at great length over the past
couple of weeks, I believe the only way to do what you want is
to instantiate your own xml parser in order to parse the included
XML and add to the DOM subtree which XSP must pass on to the next
processing layer (i.e. XSLT).

I have just started working on this myselft, but I don't have any
code to share yet.

Let me know if you want to collaborate.

- RT

dynamic file includes in xsp

Posted by Duncan Werner <du...@pagea.com>.
Is there a way to do file includes in XSP pages? Specifically, I'd like to
include xml files in an xsp page based on parameters.

Thanks,

Duncan

Re: SQL Processor question

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 23 Feb 2000, John Carroll wrote:

> Hi,
> 
> I am successfully extracting data from an SQL database using cocoon
> and the SQL processor. The problem is that for every non-numeric XML
> element created by the processor, it appends '&#0;' on to the end of
> the textual element content, i.e rather than
> 
> <field>Database field</field>
> 
> it produces
> 
> <field>Database field&#0;</field>
> 
> has anyone else seen this, or knows a workaround?

Hmm. What database are you using? Is it possible that all of your text
fields end with some weird character, e.g. \r?

- donald