Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Questo contenuto non è disponibile nella lingua selezionata.
34.3. Using Unbound Attributes
Overview Copia collegamentoCollegamento copiato negli appunti!
Defining in XML Schema Copia collegamentoCollegamento copiato negli appunti!
anyAttribute
element. It can be used wherever an attribute element can be used. The anyAttribute
element has no attributes, as shown in Example 34.7, “Complex Type with an Undeclared Attribute”.
Example 34.7. Complex Type with an Undeclared Attribute
Example 34.8. Examples of Elements Defined with a Wild Card Attribute
<officer rank="12"><name>...</name><rate>...</rate></officer> <lawyer type="divorce"><name>...</name><rate>...</rate></lawyer> <judge><name>...</name><rate>...</rate></judge>
<officer rank="12"><name>...</name><rate>...</rate></officer>
<lawyer type="divorce"><name>...</name><rate>...</rate></lawyer>
<judge><name>...</name><rate>...</rate></judge>
Mapping to Java Copia collegamentoCollegamento copiato negli appunti!
anyAttribute
element is mapped to Java, the code generator adds a member called otherAttributes
to the generated class. otherAttributes
is of type java.util.Map<QName, String>
and it has a getter method that returns a live instance of the map. Because the map returned from the getter is live, any modifications to the map are automatically applied. Example 34.9, “Class for a Complex Type with an Undeclared Attribute” shows the class generated for the complex type defined in Example 34.7, “Complex Type with an Undeclared Attribute”.
Example 34.9. Class for a Complex Type with an Undeclared Attribute
Working with undeclared attributes Copia collegamentoCollegamento copiato negli appunti!
otherAttributes
member of the generated class expects to be populated with a Map
object. The map is keyed using QNames
. Once you get the map , you can access any attributes set on the object and set new attributes on the object.
Example 34.10. Working with Undeclared Attributes