You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Majcen, Kurt" <ku...@joanneum.at> on 2002/09/17 13:27:02 UTC

Integrating XML formatted information directly with navigational structures

Hi all!

I'm rather new with Cocoon but I think I've got a somehow tricky question:

In my ORACLE database XML formatted records are stored e.g. for users (also
for other types of records but these are the easy ones I want to try with)
in CLOB fields - so the record could look like:

-- CLOB content ---
some XML stuff
...
<user>
    <system_user_name>My user name</system_user_name>
    <name>My real name</name>
    <adress>My street and number</adress>
    <phone>My full phone number</phone>
    <fax>My full fax number</fax>
    <email>My email adress</email>
</user>
-- end of CLOB content ---

One of my pages should be a 'Search for users' form.
Result of processing the above form should show a page (simple list) which
provides
- page title
- some descriptive information
- a list with only the content of  <system_user_name> for let's say the
first 20 results but each element being a link to a detailed page
- navigational elements (button or links) like 'previous 10' or 'next 10'.

Below is an example for the simple list with the first found result already
stated in html like form:
-------------------- simple list -----------------------------
    Results of user search
    Your search for 'searched name' resulted in 21 hits.
    Results 1 - 10

    <a href="http://myserver/detaileduser?name=Real name1">Real name1</a>
    Real name2
...
    Real name9
    Real name10

    <previous> 1 2 <next>
-------------------- end of simple list -----------------------------

When clicking on a name the detailed page should provide whole information
about the user in a formatted way like:
---------------------- detailed page -------------------------------
    System user name:	My user name

    Real name:		My real name

    Adress:		My street and number

    Phone:		My full phone number
    FAX:			My full fax number
    Email:		My email adress
---------------------- end of detailed page -------------------------------

My intention was to use an action which performs the search and stores the
results in an XML file (or maybe something which is XML like but does not
include e.g. the <?xml version="1.0"?> if this more convenient for the
temporary existing file). An XSP reads that XML file via some code in the
logic-section and provides the XML with the buttons/or links at the end. So
an XSL has to do the filtering of the information for the simple list and
the transformation to provide the links (which need to have some dynamic
parameters for finding the single person record in the database later on
when selected from the list) to the detailed persons.
BUT somehow I find it rather hard to get the XML (which is dynamically
produced from the database) to be included in the XSP.

Is this the right way or can you point me to a more clever one?
Maybe I don't need the XSP but how can I then get the navigation elements on
my simple list page. Is it just that simple to
- create the XML file in the action
- transform and filter to get the clickable list of names
- transform to include the page header, the descriptive text and the
navigation elements
- serialize with the html serializer

For the user pages I could also read database attributes (system user name,
adress ...) directly but I have other kinds of information and functionality
in my system which forces me to stick to already existing XML formatted
information from the database.

Thanks in advance
Kurt Majcen


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Integrating XML formatted information directly with navigational structures

Posted by Vadim Gritsenko <va...@verizon.net>.
Ugo Cei wrote:

> Majcen, Kurt wrote:
>
>> Hi all!
>>
>> I'm rather new with Cocoon but I think I've got a somehow tricky 
>> question:
>>
>> In my ORACLE database XML formatted records are stored e.g. for users 
>> (also
>> for other types of records but these are the easy ones I want to try 
>> with)
>> in CLOB fields - so the record could look like:
>
>
> <snip/>
>
> I'd use a generator instead of an action. No need to store the 
> retrieved XML in a file and read it again via XSP.


I agree that temp file idea is really bad.


> You can find an example here [1]. I'll comment the relevant parts:
>
> PreparedStatement ps = ...;
> ResultSet rs = ps.executeQuery(); // execute query and retrieve the 
> result set
> while (rs.next()) {
>   // CONTENT is the CLOB column
>   insertXML(rs.getClob("content").getCharacterStream(), parser);
> }
> ...
>
> // The insertXML method parses the CLOB column as XML and inserts
> // it as SAX events in the pipeline.
>
> private void insertXML(Reader reader, Parser parser)
>   throws SAXException, IOException
> {
>   InputSource is = new InputSource(reader);
>   parser.parse(is, new IncludeXMLConsumer(xmlConsumer));
> }
>
> I hope this is helpful and correct.


I think this particular case asks for BlobSource (scratchpad).

Vadim


>     Ugo
>
> [1]: 
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cocoblog/CocoBlog/src/java/com/beblogging/generation/RSSGenerator.java?rev=1.1&content-type=text/vnd.viewcvs-markup
>




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Integrating XML formatted information directly with navigational structures

Posted by Ugo Cei <u....@cbim.it>.
Majcen, Kurt wrote:
> Hi all!
> 
> I'm rather new with Cocoon but I think I've got a somehow tricky question:
> 
> In my ORACLE database XML formatted records are stored e.g. for users (also
> for other types of records but these are the easy ones I want to try with)
> in CLOB fields - so the record could look like:

<snip/>

I'd use a generator instead of an action. No need to store the retrieved 
XML in a file and read it again via XSP.

You can find an example here [1]. I'll comment the relevant parts:

PreparedStatement ps = ...;
ResultSet rs = ps.executeQuery(); // execute query and retrieve the 
result set
while (rs.next()) {
   // CONTENT is the CLOB column
   insertXML(rs.getClob("content").getCharacterStream(), parser);
}
...

// The insertXML method parses the CLOB column as XML and inserts
// it as SAX events in the pipeline.

private void insertXML(Reader reader, Parser parser)
   throws SAXException, IOException
{
   InputSource is = new InputSource(reader);
   parser.parse(is, new IncludeXMLConsumer(xmlConsumer));
}

I hope this is helpful and correct.

	Ugo

[1]: 
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cocoblog/CocoBlog/src/java/com/beblogging/generation/RSSGenerator.java?rev=1.1&content-type=text/vnd.viewcvs-markup

-- 
Ugo Cei - http://www.bebloggging.com/blog/


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>