|
Subject: Re: Matching in IDREFS attributes From: "Pete Johnston" <P.Johnston@xxxxxxxxxxxxxxxxxx> Date: Fri, 16 Jul 1999 12:33:45 GMT |
[Jean Daniel Fekete]
> I have XML elements with an ANA attribute of type IDREFS. I want to
> iterate over these refs in XSL and create an hypertext link to each
> referenced id.
There really _must_ be a better solution than this but I think a
called template working its way through the value of the attribute as
a string does the trick... something like:
<xsl:template match="name">
<xsl:value-of select="."/>
<xsl:call-template name="get-ref">
<xsl:param name="refstring" expr="@ana"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="get-ref">
<xsl:param-variable name="refstring"/>
<xsl:param-variable name="count" expr="1"/>
<xsl:variable name="thisref"
expr="substring-before(concat($refstring,' '),' ')"/>
<xsl:if test="not($thisref='')">
<xsl:element name="a">
<xsl:attribute name="href">#<xsl:value-of select="$thisref"/>
</xsl:attribute>
<xsl:value-of select="$count"/>
</xsl:element>
<xsl:call-template name="get-ref">
<xsl:param name="refstring" expr="substring-after($refstring,' ')"/>
<xsl:param name="count" expr="$count+1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
> 2nd problem, probably harder: I would also like to have a two-way
> linking where the <INTERP ...> points back to all its references.
I haven't worked this through fully, but if all the references are
in "ana" attributes then I think a pattern something like the
following might help:
<xsl:template match="interp">
<xsl:variable name="thisid" expr="@id"/>
<xsl:for-each select="//*[contains(concat' ',(@ana,' '),concat('
',$thisid,' '))]">
[process referring elements to generate link back]
</xsl:for-each>
</xsl:template>
Pete Johnston
University of Glasgow
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Matching in IDREFS attributes, Jean Daniel Fekete 8 | Thread | Re: Matching in IDREFS attributes, Sebastian Rahtz |
| Re: XSL-WG solicits comments on FO , Stephen Deach | Date | Re: Namespace name of source docume, James Clark |
| Month |