users@jaxb.java.net

custom binding for single element XML

From: Steve Maring <steve_at_maring.org>
Date: Fri, 27 Jun 2003 00:14:51 -0400

 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!

Any thoughts would be greatly appreciated. I've got the complicated XML
licked!

Steve Maring
Tarpon Springs, FL