[0]>
I am a newbie to this forum
That may play to your advantage. In some cases, I would give up helping for some veterans to the forum if I judge help would be vain and even counter-productive.
[1] With arsenal from within the boundary of xml technologies, it is possible to approach the problem of some affinity to traveler problem and/or paths and loops over a lattice etc. It is not apriori simple and the inherent complexity is recognized.
[2] Xsl basically kind of functional language should be adequate to tackle the problem. In a sense, it can be conceived as a kind of constraint on xml document through Schematron, outside of w3c schema language.
[3] I can show you an example of how this can be done through recursive template construction. Concrete use to your document is up to you to re-modeling the demo.
[4] Suppose the xml be this with general structure in a way realizing what you describe as the problem.
[tt]
<root>
<field name="a">
<option name="p" />
<option name="q" />
</field>
<field name="b">
<option name="r" />
<option name="s" />
<option name="t" />
</field>
<field name="p">
<option name="w" />
<option name="b" />
<option name="p" />
<option name="a" />
</field>
<field name="s">
<option name="x" />
<option name="y" />
</field>
</root>
[/tt]
[5] This is a way to get all the path with the characteristic suggestive to dependency.
[tt]
<xsl:stylesheet version="1.0" xmlns:xsl="[ignore]
[/ignore]">
<xsl

utput method="text" omit-xml-declaration="yes" encoding="utf-8" />
<xsl:template match="/">
<xsl:apply-templates select="root" />
</xsl:template>
<xsl:template match="root">
<xsl:apply-templates select="field" />
</xsl:template>
<xsl:template match="field">
<xsl:variable name="fieldname" select="@name" />
<xsl:variable name="pv" select="position()" />
<xsl:for-each select="option">
<xsl:call-template name="proc-option">
<xsl:with-param name="origin" select="$fieldname" />
<xsl:with-param name="pv" select="$pv" />
<xsl:with-param name="linklist" select="$fieldname" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="proc-option">
<xsl

aram name="origin" />
<xsl

aram name="pv" />
<xsl

aram name="linklist" />
<xsl:if test="not(contains($linklist,@name)) and (count(//field[@name=current()/@name]) > 0)">
<xsl:call-template name="proc-field">
<xsl:with-param name="origin" select="$origin" />
<xsl:with-param name="pv" select="$pv" />
<xsl:with-param name="field" select="//field[@name=current()/@name][1]" />
<xsl:with-param name="linklist" select="concat($linklist,'-',@name)" />
</xsl:call-template>
</xsl:if>
<xsl:if test="not(contains($linklist,@name)) and (count(//field[@name=current()/@name]) = 0)">
<xsl:value-of select="concat('field [',$pv,'] ',$origin,'

ath=>',$linklist,'-',@name,':stopped','
')" />
</xsl:if>
<xsl:if test="contains($linklist,@name)">
<xsl:value-of select="concat('field [',$pv,'] ',$origin,'

ath=>',$linklist,'-',@name,':looping','
')" />
</xsl:if>
</xsl:template>
<xsl:template name="proc-field">
<xsl

aram name="origin" />
<xsl

aram name="pv" />
<xsl

aram name="field" />
<xsl

aram name="linklist" />
<xsl:for-each select="$field/option">
<xsl:call-template name="proc-option">
<xsl:with-param name="origin" select="$origin" />
<xsl:with-param name="pv" select="$pv" />
<xsl:with-param name="linklist" select="$linklist" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
[/tt]
[6] The output would look like this.
[tt]
field [1] a

ath=>a-p-w:stopped
field [1] a

ath=>a-p-b-r:stopped
field [1] a

ath=>a-p-b-s-x:stopped
field [1] a

ath=>a-p-b-s-y:stopped
field [1] a

ath=>a-p-b-t:stopped
field [1] a

ath=>a-p-p:looping
field [1] a

ath=>a-p-a:looping
field [1] a

ath=>a-q:stopped
field [2] b

ath=>b-r:stopped
field [2] b

ath=>b-s-x:stopped
field [2] b

ath=>b-s-y:stopped
field [2] b

ath=>b-t:stopped
field [3] p

ath=>p-w:stopped
field [3] p

ath=>p-b-r:stopped
field [3] p

ath=>p-b-s-x:stopped
field [3] p

ath=>p-b-s-y:stopped
field [3] p

ath=>p-b-t:stopped
field [3] p

ath=>p-p:looping
field [3] p

ath=>p-a-p:looping
field [3] p

ath=>p-a-q:stopped
field [4] s

ath=>s-x:stopped
field [4] s

ath=>s-y:stopped
[/tt]
[7] How and what do you get something out of the demo are up to you and your readiness to do with the technologies.