63 * class ObjectFactory { |
63 * class ObjectFactory { |
64 * @XmlElementDecl(name="foo") |
64 * @XmlElementDecl(name="foo") |
65 * JAXBElement<String> createFoo(String s) { ... } |
65 * JAXBElement<String> createFoo(String s) { ... } |
66 * } |
66 * } |
67 * </pre> |
67 * </pre> |
68 * <pre> |
68 * <pre> {@code |
69 * <!-- XML input --> |
69 * |
70 * <foo>string</foo> |
70 * <!-- XML input --> |
|
71 * <foo>string</foo> |
71 * |
72 * |
72 * // Example: code fragment corresponding to XML input |
73 * // Example: code fragment corresponding to XML input |
73 * JAXBElement<String> o = |
74 * JAXBElement<String> o = |
74 * (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument); |
75 * (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument); |
75 * // print JAXBElement instance to show values |
76 * // print JAXBElement instance to show values |
76 * System.out.println(o.getName()); // prints "{}foo" |
77 * System.out.println(o.getName()); // prints "{}foo" |
77 * System.out.println(o.getValue()); // prints "string" |
78 * System.out.println(o.getValue()); // prints "string" |
78 * System.out.println(o.getValue().getClass()); // prints "java.lang.String" |
79 * System.out.println(o.getValue().getClass()); // prints "java.lang.String" |
79 * |
80 * |
80 * <!-- Example: XML schema definition --> |
81 * <!-- Example: XML schema definition --> |
81 * <xs:element name="foo" type="xs:string"/> |
82 * <xs:element name="foo" type="xs:string"/> |
82 * </pre> |
83 * }</pre> |
83 * |
84 * |
84 * <p><b>Example 2: </b> Element declaration with non local scope |
85 * <p><b>Example 2: </b> Element declaration with non local scope |
85 * <p> |
86 * <p> |
86 * The following example illustrates the use of scope annotation |
87 * The following example illustrates the use of scope annotation |
87 * parameter in binding of element declaration in schema derived |
88 * parameter in binding of element declaration in schema derived |
88 * code. |
89 * code. |
89 * <p> |
90 * <p> |
90 * The following example may be replaced in a future revision of |
91 * The following example may be replaced in a future revision of |
91 * this javadoc. |
92 * this javadoc. |
92 * |
93 * |
93 * <pre> |
94 * <pre>{@code |
94 * <!-- Example: XML schema definition --> |
95 * <!-- Example: XML schema definition --> |
95 * <xs:schema> |
96 * <xs:schema> |
96 * <xs:complexType name="pea"> |
97 * <xs:complexType name="pea"> |
97 * <xs:choice maxOccurs="unbounded"> |
98 * <xs:choice maxOccurs="unbounded"> |
98 * <xs:element name="foo" type="xs:string"/> |
99 * <xs:element name="foo" type="xs:string"/> |
99 * <xs:element name="bar" type="xs:string"/> |
100 * <xs:element name="bar" type="xs:string"/> |
100 * </xs:choice> |
101 * </xs:choice> |
101 * </xs:complexType> |
102 * </xs:complexType> |
102 * <xs:element name="foo" type="xs:int"/> |
103 * <xs:element name="foo" type="xs:int"/> |
103 * </xs:schema> |
104 * </xs:schema> |
104 * </pre> |
105 * }</pre> |
105 * <pre> |
106 * <pre> |
106 * // Example: expected default binding |
107 * // Example: expected default binding |
107 * class Pea { |
108 * class Pea { |
108 * @XmlElementRefs({ |
109 * @XmlElementRefs({ |
109 * @XmlElementRef(name="foo",type=JAXBElement.class) |
110 * @XmlElementRef(name="foo",type=JAXBElement.class) |