commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Chancogne <da...@o-ms.com>
Subject [Betwixt] Betwixt and Log4j
Date Fri, 07 Nov 2003 22:22:54 GMT

Hello,

My setup:
   Java: Sun SDK, java version "1.4.2-beta"
   Betwixt: 1.0 apha1
   Digester: 1.5
   Log4j: 1.2.8


The code attached reproduces the problem.

Running the attached code produce the expected result, i.e.
the outside tag is renamed to 'product' and the 'archives'
field is ignore:

<product>
  <id>1</id>
  <name>Productname</name>
</product>


Turning debugging on to 'DEBUG' level in log4j.properties
generates the following output (as well has the
stack exception thrown by XMLIntrospectorHelper):
 
<ProductXMLTest>
  <archives>
    <archive>
      <id>2</id>
      <name>ArchiveName</name>
    </archive>
  </archives>
  <id>1</id>
  <name>Productname</name>
</ProductXMLTest>


Obviously this is not the right output (e.g. 'archives'
should be hidden). This is probably due to the exception
thrown by Betwixt. Am I missing something?

--
/David

--------8<-------- CUT HERE -----------------8<-------------
File: ProductXMLTest.java

import java.util.*;

import java.beans.*;
import java.io.*;
import java.util.*;
import org.xml.sax.*;

import org.apache.commons.betwixt.io.*;
import org.apache.commons.betwixt.strategy.*;

public class ProductXMLTest {
    
    private int id;
    private String name;
    private List archives;
    
    
    /** Creates a new instance of ProductXMLTest */
    public ProductXMLTest(int id, String name) {
        this.id = id;
        this.name = name;
        this.archives = new ArrayList();
    }
   
    
    /** Getter for property id.
     * @return Value of property id.
     *
     */
    public int getId() {
        return id;
    }
    
    /** Setter for property id.
     * @param id New value of property id.
     *
     */
    public void setId(int id) {
        this.id = id;
    }
    
    /** Getter for property name.
     * @return Value of property name.
     *
     */
    public String getName() {
        return name;
    }
    
    /** Setter for property name.
     * @param name New value of property name.
     *
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /** Getter for property archives.
     * @return Value of property archives.
     *
     */
    public List getArchives() {
        return archives;
    }
    
    /** Setter for property archives.
     * @param archives New value of property archives.
     *
     */
    public void addArchive(ArchiveXMLTest archive) {
        this.archives.add(archive);
    }
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    
        ProductXMLTest p = new ProductXMLTest(1, "Productname");
        p.addArchive(new ArchiveXMLTest(2, "ArchiveName"));
        
        String xml = null;
        try {
            StringWriter w = new StringWriter();
            BeanWriter beanWriter  = new BeanWriter(w);
            beanWriter.enablePrettyPrint();
            beanWriter.setWriteIDs(false);
            beanWriter.write(p);
            System.out.println(w.toString());
            
        }
       catch (Exception e) {
           e.printStackTrace();
        }
        
        
    }
    
    
}
--------8<-------- CUT HERE -----------------8<-------------
File: ArchiveXMLTest.java

public class ArchiveXMLTest {
    
    private String name;
    private int id;
    
    /** Creates a new instance of ArchiveXMLTest */
    public ArchiveXMLTest(int id, String name) {
        this.id = id;
        this.name = name;
    }
    
    /** Getter for property name.
     * @return Value of property name.
     *
     */
    public String getName() {
        return name;
    }
    
    /** Setter for property name.
     * @param name New value of property name.
     *
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /** Getter for property id.
     * @return Value of property id.
     *
     */
    public int getId() {
        return id;
    }
    
    /** Setter for property id.
     * @param id New value of property id.
     *
     */
    public void setId(int id) {
        this.id = id;
    }
    
}
--------8<-------- CUT HERE -----------------8<-------------
File: ProductXMLText.betwixt

<?xml version='1.0' encoding='UTF-8' ?>
<info primitiveTypes='element'>
<hide property='archives'/>
    <element name='product'>
        <addDefaults/>
    </element>
</info>
--------8<-------- CUT HERE -----------------8<-------------
File: log4j.properties

# 
# Log4J properties file.

# Set root logger level to FATAL and its only appender to console.
log4j.rootLogger=FATAL, console

# console is set to be a ConsoleAppender.
log4j.appender.console=org.apache.log4j.ConsoleAppender

# console uses PatternLayout.
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x -
%m%n
--------8<-------- CUT HERE -----------------8<--------------




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message