You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jerry Wang <sk...@gmail.com> on 2010/01/20 16:26:24 UTC

question on code generation with regard to non-alphabetic character in xml element name

I am using xmlbean to generate code from wsdl, the issue I am facing is that
names of some xml elements have special character like "_"(for example
<first_name>).
and the getter generated is getFirstName().
can I somehow force the method generated to have exact xml tag name like
getFirst_Name()?
I really do not want to do mapping,just too much over head.
Thanks
Jerry

Re: question on code generation with regard to non-alphabetic character in xml element name

Posted by Jerry Wang <sk...@gmail.com>.
I am still facing one issue on getting actual element names, this time it is
about a particular element name(<id1>).
1. method generated by xmlbean from wsdl
    public org.apache.xmlbeans.XmlString xgetId1()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlString target = null;
            target =
(org.apache.xmlbeans.XmlString)get_store().find_element_user(ID1$10, 0);
            return target;
        }
    }
2.code to get element name
 Line 1:   XmlString xobj = xparent.xgetId1();
Line 2:  TypeStore _textsource =  xobj .get_store();
 Line 3:  SchemaField field = _textsource.get_schema_field();
 Line 4:  String ElementName = field .getName().getLocalPart();

3.some how the field returned from line 4 is null on element<id1> while same
code works perfectly for any other elements
     <id1>600000000005</id1>
    <player_name>John</player_name>
    <timestamp>20100101111111</timestamp>

can someone help or suggest a different way to get the element name?

Thanks
Jerry


On Wed, Jan 20, 2010 at 3:29 PM, Jerry Wang <sk...@gmail.com> wrote:

> you are right, what I am looking for is to use reflection to create (xml
> element)name/value pairs using reflection.
> from the XmlStringImpl returned from xget(), I am able to get the element
> names for most of the regular ones, still working on how to get names for
> those complex types.
> Cheers
> Jerry
>
>
>
> On Wed, Jan 20, 2010 at 2:20 PM, Jacob Danner <ja...@gmail.com>wrote:
>
>> So you would use reflection or something like it to infer the name?
>> Seems like you could get this 'actual element name' information from
>> the schematypesystem apis without too much hassle.
>> -jacobd
>>
>> On Wed, Jan 20, 2010 at 10:29 AM, Jerry Wang <sk...@gmail.com>
>> wrote:
>> > just want to get original element names from generated classes, so those
>> > names can be passed onto other components.
>> >
>> > On Wed, Jan 20, 2010 at 12:50 PM, Gillen, Paul <pa...@nscorp.com>
>> > wrote:
>> >>
>> >> Pardon the impertinence, but why?
>> >>
>> >>
>> >>
>> >> ________________________________
>> >>
>> >> Paul
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> ________________________________
>> >>
>> >> From: Jerry Wang [mailto:skidoojava@gmail.com]
>> >> Sent: Wednesday, January 20, 2010 10:26 AM
>> >> To: user@xmlbeans.apache.org
>> >> Subject: question on code generation with regard to non-alphabetic
>> >> character in xml element name
>> >>
>> >>
>> >>
>> >> I am using xmlbean to generate code from wsdl, the issue I am facing is
>> >> that names of some xml elements have special character like "_"(for
>> example
>> >> <first_name>).
>> >> and the getter generated is getFirstName().
>> >> can I somehow force the method generated to have exact xml tag name
>> like
>> >> getFirst_Name()?
>> >> I really do not want to do mapping,just too much over head.
>> >> Thanks
>> >> Jerry
>> >>
>> >>
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>
>>
>

Re: question on code generation with regard to non-alphabetic character in xml element name

Posted by Jerry Wang <sk...@gmail.com>.
you are right, what I am looking for is to use reflection to create (xml
element)name/value pairs using reflection.
from the XmlStringImpl returned from xget(), I am able to get the element
names for most of the regular ones, still working on how to get names for
those complex types.
Cheers
Jerry


On Wed, Jan 20, 2010 at 2:20 PM, Jacob Danner <ja...@gmail.com>wrote:

