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

Re: Question about keys and cross-referencing (was pre

Subject: Re: Question about keys and cross-referencing (was predicate)
From: Chris Loschen <loschen@xxxxxxxxxxxxx>
Date: Mon, 05 May 2003 17:13:58 -0400
homograph numbers
At 04:28 PM 5/5/03, you wrote:
Chris,

At 03:33 PM 5/5/2003, you wrote:
So I've got an input structure like this:

<e eid="e0001"><hg><hw>keyword</hw></hg><se1>...</se1></e>
...
<e eid="e1234"><hg><hw>different_keyword</hw></hg><se1>... <xg>See also <xr>keyword</xr></xg>...</se1></e>


where the <xr> element "keyword" needs to link to the <e> element where the <hw> is "keyword".

I'm thinking that I can set up a key like

<xsl:key name="headwords" match="hw" use="ancestor::e/@eid" />

and then reference it in my xr template like

<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:apply-templates select="key('headwords',ancestor::e/@eid)" /></xsl:attribute>

Does that sound right?

I'd say -- not quite. "ancestor::e/@eid" for the current node when the template is matched, where this attribute is generated, will be e1234, not e0001. You want to refer to e0001.


You could define your key as

<xsl:key name="e-by-hw" match="e" use="hg/hw"/>

Then

<xsl:apply-templates select="key('e-by-hw',.)"/> to select the target "e" element refered to by its headword elsewhere.

Sometimes I've got several headwords that are identical except for the homograph numbers, like so:

<e eid="e0003"><hg><hw>keyword</hw><hom>1</hom></hg><se1>...</se1></e>
<e eid="e0004"><hg><hw>keyword</hw><hom>2</hom></hg><se1>...</se1></e>
<e eid="e0005"><hg><hw>keyword</hw><hom>3</hom></hg><se1>...</se1></e>

and these are referenced like so:

<e eid="e2345"><hg><hw>different_keyword</hw></hg>... <xg>See also <xr>keyword</xr><hom>1</hom></xg>...</e>

Is there a way to include those homograph numbers in the key and in the cross-reference so that I get the
correct (I hope unique) link?

Sure, you could define your key as


<xsl:key name="e-by-hw" match="e" use="concat(hg/hw, '-' ,hg/hom)"/>

Then

<xsl:apply-templates select="key('e-by-hw',concat(., '-' ,../hom))"/>

Make sense?

Very cool! I'll play around with it and see what I can come up with. Thank you very much!



--Chris


----------------------------------------------------------------------------------------
Texterity ~ XML and PDF ePublishing Services
----------------------------------------------------------------------------------------
Chris Loschen, XML Developer
Texterity, Inc.
144 Turnpike Road
Southborough, MA 01772 USA
tel: +1.508.804.3033
fax: +1.508.804.3110
email: loschen@xxxxxxxxxxxxx
http://www.texterity.com/



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.