XML 1-4, p.51

Eliminating Redundancy in XML Using ID/IDREF

Listing 1
<?xml version="1.0"?>
<!DOCTYPE SAMPLE [
<!ELEMENT SAMPLE (SUPERVISOR+, EMPLOYEE+)>
<!ELEMENT SUPERVISOR (NAME)>
<!ATTLIST SUPERVISOR ID ID #REQUIRED>
<!ELEMENT EMPLOYEE (NAME)>
<!ELEMENT NAME (#PCDATA)>
<!ATTLIST EMPLOYEE SUPERVISOR IDREF #REQUIRED>
]>
<SAMPLE>
  <SUPERVISOR ID="123">
     <NAME>Jeff Ricker</NAME>
  </SUPERVISOR>

  <SUPERVISOR ID="456">
     <NAME>Debbie Hamel</NAME>
  </SUPERVISOR>

  <EMPLOYEE SUPERVISOR="123">
     <NAME>Dan Cocos</NAME>
  </EMPLOYEE>

  <EMPLOYEE SUPERVISOR="456">
     <NAME>Yoshi Russell</NAME>
  </EMPLOYEE>
</SAMPLE>
 

Listing 2
<Database>
<View_1>
<Key>1232231</Key>
<FirstName>Bruce</FirstName>
<LastName>Wellington</LastName>
<Address>161 West Park Driver</Address>
<City>South Park</City>
<State>CO</State>
<Zip>30303</Zip>
</View_1>
<View_2>
<Key>1232231</Key>
<FirstName>Bruce</FirstName>
<LastName>Wellington</LastName>
<PurchaseOrderNumber>122343</PurchaseOrderNumber>
</View_2>
</Datebase>
 

Listing 3
<Database>
     <Keys>
      <Key ID="1232231">
          <FirstName>Bruce</FirstName>
          <LastName>Wellington</LastName>
      </Key>
     </Keys>
<DataView>
     <Adress IDREF="1232231">
      <Street>161 West Park Drive</Street>
      <City>South Park</City>
      <State>CO</State>
      <Zip>30303</Zip>
     </Address>
     <PurchaseOrderNumber IDREF="1232231">
      122343
     </PurchaseOrderNumber>
</DataView>
</Database>