tags:

views:

102

answers:

3

Lets say I have an XML format similar to the following:

 <Random>
  <...Some arbitrary amount of nesting here...>
    <Random2>
      <Definition>
        <Name>Ape</Name>
        <Description>A mammal</Description>
      </Definition>
    </Random2>
    <Random2>
      <Definition>
        <Name>Ape</Name>
        <Description>A mammal</Description>
      </Definition>
    </Random2>
  <...More Random2 here, end of nesting.../>
</Random>

Is there a general standard approach to support reuse of the definitions in this type of scenario?

A: 

If you don't want the duplication then create a "Definitions" element at the top level and put all of the "Definition" elements there. Then just put some kind of pointer to the definition in your "Random2" elements.

David
+2  A: 

In a xml schema or DTD you can define and id and and idref attribute. This allows you to create it with an id the first time you use it and reference the later values.

DefLog
A: 

Turns out I wanted the key/keyref part of the standard, which also allows you to specify the set of objects (such as a definition list) http://www.w3schools.com/schema/el_keyref.asp

Kinguy