|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Matching in IDREFS attributes
[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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








