Chapter 19 Controlling XML Element and Attribute Names - Controlling Tags for Simple Attributes

Chapter 19 Controlling XML Element and Attribute Names - Controlling Tags for Simple Attributes

In an XML-enabled object, each simple attribute is projected as a XML element or attribute, depending on how it is mapped. In either case, by default, the IRIS attribute name is used as the XML element or attribute name. To provide a different XML name for an attribute, specify the attribute's XMLNAME parameter.

Property Zip As %String (XMLNAME = "PostalCode");

The output of the previous example will look like this:

<HomeAddress>
  <Street>5064 Elm Street</Street>
  <City>Jackson</City>
  <State>PA</State>
  <PostalCode>27621</PostalCode>
</HomeAddress>

Note that if the attribute is another IRIS object class, the XML mapping ignores the class name and XMLNAME Parameters. For example, suppose class Person has a property named Address that is a reference to class Address. Person The projection of the object looks like this:

<Person>
 <Name>Zevon,Juanita Q.</Name>
 <DOB>1986-08-18</DOB>
 <Address>
   <Street>5064 Elm Street</Street>
   <City>Jackson</City>
   <State>PA</State>
   <Zip>27621</Zip>
 </Address>
</Person>

<Address>The name of the element is determined by the name of the corresponding attribute in the Person object. This is because the address object is a property of the object being imported or exported (rather than the object being imported or exported directly).

As with any other property, this name can be overridden by specifying the property's XMLNAME parameter. For example:

Property Address As MyApp.Address (XMLNAME = "EmployeeAddress");

The output of the previous example will look like this:

<Person>
 <Name>Zevon,Juanita Q.</Name>
 <DOB>1986-08-18</DOB>
 <EmployeeAddress>
   <Street>5064 Elm Street</Street>
   <City>Jackson</City>
   <State>PA</State>
   <Zip>27621</Zip>
 </EmployeeAddress>
</Person>

Guess you like

Origin blog.csdn.net/yaoxin521123/article/details/134681187