users@jaxb.java.net

Re: XJC. How to preserve case?

From: Anth <anth_at_tut.by>
Date: Fri, 27 May 2011 15:26:58 +0300

Unfortunately this doesn't work because variables will be upper-cased
after XSLT transformation.
So question remains.


>If it is really every element name then a relatively simple XSLT can be
>used to insert customizations into the XML Schema files.
>-W

On 25 May 2011 09:58, Pechinsky Anton <anth_at_tut.by> wrote:

    Hi all,

    I can't instruct XJC to preserve character case.
    I'm integrating with .NET web service and case is important for my project.

    For example if element is declared as Account in schema then I'd like
    to see exactly the same property in target class:
    xsd:
    <element name="Account" type="xs:string"/>
    java:
    String Account;

    I need to preserve case globally (for every identifier) so I can't
    manually specify each property in customization file.


    The problem is that reference implementation uses concrete name
    converter class after applying user provided name converter:
    com.sun.tools.xjc.model.CPropertyInfo#CPropertyInfo(String name,
    boolean collection, XSComponent source,
                               CCustomizations customizations, Locator
locator) {
    ...
    // next line causes the problem
    String n = NameConverter.standard.toVariableName(name);
    ...

    I've tried:
    - Custom plugin with custom name converter. Unfortunately name
    converter doesn't help because I can change everything except first
    char. This is because of above problem (concrete class usage)

    - Custom plugin which modifies generated mode. No idea how to obtain
    original field name

       public boolean run(Outline model, Options opt, ErrorHandler
    errorHandler) throws SAXException {

           for (ClassOutline classOutline : model.getClasses()) {
               Map<String, JFieldVar> generatedFields =
    classOutline.implClass.fields();
               for (JFieldVar field : generatedFields.values()) {
                   // at this moment field's public name has first char
    in upper case while private name in lower case despite how it was
    declared in schema :(
                   // so I need to get original field name
                   Sting originalFieldName = ???????
                   field.name(originalFieldName);
               }

    Help me please.

    Thanks