Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Representing duplicated data in XML [Thread Next] Re: Representing duplicated data in XMLTo: NULL Date: 9/6/2008 3:16:00 PM Troy Cauble wrote: > In comp.text.xml Charles Packer <mailbox@c...> wrote: >> Does XML have a way to refer to duplicated data? > >> . >> . >> <situation> something </situation> >> <action1> action specific to something </action1> >> <action2> >> . >> . ...often done in any situation... >> . >> </action2> >> <situation) something else </situation> >> <action1> action specific to something else</action1> >> ??? >> . >> . >> . >> >> ...the question marks are where I want to insert >> correct XML that compactly signals a second use of >> datum "action2". I learned from an XML tutorial that I can >> assign an _attribute_ to action2. Might a solution to >> the problem involve an attribute? The tutorials I perused >> didn't have anything about this use of attributes. > > > You could have optional id and ref elements. > > <action id='myUniqueId'>blah....</action> > ... > <action ref='myUniqueId'/> > > with documentation saying to use a ref attribute *OR* content. > Better than documentation is something you can validate > with DTD/XML Schema/whatever. Such as > > <actionref ref='myUniqueId'/> > > Where actionref requires ref, does not allow content, and can be > used wherever action can. > > Depending on your app, you might consider it poor form to > reference an action in a situation from another situation. > So you might want a section of > > <actiondefs> > <actiondef id='myUniqueId'>blah...</actiondef> > </actiondefs> > > where id is required (and no longer allowed in action). > > Also, you probably don't want to number your action element > names "action1", "action2", etc. Just use "action". Order > is significant within sub-elements. Sadly, SGML's CONREF (Content Reference) attribute type, which was (among other things) for this exact type of situation, never made it into XML. ///Peter | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
