Let me ask about this line:
<xs:element ref="Symbol"/>
Character defined in yahoo.xsd or locally in the same xsd file?
I will try to deduce some facts.
I assume that you have two yahoo.xsd : yahoo.xsd and some.xsd (the first in your post). I am sure that the Symbol type is defined in some.xsd and not in yahoo.xsd . If it were otherwise, I would expect some namespace prefix ("yahoo: Symbol"?).
Now, is it true, your some.xsd looks something like this:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" > <xs:element name="Symbol"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="quote"> <xs:complexType> <xs:sequence> <xs:element ref="Symbol"/> </xs:sequence> <xs:attribute name="symbol" use="required" type="xs:NCName"/> </xs:complexType> </xs:element> </xs:schema>
If what I'm saying is true, then your jaxb binding should look like this:
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1"> <bindings schemaLocation="some.xsd"> <bindings node="//xs:element[@name='quote']/xs:complexType/xs:sequence/xs:element[@ref='Symbol']"> <property name="SymbolAttribute" /> </bindings> </bindings> </bindings>
And the generated java class will be:
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "symbolAttribute" }) @XmlRootElement(name = "quote") public class Quote { @XmlElement(name = "Symbol") protected int symbolAttribute; @XmlAttribute(name = "symbol", required = true) @XmlJavaTypeAdapter(CollapsedStringAdapter.class) @XmlSchemaType(name = "NCName") protected String symbol; ....
source share