Hi, thanks for your contributions, the <util:include-expr/> tip worked
great.. :)
And now i'm having a little doubt,
i want to create a Transformer that takes the XML from my generator and
changes some attributes of the tags existing in it, and
the package org.xml.sax.Attributes only has methods like getValue,
getQname... and i was wondering how could i get the sax events from one
Generator and then change or introduce attributes to the nodes...
it could be like...
public void startElement(String namespaceURI, String localName, String
qName,
Attributes attributes) throws SAXException
{
Attributes newAttribute;
//fill in the attribute, accessing a MySql Data Base
super.startElement(NAMESPACE, , , newAttribute);
}
If anyone has any ideas it would be great :)
thanks in advance
Miguel Carvalho
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: quinta-feira, 31 de Julho de 2003 13:25
To: [EMAIL PROTECTED]
Subject: RE: problem applying a generator and transformer
Hi Joerg,
<xsp:expr/> will take its content and add it to the output as a string -
that's your problem.
Try one of the xsp-util functions to include you data as XML (I think it's
<util:include-expr/>, but please check)
/Adrian
> -----Original Message-----
> From: Joerg Heinicke [mailto:[EMAIL PROTECTED]
> Sent: Thursday 31 July 2003 14:21
> To: [EMAIL PROTECTED]
> Subject: Re: problem applying a generator and transformer
>
>
> Miguel Carvalho wrote:
>
> > 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>
>
> Here you have <document/> as root element.
>
> >
> --------------------------------------------------------------
> --------------
> > ----------
> >
> > 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>
>
> Here you match on <contents/> as root element. Try to remove the line
> <xsl:output/> or at least make it correct: you don't want
> html as result
> of this transformation. Furthermore does the XSP code return XML or a
> string of the database content, that should be XML. Fix it
> there. Don't
> use disable-output-escaping.
>
> Joerg
>
> >
> --------------------------------------------------------------
> --------------
> > ------
> >
> > and the problem is that what i get in the view source of
> the browser is
> > something like,
> >
> > <?xml version="1.0"?>
> > <article id="1" rating="2" sectionid="1"
> > xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/daeDocuments"
> > src:key="1">
> > <title>Titulo com rating 2</title>
> > <text>Texto</text>
> > </article><?xml version="1.0"?>
> > <article id="2" rating="1" sectionid="1"
> > xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/daeDocuments"
> > src:key="2">
> > <title>Titulo do artigo
> com rating igual a 1</title>
> > <text>texto do artigo com
> rating igual a 1</text>
> > <image>img1.jpg</image>
> > </article><?xml version="1.0"?>
> > <article id="3" rating="2" sectionid="1"
> > xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/daeDocuments"
> > src:key="3">
> > <title>Titulo do artigo
> com rating igual a 2</title>
> > <text>texto do artigo com
> rating igual a 2</text>
> > <image>img1.jpg</image>
> > </article><?xml version="1.0"?>
> > <article id="4" rating="2" sectionid="1"
> > xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/daeDocuments"
> > src:key="4">
> > <title>Titulo do artigo
> com rating igual a 2</title>
> > <text>texto do artigo com
> rating igual a 2</text>
> > <image>img1.jpg</image>
> > </article>
> >
> > 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
>
Any e-mail message from the European Central Bank (ECB) is sent in good
faith but shall neither be binding nor construed as constituting a
commitment by the ECB except where provided for in a written agreement.
This e-mail is intended only for the use of the recipient(s) named above.
Any unauthorised disclosure, use or dissemination, either in whole or in
part, is prohibited.
If you have received this e-mail in error, please notify the sender
immediately via e-mail and delete this e-mail from your system.