xsl-list
[Top] [All Lists]

Re: [xsl] Question about isolating records

2015-09-05 21:20:40
At 2015-09-05 23:46 +0000, Mark Wilson pubs(_at_)knihtisk(_dot_)org wrote:
I am still missing something -- I have been building the key in File 1 with this code:
<xsl:key name="pdf-key" match="Item" use="doc('FILE2')//Shelfmark"/>

You've transcribed my suggestion incorrectly. The use= attribute is relative to the match= node. I expressly used use="Shelfmark". The File2 tree is accessed when you use the third argument to the key() function.

That, of course, gives me all the content of every <Items> as my pdf-number when I call <xsl:attribute name="pdf-number" select="key('pdf-key', ., doc('test-xml.xml'))"/>

Right ... because you didn't use the code I gave you.

If I use:
<xsl:key name="pdf-key" match="Item" use="doc('FILE2')/Shelfmark"/>
I get nothing when I do the look-up.

Also correct, because you must not access File2 when declaring the key.

Am I supposed to build the key in File2, and if so, how do I then preserve it for use in File1.

Declaring a key creates a key table for every input file. It is the third argument of the key() function that declares which file is looked up ... and if the third argument is absent the tree of the current node is used (which you don't want because that is File1).

Sorry to be so dense, but I have never used keys before.

Did you try the code that I gave you? I was expecting it to work without you making any changes.

At 2015-09-05 23:54 +0000, you wrote:
My last was not quite right: I am building the key in the stylesheet that processes File 1.

The act of declaring a key will create a key table for every input file.

PS. Lost your book when my last computer went south.

All registered users get perpetual free updates ... I'll send you the password.

. . . . . . . Ken


--
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Free 5-hour lecture:  http://www.CraneSoftwrights.com/links/video.htm |
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                    
mailto:gkholman(_at_)CraneSoftwrights(_dot_)com |
Google+ profile:       http://plus.google.com/+GKenHolman-Crane/about |
Legal business disclaimers:     http://www.CraneSoftwrights.com/legal |


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>