[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 13:09:50 -0000

Ken,
Again thanks. Since this is a one-off task (with more nasty stuff to come), I found a less elegant solution by running a second transformation on the output to remove everything but the PDF number from the @pdf-number.


I do appreciate your help and advice. I have never been able to master the XSLT model -- 20 years of C++ programming simply gets in the way. At the age of 76, I may never actually understand it, but the product of the process we worked through (you helped with that also) a few years ago won a Gold Medal at the London 2013 Stampex show - you can see that work at www.czechout.org -- the entire website is produced and updated using only XML. No other philatelic index has ever won a Gold Medal! You may take some of the credit for that.
Thanks again,
Mark


On 9/6/2015 5:44 AM, G. Ken Holman g.ken.holman@xxxxxxxxx wrote:
At 2015-09-06 03:48 +0000, Mark Wilson pubs@xxxxxxxxxxxx wrote:
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')"/>

I think a better solution would be:


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

... because you want the value of the <PDF> child of the <Item> element being returned by the key() function. I worry you approach XSLT, like many of my incoming students did, as dealing with XML as a bunch of strings to be manipulated. I had to teach the students to understand XSLT treats XML as a bunch of nodes, not strings. Whereas you approached the solution above by substringing the <Item> element string value, I suggest you simply address the PDF child of the Item element node and you have everything you need without using substrings.

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.

Good ... I was trying to get across to you that, yes, the key declaration is in effect for all input files.


Also, thanks for reopening the book for me.

You are most welcome. Other registered purchasers are welcome to ask for access to the latest edition (14th, dated 2011-02-11).


. . . . . . 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