You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Kazi the P i R @ t {-" <ka...@ewarna.com> on 2001/08/01 05:47:46 UTC

Re: xsl transfromation.

well, there are three children of the 'guide' root. And i want to have them
all printed out in html along with the rest of their children. I have
restructured my xsl (included below). now what happens is the values between
the tags are printed, the output is as follows:
---output of
guide.xml-------------------------------------------------------------------
---
|    type="text/html"
|
|
|
|    0left
|
| (a bullet appears in this portion, i suspect because of my
<ul><li></li></ul> eleements)      |
|    for more information contact the person below:
|
----------------------------------------------------------------------------
----------------

My new xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3c.org/1999/XSL/Transform"
version="1.0">

<xsl:template match="guide">
 <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
 <html>
  <head>
   <title>A Guide to the Search Utility</title>
   </head>
    <body style="font-family: Arial;">
      <table width="90%" border="0" align="center" valign="middle">
      <tr>
        <td>
           <xsl:apply-templates/>
        </td>
      </tr>
      </table>
    </body>
 </html>
</xsl:template>

<xsl:template match="buttons">
  <p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="search|view|sort|warning|respond">
  <xsl:element name="img">
      <xsl:attribute name="border">0</xsl:attribute>
      <xsl:attribute name="align">left</xsl:attribute>
   <xsl:attribute name="src"><xsl:copy-of select="image"/></xsl:attribute>
  </xsl:element>
  <xsl:vlaue-of select="text"/>
</xsl:template>

<xsl:template match="how-to">
    <p><xsl:apply-templates select="description"/></p>
</xsl:template>

<xsl:template match="how-to">
<p>
<xsl:apply-templates select="description"/>
</p>
</xsl:template>

<xsl:template match="description">
 <ul>
     <xsl:for-each select=".">
         <li>
           <xsl:apply-templates select="text()|description[subpoint]"/>
         </li>
     </xsl:for-each>
 </ul>
</xsl:template>

<xsl:template match="text()">
  <xsl:value-of select="text()"/>
</xsl:template>

<xsl:template match="description[subpoint]">
    <br/>
        <xsl:value-of select="."/>
</xsl:template>

<xsl:template match="contact">
    <p><xsl:text>for more information contact the person
below:</xsl:text></p>
    <p><b><xsl:value-of select="name"/></b></p>
    <p><b><xsl:value-of select="email"/></b></p>
</xsl:template>

</xsl:stylesheet>

My reference:
-----------------
-XML Developer's Guide : Fabio Arciniegas (Osborne. McGraw Hill)
-Introduction to Cocoon, XML XSL by Olivier Eymere
                http://www.devshed.com/Client_Side/XML/INTCXX/page7.html
-http://www.cs.rpi.edu/~puninj/XMLJ/classes/class7/Overview-1.html

> > System: Win 98
> > Servlet Engine: Tomcat (standalone) 3.2.1
> > XML Framework: Cocoon 1.8.2

Helplessly wAiting~
 -Kazi-

----- Original Message -----
From: "JEULIN Olivier" <ol...@xml-ais.com>
To: <co...@xml.apache.org>
Sent: Tuesday, July 31, 2001 8:24 PM
Subject: RE: xsl transfromation.


> In this case, there's a problem with the body tag, opened in a template
and
> closed in another one.
> There are also 3 (!) templates matching "guide"... It's useless, only the
> 1st or last one will be used (I don't remember if this is in the spec or
> XSLT engine dependant)
>
> I would advise you to use identation when writing templates. This kind of
> error will be easier to track... (see discussion about xsl editing;
> personnaly, I'm using cooktop -- it can also validate you stylesheets)
>
> Also, don't expect too much of cocoon's error message: they're quite
useless
> as you can see here. Use a xml/xsl validator to find the right bug.
>
> Olivier
>
> > -----Message d'origine-----
> > De : Kazi the P i R @ t {- [mailto:kazi@ewarna.com]
> > Envoyé : mardi 31 juillet 2001 06:24
> > À : cocoon-users@xml.apache.org
> > Cc : general@xml.apache.org; Lim Huat Heng
> > Objet : xsl transfromation.
> >
> >
> > Trouble:
> > I was just trying out an xsl transformaiton of a static xml page i
> > created... but then when i called the page from the browser
> > the following
> > error comes up -
> >
> > 'org.apache.cocoon.processor.ProcessorException: Could not associate
> > stylesheet to document:  error reading
> > C:\Tomcat\webapps\cocoon\newProd\guide-html.xsl:
> > org.xml.sax.SAXParseException: The element type "xsl:template" must be
> > terminated by the matching end-tag "</xsl:template>".'
> >
> > I just checked the <xsl:template.. issue it mentions.. and it
> > appears that
> > all the tags were closed properly.
> >
> > The XSL file -
> >
> > <?xml version="1.0" ?>
> > <xsl:stylesheet xmlns:xsl="http://www.w3c.org/1999/XSL/Transform"
> > version="1.0">
> > <html>
> > <head>
> > <title>A Guide to the Search Utility</title>
> > </head>
> > <body>
> > <xsl:template match="guide">
> > <xsl:processing-instruction
> > name="cocoon-format">type="text/html"</xsl:processing-instruction>
> > <table width="100%" border="0">
> > <tr>
> > <td>
> > <xsl:apply-template select="buttons"/>
> > </td>
> > </tr>
> > </table>
> > </xsl:template>
> > <xsl:template match="guide">
> > <table width="100%" border="0">
> > <tr>
> > <td>
> > <xsl:apply-template select="how-to"/>
> > </td>
> > </tr>
> > </table>
> > </xsl:template>
> > <xsl:template match="guide">
> > <table width="60%" border="0" align="center" valign="middle">
> > <tr>
> > <td>
> > <xsl:apply-template select="contact"/>
> > </td>
> > </tr></table>
> > </body>
> > </html>
> > </xsl:template>
> > <xsl:template match="buttons">
> > <xsl:for-each select="buttons[*]"><p><img border="0" align="left"
> > valign="middle">
> > <xsl:attribute name="src"><xsl:value-of
> > select="image"/></xsl:attribute>
> > </img>
> > <xsl:vlaue-of select="text"/></p>
> > </xsl:for-each>
> > </xsl:template>
> > <xsl:template match="how-to">
> > <p>
> > <xsl:apply-template select="description"/>
> > </p>
> > </xsl:template>
> > <xsl:template match="description">
> > <ol>
> > <xsl:for-each select=".">
> > <li>
> > <xsl:value-of select="."/>
> > <xsl:apply-template select="sub-point"/>
> > </li>
> > </xsl:for-each>
> > </ol>
> > </xsl:template>
> > <xsl:template match="subpoint">
> > <ul>
> > <xsl:value-of select="."/>
> > </ul>
> > </xsl:template>
> > <xsl:template match="contact">
> > <p><xsl:text>form more information contact the person
> > below:</xsl:text></p>
> > <p>
> > <b><xsl:value-of select="name"/></b>
> > </p>
> > <p>
> > <b><xsl:value-of select="email"/></b>
> > </p>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> > My DTD -
> >
> > <!ELEMENT guide (buttons,how-to,contact)>
> > <!ELEMENT buttons (search,view,sort,warning,respond)>
> > <!ELEMENT how-to (description+)>
> > <!ELEMENT contact (name,email)>
> > <!ELEMENT search (text, image)>
> > <!ELEMENT view (text,image)>
> > <!ELEMENT sort (text,image)>
> > <!ELEMENT warning (text,image)>
> > <!ELEMENT respond (text,image)>
> > <!ELEMENT text (#PCDATA)>
> > <!ELEMENT image (#PCDATA)>
> > <!ELEMENT description (#PCDATA|sub-point)*>
> > <!ELEMENT sub-point (#PCDATA)>
> > <!ELEMENT name (#PCDATA)>
> > <!ELEMENT email (#PCDATA)>
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@xml.apache.org>
> >
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>


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

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