users@jaxb.java.net

Re: custom binding for single element XML

From: Steve Maring <steve_at_maring.org>
Date: Fri, 27 Jun 2003 10:59:08 -0400

I'm using [1.0.1], and I don't get the customization at all!

I can customize the binding of an element if that element contains a
complexType, however, it seems to be a different animal if it contains a
simpleType, as in this case.

I'm thinking there must be a different method here that I can't seem to
figure out.

Any other thoughts?


> Steve Maring wrote:
>
>> I have an XML file like this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <MY_ELEMENT>text</MY_ELEMENT>
>>
>>
>> I'd like to have that bound to a classname of MyElement with a single
>> property called Value.
>>
>> The XSD looks like this:
>>
>> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>> <xsd:element name="MY_ELEMENT" type="xsd:string"/>
>> </xsd:schema>
>>
>> I've tried this but it does not work:
>>
>> <jaxb:bindings version="1.0"
>> xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>> <jaxb:bindings schemaLocation="MyElement.xsd" node="/xsd:schema">
>> <jaxb:bindings node="//xsd:element[@name='MY_ELEMENT']">
>> <jaxb:class name="MyElement"/>
>> </jaxb:bindings>
>> </jaxb:bindings>
>> </jaxb:bindings>
>>
>>
>> I keep ending up with a class named MY_ELEMENT!
>>
>
> Are you using JAXB 1.0? When I run your sample against 1.0.1, I get a
> MYELEMENT.java without the customization, and a MyElement.java with it.
>
> I seem to recall there were some bugs regarding the XML -> Java name
> conversion in JAXB 1.0...
>
>> Any thoughts would be greatly appreciated. I've got the complicated XML
>> licked!
>>
>
> Congrats - you're a better person than I am ;8-)
>
> --Ryan
>
>> Steve Maring
>> Tarpon Springs, FL
>>
>