Hi, i'm having some doubts about the way the sax events are created in a
transformer in java...
I'm asking this question because i wrote a transformer in java, but i want
to apply another transformer in xsl after that and i can't access the
attributes in the nodes...
this is the code of the transformer i wrote..
package pt.laseeb.dae.transformer;
/*
* File: daeTransformer.java
*
* Project: Design Automatico e Evolutivo
*
* Authors: Paulo Srgio Silva Paixao- [EMAIL PROTECTED]
* Miguel Angelo Rodrigues Carvalho - [EMAIL PROTECTED]
*
* Date: 4/Ago/2003
*
* Trabalho de Fim de Curso - Design Automtico e Evolutivo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
import org.apache.cocoon.transformation.AbstractTransformer;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.ProcessingException;
import org.apache.avalon.framework.parameters.Parameters;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
import java.util.Map;
import java.io.IOException;
public class daeTransformer extends AbstractTransformer
{
public static final String DOCUMENT_ELEMENT = document;
public static final String CONTENT_ELEMENT = contents;
public static final String ARTICLE_ELEMENT = article;
public static final String ARTICLE_TITLE_ELEMENT = title;
public static final String ARTICLE_TEXT_ELEMENT = text;
public static final String ARTICLE_IMAGE_ELEMENT = image;
protected static final int MODE_NONE = 0;
protected static final int MODE_ARTICLE = 1;
protected static final int MODE_TITLE = 2;
protected static final int MODE_TEXT = 3;
protected static final int MODE_IMAGE = 4;
protected int mode;
protected StringBuffer articleText;
protected StringBuffer articleTitle;
protected StringBuffer articleImage;
protected Attributes attr;
public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
throws ProcessingException, SAXException, IOException
{
this.mode = MODE_NONE;
this.articleImage = new StringBuffer();
this.articleTitle = new StringBuffer();
this.articleText = new StringBuffer();
}
public void startElement(String namespaceURI, String localName, String
qName,
Attributes attributes) throws SAXException
{
AttributesImpl newAttr = new AttributesImpl();
if (localName.equals(DOCUMENT_ELEMENT) == true)
{
super.startElement(, localName , qName, newAttr);
}
else if (localName.equals(CONTENT_ELEMENT) == true)
{
super.startElement(, localName , qName, newAttr);
}
else if (localName.equals(ARTICLE_ELEMENT) == true)
{
newAttr.addAttribute(, localName, layouttype, , 2);
newAttr.addAttribute(, localName, xpos, , 5);
newAttr.addAttribute(, localName, ypos, , 7);
newAttr.addAttribute(, localName, border, , dotted);
super.startElement(, localName, qName, newAttr);
}
else if (localName.equals(ARTICLE_TITLE_ELEMENT) == true)
{
this.mode = MODE_TITLE;
super.startElement(, localName, qName, newAttr);
}
else if (localName.equals(ARTICLE_TEXT_ELEMENT) == true)
{
this.mode = MODE_TEXT;
super.startElement(, localName, qName, attributes);
}
else if (localName.equals(ARTICLE_IMAGE_ELEMENT) == true)
{
this.mode = MODE_IMAGE;
super.startElement(, localName, qName, attributes);
}
else
{
throw new SAXException(Unknown start element +
localName);
}
}
public void characters(char[] buffer, int start, int length)
throws SAXException
{
switch (this.mode)
{
case MODE_NONE : super.characters(buffer, start, length);
break;
case MODE_TITLE : this.articleTitle.append(buffer, start,
length);
break;
case MODE_TEXT : this.articleText.append(buffer, start,