<anyAttribute/> 값 설정은 <any/>를 설정하는 것과 동일한 방법으로 수행되지만 글로벌 요소 대신 글로벌 속성을 사용합니다.
anyAttribute 필드에 설정된 데이터 이름을 알고 있는 경우 기타 속성 값과 동일한 방법으로 데이터 가져오기를 수행할 수 있습니다. XPath "@<name>"을 사용하여 가져오기를 수행할 수 있으며 가져오기가 해결됩니다. 이름을 알 수 없는 경우 위의 코드를 사용하여 값을 반복시키고 차례로 값에 액세스할 수 있습니다. 다음 코드 예제는 이 작업의 수행 방법을 보여 줍니다.
<?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"