cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Miguel Carvalho" <m...@rnl.ist.utl.pt>
Subject problem applying a generator and transformer
Date Wed, 30 Jul 2003 17:05:39 GMT
Hi, im havinf some trouble creating a Generator in XSP and after that
aplying a transformer in XSL, the problem is, that i am not able to parse
the XML returned by the generator with the transformer.

----------------------------------------------------------------------------
----------
Generator code

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">

    <xsp:structure>
        <xsp:include>pt.laseeb.dae.xmlDbApi.daeXmlDbApi</xsp:include>
        <xsp:include>org.xmldb.api.base.ResourceIterator</xsp:include>
        <xsp:include>org.xmldb.api.base.Resource</xsp:include>
        <xsp:include>org.xmldb.api.base.XMLDBException</xsp:include>
    </xsp:structure>

 <document>
        <xsp:logic>
            try
            {
                Resource res = null;
                String resStr = null;
                daeXmlDbApi daeApi = new daeXmlDbApi();
                ResourceIterator results;
                results = daeApi.getArticleSection("1").getIterator();
                while (results.hasMoreResources())
                {
                    res = results.nextResource();
                    <contents><xsp:expr>
(String)res.getContent()</xsp:expr></contents>
                }
            }
            catch(Exception e)
            {
            }
        </xsp:logic>

 </document>
</xsp:page>

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

daeAPI is a API created by me to access to an XINDICE database that contains
XML following the current syntax:

<article>
  <title></title>
  <text></text>
  <image></image>
</article>

----------------------------------------------------------------------------
----------
Transformer code

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output indent="no" method="html" omit-xml-declaration = "yes" />


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

<xsl:template match="/contents">

    <xsl:for-each select = "/article" >

                    <titulo><xsl:value-of disable-output-escaping = "yes"
select = "/title" /></titulo>
                    <imagem><xsl:value-of disable-output-escaping = "yes"
select = "/image" /></imagem>

   </xsl:for-each>

</xsl:template>

</xsl:stylesheet>

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

and the problem is that what i get in the view source of the browser is
something like,

&lt;?xml version="1.0"?&gt;
&lt;article id="1" rating="2" sectionid="1"
xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/daeDocuments"
src:key="1"&gt;
	&lt;title&gt;Titulo com rating 2&lt;/title&gt;
    &lt;text&gt;Texto&lt;/text&gt;
&lt;/article&gt;&lt;?xml version="1.0"?&gt;
&lt;article id="2" rating="1" sectionid="1"
xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/daeDocuments"
src:key="2"&gt;
				&lt;title&gt;Titulo do artigo com rating igual a 1&lt;/title&gt;
				&lt;text&gt;texto do artigo com rating igual a 1&lt;/text&gt;
				&lt;image&gt;img1.jpg&lt;/image&gt;
&lt;/article&gt;&lt;?xml version="1.0"?&gt;
&lt;article id="3" rating="2" sectionid="1"
xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/daeDocuments"
src:key="3"&gt;
				&lt;title&gt;Titulo do artigo com rating igual a 2&lt;/title&gt;
				&lt;text&gt;texto do artigo com rating igual a 2&lt;/text&gt;
				&lt;image&gt;img1.jpg&lt;/image&gt;
			&lt;/article&gt;&lt;?xml version="1.0"?&gt;
&lt;article id="4" rating="2" sectionid="1"
xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/daeDocuments"
src:key="4"&gt;
				&lt;title&gt;Titulo do artigo com rating igual a 2&lt;/title&gt;
				&lt;text&gt;texto do artigo com rating igual a 2&lt;/text&gt;
				&lt;image&gt;img1.jpg&lt;/image&gt;
			&lt;/article&gt;

and i con't parse it in my transformer.

If anyone could give a look at the code and see what i am doing wrong i
would apreciate it :)

Thanks id advance
Miguel Carvalho



Mime
View raw message