[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Matching in IDREFS attributes

Subject: Re: Matching in IDREFS attributes
From: "Pete Johnston" <P.Johnston@xxxxxxxxxxxxxxxxxx>
Date: Fri, 16 Jul 1999 12:33:45 GMT
pete template
[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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.