[color=blue]
> In the example above, the
> Package element (complexType) would continue to print infinitely. Is
> there a way, using XSLT, to determine if an element is recursive, and
> thus avoid "re-printing" it?[/color]
Hi,
I don't know if there is a standard way to deal with it, but I came up with this:
<xsl:if test="0=count(//complexType[@name = current()/@ref][element/@ref=current()/../@name])"/>
will be true if it is recursive.
Using this stylesheet:
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:apply-templates select="//complexType"/>
</body></html>
</xsl:template>
<xsl:template match="complexType">
<h1><xsl:value-of select="local-name()"/> - name: <xsl:value-of select="@name"/></h1>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<p>
<xsl:value-of select="local-name()"/> - ref: <xsl:value-of select="@ref"/> - recursive:
<xsl:value-of select="0!=count(//complexType[@name = current()/@ref][element/@ref=current()/../@name])"/>
</p>
</xsl:template>
an input XML schema like this:
<complexType name="test">
<element ref="d" />
<element ref="test" />
</complexType>
<complexType name="a">
<element ref="b" />
<element ref="a" />
</complexType>
<complexType name="b">
<element ref="f" />
<element ref="a" />
</complexType>
<complexType name="c">
<element ref="a" />
</complexType>
<complexType name="d">
<element ref="e" />
</complexType>
will be outputed as:
complexType - name: test
element - ref: d - recursive: false
element - ref: test - recursive: true
complexType - name: a
element - ref: b - recursive: true
element - ref: a - recursive: true
complexType - name: b
element - ref: f - recursive: false
element - ref: a - recursive: true
complexType - name: c
element - ref: a - recursive: false
complexType - name: d
element - ref: e - recursive: false
I hope you can use this somehow.
regards,
--
Joris Gillis (
http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum