You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Richard Cunliffe <ri...@cunliffe.net> on 2003/03/13 10:39:10 UTC

SQL and Stylesheets

Thorsten and Marco,

 

 

After reading the "Cocoon: Building XML Applications" and O'Reilly
"XSLT" I have written my own "tidy and simple" XSL style sheet :-)
(instead of using XML Spy). It's giving results, but its not right. 

 

I have included the style sheet, the XML document, and a picture of the
results. I'm sure it's nothing to serious. It may be something to do
with X-Paths but I cant be sure.

 

 

Thanks,

 

Richard.

 


AW: SQL and Stylesheets

Posted by Marco Rolappe <m_...@web.de>.
hi richard,

I had a quick look at the xsl and it seems to me you should be learning some
XSL ;-) maybe go to http://www.w3schools.com and check out their XSL
tutorial. they even use some kind of cd database in that tutorial. may be
the right thing for you.

to the xsl: the <title> element was supposed to go into the <head>, the
<table>s and other stuff belong to the body (w3schools also has an html
tutorial and tag reference).

I haven't yet worked with the sql transformer, only with the esql logicsheet
(which is supposed to be quite similar); that sql:* stuff doesn't like quite
right either.

> -----Ursprungliche Nachricht-----
> Von: cocoon-users-return-47760-m_rolappe=web.de@xml.apache.org
> [mailto:cocoon-users-return-47760-m_rolappe=web.de@xml.apache.org]Im
> Auftrag von Richard Cunliffe
> Gesendet: Donnerstag, 13. Marz 2003 17:19
> An: cocoon-users@xml.apache.org
> Betreff: RE: SQL and Stylesheets
>
>
>
>
> OK I have got it working!!
>
>
> But its not coming out in the correct table format, e.g.
>
> --------------------------------------------
> The result im getting is:
>
> ParachutesWhats The Story Morning Glory
> Coldplay
> Oasis
>
> --------------------------------------------
> The result I want:
>
> Coldplay   Parachutes
> Oasis      The Story Morning Glory
>
> --------------------------------------------
>
>
> I have attached my xsl, what can anyone suggest?
>
> Thanks,
>
> Richard.
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


RE: SQL and Stylesheets

Posted by Richard Cunliffe <ri...@cunliffe.net>.

OK I have got it working!!


But its not coming out in the correct table format, e.g.

--------------------------------------------
The result im getting is:

ParachutesWhats The Story Morning Glory
Coldplay
Oasis

--------------------------------------------
The result I want:

Coldplay   Parachutes
Oasis      The Story Morning Glory

--------------------------------------------


I have attached my xsl, what can anyone suggest?

Thanks,

Richard.



Re: SQL and Stylesheets

Posted by Scherler <th...@wyona.org>.
Richard Cunliffe wrote:

