Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top