[xquery-talk] reconstructing missing attributes

Howard Katz howardk at fatdog.com
Tue Feb 7 14:46:41 PST 2006


Query lovers, here's another one for your creative minds! This is from an
incorrectly formed file that was mal-created w/out the @id attributes that
should have been on the optional <b/> and <c/> elements. These need to be
added back in and should match the @id's on each immediately preceding
sequence of <a/>'s. Runs of <a/>'s, <b/>'s, and <c/> are of indeterminate
length; <b/>'s and/or <c/>s may be missing altogether between changes in <a
.../> values; the @id attributes are monotonically increasing.

<a id="1"/>
<a id="1"/>
<a id="1"/>
<a id="2"/>
<b/>		(: should be id="2" :)
<b/>		(: should be id="2" :)
<b/>		(: should be id="2" :)
<c/>		(: should be id="2" :)
<a id="3"/>
<a id="3"/>
<b/>		(: id="3" :)
<c/>		(: id="3" :)
<c/>		(: id="3" :)
<a id="4"/>
<a id="4"/>
<a id="4"/>
<a id="5"/>
<b/>		(: id="5" :)
<b/>		(: id="5" :)
<a id="6"/>
...

Seems like it should be easy, but I can't quite see it. Who wants to help me
re-experience that old familiar Doh! sensation? :-)
Howard



More information about the talk mailing list