hi list,

i have a "little problem" with the binding for the sourcegenerator. i need
to extend from another class. that works fine but wenn i add an attribute to
the node the attributes a marshalled as elements.

where did i make the error? we use the castor-0.9.5-xml.jar

schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="unqualified">
        <xs:element name="any-test">
                <xs:complexType>
                    <xs:sequence>
                    
                        <xs:element name="test-element" minOccurs="0">
                        <xs:complexType>
                                <xs:attribute name="an-attribute"
type="xs:string" use="optional"/>
                                <xs:attribute name="test-mich-doch-mal"
type="xs:string" use="optional"/>
                    </xs:complexType>
                        </xs:element>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
</xs:schema>

binding file:

<?xml version="1.0"?>
<cbf:binding xmlns:cbf="http://www.castor.org/SourceGenerator/Binding";
defaultBindingType="element">
    <cbf:elementBinding name="any-test">
        <java-class name="AnyTest" package="com.godyo.test.beans"
final="false" abstract="false" equals="false" bound="false">
            <extends>com.godyo.schichtbuch.beans.Envelope</extends>
        </java-class>
        
        <cbf:elementBinding name="test-element">
            <java-class name="AMTestElement" package="com.godyo.test.beans"
final="false" abstract="false" equals="false" bound="false"/>
            <cbf:attributeBinding name="an-attribute">
                <cbf:member name="testAttribute"
java-type="java.lang.String"/>
             </cbf:attributeBinding>
        </cbf:elementBinding>
    </cbf:elementBinding>
</cbf:binding> 

java:

        AnyTest test = new AnyTest();
        AMConfiguration conf = new AMConfiguration();
        AMTestElement tElem  = new AMTestElement();     
        
        tElem.setTestAttribute("an attribute");
        tElem.setTestMichDochMal("testMichDochMal");
                
        test.setAMTestElement(tElem);
        
        StringWriter out = new StringWriter();
        
        try{
                test.marshal(out);
        }
        catch(Exception e){
                
                e.printStackTrace();
                
        }

output:

<?xml version="1.0" encoding="UTF-8"?>
<anyTest>
    <AMTestElement>
        <valid>true</valid>
        <testAttribute>an attribute</testAttribute>
        <testMichDochMal>testMichDochMal</testMichDochMal>
    </AMTestElement>
    <valid>true</valid>
</anyTest>

The testAttribute ant the testMichDochMal elements has to be attributes of
AMTestElement.

Thanks for your help

cham



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to