> So you would use reflection or something like it to infer the name?
> Seems like you could get this 'actual element name' information from
> the schematypesystem apis without too much hassle.
> -jacobd
>
> On Wed, Jan 20, 2010 at 10:29 AM, Jerry Wang <sk...@gmail.com> wrote:
> > just want to get original element names from generated classes, so those
> > names can be passed onto other components.
> >
> > On Wed, Jan 20, 2010 at 12:50 PM, Gillen, Paul <pa...@nscorp.com>
> > wrote:
> >>
> >> Pardon the impertinence, but why?
> >>
> >>
> >>
> >> ________________________________
> >>
> >> Paul
> >>
> >>
> >>
> >>
> >>
> >> ________________________________
> >>
> >> From: Jerry Wang [mailto:skidoojava@gmail.com]
> >> Sent: Wednesday, January 20, 2010 10:26 AM
> >> To: user@xmlbeans.apache.org
> >> Subject: question on code generation with regard to non-alphabetic
> >> character in xml element name
> >>
> >>
> >>
> >> I am using xmlbean to generate code from wsdl, the issue I am facing is
> >> that names of some xml elements have special character like "_"(for
> example
> >> <first_name>).
> >> and the getter generated is getFirstName().
> >> can I somehow force the method generated to have exact xml tag name like
> >> getFirst_Name()?
> >> I really do not want to do mapping,just too much over head.
> >> Thanks
> >> Jerry
> >>
> >>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

Re: question on code generation with regard to non-alphabetic character in xml element name

Posted by Jacob Danner <ja...@gmail.com>.
So you would use reflection or something like it to infer the name?
Seems like you could get this 'actual element name' information from
the schematypesystem apis without too much hassle.
-jacobd

On Wed, Jan 20, 2010 at 10:29 AM, Jerry Wang <sk...@gmail.com> wrote:
> just want to get original element names from generated classes, so those
> names can be passed onto other components.
>
> On Wed, Jan 20, 2010 at 12:50 PM, Gillen, Paul <pa...@nscorp.com>
> wrote:
>>
>> Pardon the impertinence, but why?
>>
>>
>>
>> ________________________________
>>
>> Paul
>>
>>
>>
>>
>>
>> ________________________________
>>
>> From: Jerry Wang [mailto:skidoojava@gmail.com]
>> Sent: Wednesday, January 20, 2010 10:26 AM
>> To: user@xmlbeans.apache.org
>> Subject: question on code generation with regard to non-alphabetic
>> character in xml element name
>>
>>
>>
>> I am using xmlbean to generate code from wsdl, the issue I am facing is
>> that names of some xml elements have special character like "_"(for example
>> <first_name>).
>> and the getter generated is getFirstName().
>> can I somehow force the method generated to have exact xml tag name like
>> getFirst_Name()?
>> I really do not want to do mapping,just too much over head.
>> Thanks
>> Jerry
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: question on code generation with regard to non-alphabetic character in xml element name

Posted by Jerry Wang <sk...@gmail.com>.
just want to get original element names from generated classes, so those
names can be passed onto other components.

On Wed, Jan 20, 2010 at 12:50 PM, Gillen, Paul <pa...@nscorp.com>wrote:

>  Pardon the impertinence, but why?
>
>
>  ------------------------------
>
> Paul
>
>
>
>
>  ------------------------------
>
> *From:* Jerry Wang [mailto:skidoojava@gmail.com]
> *Sent:* Wednesday, January 20, 2010 10:26 AM
> *To:* user@xmlbeans.apache.org
> *Subject:* question on code generation with regard to non-alphabetic
> character in xml element name
>
>
>
> I am using xmlbean to generate code from wsdl, the issue I am facing is
> that names of some xml elements have special character like "_"(for example
> <first_name>).
> and the getter generated is getFirstName().
> can I somehow force the method generated to have exact xml tag name like
> getFirst_Name()?
> I really do not want to do mapping,just too much over head.
> Thanks
> Jerry
>
>
>

RE: question on code generation with regard to non-alphabetic character in xml element name

Posted by "Gillen, Paul" <pa...@nscorp.com>.
Pardon the impertinence, but why?

________________________________
Paul


________________________________
From: Jerry Wang [mailto:skidoojava@gmail.com]
Sent: Wednesday, January 20, 2010 10:26 AM
To: user@xmlbeans.apache.org
Subject: question on code generation with regard to non-alphabetic character in xml element name

I am using xmlbean to generate code from wsdl, the issue I am facing is that names of some xml elements have special character like "_"(for example <first_name>).
and the getter generated is getFirstName().
can I somehow force the method generated to have exact xml tag name like getFirst_Name()?
I really do not want to do mapping,just too much over head.
Thanks
Jerry