users@jaxb.java.net

Re: XJC. How to preserve case?

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Fri, 27 May 2011 15:36:12 +0200

I think you misunderstood me.

I was trying to suggest a way of creating a customization. Rather than
manually specifying the properties in a customization file, use an XSLT to
process the XML schema file and derive the external bindings from that (or
insert the bindings inline into the schema).
-W

On 27 May 2011 14:26, Anth <anth_at_tut.by> wrote:

> 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
>