[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Question about isolating records


Subject: Re: [xsl] Question about isolating records
From: "Mark Wilson pubs@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 6 Sep 2015 03:48:46 -0000

Thank you,

I got to work with one small change to your suggested code:

<xsl:attribute name="pdf-number" select="substring-before(key('pdf-key', ., doc('test-xml.xml')), 'Crawford')"/>

My major misunderstanding was of the <xsl:key/> statement, not realizing that is was not a 'variable to be loaded when called' and that the key() function later would parse the data in FILE2.

Also, thanks for reopening the book for me.
Regards,
Mark

On 9/5/2015 7:20 PM, G. Ken Holman g.ken.holman@xxxxxxxxx wrote:
At 2015-09-05 23:46 +0000, Mark Wilson pubs@xxxxxxxxxxxx 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@xxxxxxxxxxxxxxxxxxxx | 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


Current Thread
Keywords