This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 92150 - Attribute naming incorrect
Summary: Attribute naming incorrect
Status: RESOLVED WONTFIX
Alias: None
Product: ide
Classification: Unclassified
Component: Schema2Beans (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: schema2beans-issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-09 18:07 UTC by maxnitribitt
Modified: 2011-09-13 14:28 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description maxnitribitt 2007-01-09 18:07:33 UTC
When an Attribute name collides with the Method name of the BaseBean class (
e.g. Attribute name in dtd = "class"), setters and getters of generated beans
get a numerical value attached (getClass2, setClass2). Fine so far, but when you
try to add those properties, you will get an Exception:

I have created a minimal example. Create the binding classes for this dtd:
8<-----------example dtd----------------->8
<?xml version="1.0" encoding="UTF-8"?>

<!ELEMENT root (parameter)>
<!ATTLIST root version CDATA #REQUIRED>
<!ELEMENT parameter >
<!ATTLIST parameter
	class NMTOKEN "java.lang.String"
>
8<---------------------------->8

This will result in two classes Root and Parameter (I can supply those when
needed, but they are a bit long to paste them here). 


add a simple test.xml file
8<-----------test.xml--------->8
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Base PUBLIC '//newemptyDTD//DTD Report Design//EN' ''>
<root>
    <parameter class="java.lang.String"/>
</root>
8<---------------------------->8

create Unit Test:
8<---------------------------->8
package test;

import junit.framework.*;
import org.w3c.dom.*;
import org.netbeans.modules.schema2beans.*;
import java.beans.*;
import java.util.*;
import java.io.*;

public class RootTest extends TestCase {
    
    public RootTest(String testName) {
        super(testName);
    }

    public void testSetParameter() {
        System.out.println("setParameter");
        
        Parameter value = null;
        Root instance;
        try {
            instance =
Root.createGraph(Root.class.getClassLoader().getResourceAsStream("test/test.xml"));
            instance.setParameter((Parameter) instance.getParameter().clone());
        } catch (Schema2BeansException ex) {
            ex.printStackTrace();
        }
    }
}

8<---------------------------->8


expected behaviour:
Test runs through without errors

observed Behaviour:
Test fails with this stacktrace:
8<-------------------------------------------------------->8

------------- Standard Output ---------------
setParameter
------------- ---------------- ---------------
Testcase: testSetParameter(test.RootTest):	Caused an ERROR
Unknown attribute Class2 for property Parameter
java.lang.IllegalArgumentException: Unknown attribute Class2 for property Parameter
        at
org.netbeans.modules.schema2beans.BeanProp.getAttrProp(BeanProp.java:1225)
        at
org.netbeans.modules.schema2beans.BeanProp.getAttrProp(BeanProp.java:1236)
        at
org.netbeans.modules.schema2beans.BeanProp.setAttributeValue(BeanProp.java:1243)
        at org.netbeans.modules.schema2beans.BeanProp.setElement(BeanProp.java:1054)
        at org.netbeans.modules.schema2beans.BeanProp.setValue(BeanProp.java:787)
        at org.netbeans.modules.schema2beans.BaseBean.setValue(BaseBean.java:444)
        at org.netbeans.modules.schema2beans.BaseBean.setValue(BaseBean.java:433)
        at test.Root.setParameter(Root.java:107)
        at test.RootTest.testSetParameter(RootTest.java:35)


Test test.RootTest FAILED
C:\Documents and
Settings\Administrator\netbeans_projects\JavaLibrary4\nbproject\build-impl.xml:475:
Some tests failed; see details above.
BUILD FAILED (total time: 0 seconds)
8<-------------------------------------------------------->8

Hints:
If you change the Attribute creation in Root, it works:
8<----------------------Fails---------------------------------->8
this.createAttribute(PARAMETER, "class", "Class", 
						AttrProp.NMTOKEN,
						null, "java.lang.String");
8<-------------------------------------------------------->8

8<----------------------Passes---------------------------------->8
this.createAttribute(PARAMETER, "class", "Class2", 
						AttrProp.NMTOKEN,
						null, "java.lang.String");
8<-------------------------------------------------------->8
Comment 1 Erno Mononen 2007-02-06 12:20:12 UTC
Hi Toni, many thanks for the detailed bug report and the test case. I'll try to 
fix this for 6.0 M8, so I'm setting TM accordingly and lowering this to P2 as 
per our bug priority guidelines.
Comment 2 Jiri Prox 2007-09-17 21:33:22 UTC
Obsolete milestone, please reevaluate
Comment 3 Marian Mirilovic 2009-02-20 18:01:15 UTC
update no67 keyword
Comment 4 Petr Jiricka 2011-09-13 14:28:30 UTC
As this bug does not affect the NetBeans IDE and the Oracle NetBeans team is not planning to address it, I am closing this as WONTFIX. Anyone who would like to take this on and contribute the solution, please reopen and reassign to yourself.