>Thorsten
>
>Ok, I when I looked at the book I thought I would take it back one step,
>for it to make more sense to me. Therefore I thought I would start off
>doing all the XPATHs together instead of separating it out and doing
>many more MATCHes. 
>
The disadvantage in doing so is that you can not really debug the code! :(
...and frankly speaking <xsl:apply-templates 
select="/document/sql:rowset/sql:row/sql:generalmusictitle"/> don't 
result in

doing all the XPATHs together it is only one match!

...and still you have a define a "match" within the <xsl:template>!

You want to apply a template that matches 
select="/document/sql:rowset/sql:row/sql:artistbandname"
<xsl:apply-templates 
select="/document/sql:rowset/sql:row/sql:artistbandname"/>
...but no where in your code s a <xsl:template 
match="/document/sql:rowset/sql:row/sql:artistbandname">

...please read the eMail I have send you!

>
>If you look on page 171 of the 'Cocoon Building applications' we can the
>result that the SQL transformer comes out with, we don't normally see
>this. Therefore I think I was calling templates that exist(although
>temporarily).
>
>Can you check I'm right?
>
You are wrong that is the whole point in it! You are not calling a 
template(<xsl:call-template>)! You want to apply a template 
(<xsl:apply-templates>)!
...but that is xsl stuff

...what comes out of a sql transformer is xml stuff! Node that you can 
match later on!

>
>I have got the results to come out correctly by just copying the book,
>
NO!

Ok, last time! Try:
    <map:pipeline>
        <map:match pattern="database.2test">
            <map:generate src="database.xml"/>
            <map:transform type="sql">
                <map:parameter name="use-connection" value="soundpool"/>
            </map:transform>
            <map:serialize type="xml"/>
        </map:match>
    </map:pipeline>

call it!
post the result! Otherwise neither you nor me know what is the real 
result of the transform! Or maybe there is NO result!

...by the way : your sitemap
            <map:transform type="sql">
                <map:parameter name="use-connection" value="soundpool"/>
            </map:transform>
and your xsl file:
<sql:use-connection>soundpool</sql:use-connection>

You should NOT  DO that! One time is enough!

>but as soon as I start adding things to the style sheet, things start to
>go wrong, that's why I thought I would set it up myself from start to
>gain a better understanding. 
>
>If I am calling the correct templates, can you see why it displays my
>XML document 3 times?
>
>If I'm wrong :-( about the templates on page 171, then tell me, and I
>will try and work from there example a bit more.
>
>  
>
That is just AN example NOT what is coming out for you!

>Thanks
>
>Richard
>
>By the way I have included my sitemap!
>
>
>  
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>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


RE: SQL and Stylesheets

Posted by Richard Cunliffe <ri...@cunliffe.net>.
Thorsten

Ok, I when I looked at the book I thought I would take it back one step,
for it to make more sense to me. Therefore I thought I would start off
doing all the XPATHs together instead of separating it out and doing
many more MATCHes. 

If you look on page 171 of the 'Cocoon Building applications' we can the
result that the SQL transformer comes out with, we don't normally see
this. Therefore I think I was calling templates that exist(although
temporarily).

Can you check I'm right?

I have got the results to come out correctly by just copying the book,
but as soon as I start adding things to the style sheet, things start to
go wrong, that's why I thought I would set it up myself from start to
gain a better understanding. 

If I am calling the correct templates, can you see why it displays my
XML document 3 times?

If I'm wrong :-( about the templates on page 171, then tell me, and I
will try and work from there example a bit more.


Thanks

Richard

By the way I have included my sitemap!



Re: SQL and Stylesheets

Posted by Scherler <th...@wyona.org>.
Hi Richard.
you are calling templates which are not there!
<xsl:apply-templates 
select="/document/sql:rowset/sql:row/sql:generalmusictitle"/>

The example from Cocoon: building XML applications - with some comments:
sqlexample.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<!--the root of the the sqlexample is "document" but could also be "/" 
that is actually the same (HERE)-->
<!--MAIN - TEMPLATE-->
<xsl:template match="document">
<html>
<head><title>test</title></head>
<body><table>
<!--Here we call a SUB-TEMPLATE. The result of that template will be 
parsed right here. We are looking for the following XPath 
(sql:rowset/sql:row):
<sql:rowset>
<sql:row>This node</sql:row>
</sql:rowset>
-->
<xsl:apply-templates select="sql:rowset/sql:row"/>
</table></body></html>
</xsl:template>
<!--/MAIN - TEMPLATE-->
<!--Sub1 - TEMPLATE: apply all the templates which are based within the 
<sql:row>This node</sql:row>
Did you notice that we match the row output and parse a xhtml-element 
<tr> for each matching <sql:row/>.
Without using <xsl:for-each/>.
-->
<xsl:template match="sql:row">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<!--/Sub1- TEMPLATE-->
<!--Sub2 - TEMPLATE-->
<!-- Here we know that the elements of the parent <sql:row/> are 
"sql:id|sql:name". | means or! Or lets say we just want them from the 
stream.-->
<xsl:template match="sql:id|sql:name">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<!--/Sub2 - TEMPLATE-->
</xsl:stylesheet>

Besides that it would be nice to see your sitemap.xmap and the result of 
the sql transformation of the database.xml <-Do you remember:
<map:pipeline>
<map:match pattern="database">
<map:generate src="database.xml"/>
<map:transform type="sql"/>
<!-- <map:transform src="databasepda.xsl"/>-->
<map:serialize/>
</map:match>
</map:pipeline>

King regards
Thorsten

Richard Cunliffe wrote:

> Thorsten and Marco,
>
> After reading the “Cocoon: Building XML Applications” and O’Reilly 
> “XSLT” I have written my own “tidy and simple” XSL style sheet J 
> (instead of using XML Spy). It’s giving results, but its not right.
>
> I have included the style sheet, the XML document, and a picture of 
> the results. I’m sure it’s nothing to serious. It may be something to 
> do with X-Paths but I cant be sure.
>
> Thanks,
>
> Richard.
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>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