users@jaxb.java.net

RE: External customize

From: Lulseged Zerfu <lulseged.zerfu_at_ericsson.com>
Date: Mon, 16 Nov 2009 14:01:10 +0100

Hi
 
 I also have one element that exists in 5 places in the XSD file. How
can I customize it so that I need only one customization instead of 5
distinct customization in the binding.xjb file.
 
 This customization will create adapters for each, which is
Adapter1.java, Adapter2.java, Adapter3.java, Adapter4.java,
Adapter5.java which are all same.
 
  

package com.ericsson.ims.pgm.app.config.model;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class Adapter1 extends XmlAdapter<String, Boolean>
{
    public Boolean unmarshal(String value)
    {
        return
(com.ericsson.ims.pgm.config.converter.TextualNumericConverter.parseBool
ean(value));
    }


    public String marshal(Boolean value)
    {
        return
(com.ericsson.ims.pgm.config.converter.TextualNumericConverter.printBool
ean(value));
    }
}

How can I create one adapter (for ex. boolean converter as above) and
use all over where I need to convert boolean data types?
 
Lulseged

________________________________

From: Lulseged Zerfu [mailto:lulseged.zerfu_at_ericsson.com]
Sent: den 16 november 2009 13:40
To: users_at_jaxb.dev.java.net
Subject: External customize



Hi

 I am trying to external customize so that it out puts boolean types
with 0 and 1 instead of ture or false.

 I am able to customoize some but unabl eto customize

.
.
.
.
 <xs:attribute name="preInstantiable" type="xs:boolean" use="required"
/> (line 437 in AppConfig.xsd)
.
.
.
.


My binding.xjb file looks like this:

        <!-- preInstantiable -->
        <jxb:bindings
node="//xs:complexType[@name='componentAttributesT']//xs:element[@name='
proxiedComponent']">
                <jxb:bindings
node="//xs:attribute[@name='preInstantiable']">
                        <jxb:javaType name="boolean"
 
parseMethod="com.ericsson.ims.pgm.config.converter.TextualNumericConvert
er.parseBoolean"

 
printMethod="com.ericsson.ims.pgm.config.converter.TextualNumericConvert
er.printBoolean">

                        </jxb:javaType>
                    </jxb:bindings>
        </jxb:bindings>

I was not able to compile with this customization. I guess I am not
getting the correct xpath.

Any suggestion?


<<AppConfig.xsd>>