WebSphere Enterprise Service Bus, Version 6.2.0 Operating Systems: AIX, HP-UX, i5/OS, Linux, Solaris, Windows


How do I get/set anyAttribute values?

Setting an <anyAttribute/> value is done in the same way as setting an <any/>, but instead of a global element a global attribute is used.

Performing a get on data that was set in an anyAttribute field can be done in the same manner as any other attribute value if the name is known. You can perform a get with the XPath "@<name>" and it will be resolved. If the name is unknown, using the above code the values can be iterated and accessed one by one. The example code below shows this:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:tns="http://AnyAttrOnlyMixed" 
 targetNamespace="http://AnyAttrOnly">
  <xsd:complexType name="AnyAttrOnly">
    <xsd:sequence>
      <xsd:element name="element" type="xsd:string"/>
    </xsd:sequence>
    <xsd:anyAttribute/>
  </xsd:complexType>
</xsd:schema>

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	targetNamespace="http://GlobalAttrs">
  <xsd:attribute name="globalAttribute" type="xsd:string"/>
</xsd:schema>

	DataObject dobj = ...

	// Get the global attribute Property that is going to be set
	Property globalProp = boXsdHelper.getGlobalProperty(http://GlobalAttrs, 
	"globalAttribute", false);

	// Set the value on the dobj, just like any other data
	dobj.set(globalProp, "foo");

	// The data can now be accessed by a get call
	System.out.println(dobj.get("@globalAttribute")); // Displays "foo"

concept Concept topic

Terms of use | Feedback


Timestamp icon Last updated: 21 June 2010


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wesb620.doc/doc/cbo_howgetsetanyattrs.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
This information center is powered by Eclipse technology (http://www.eclipse.org).