[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Question about isolating records
At 2015-09-05 21:35 +0000, Mark Wilson pubs@xxxxxxxxxxxx wrote:
Ken, I clearly am missing something. My stylesheet (using the two records at the bottom of this email) creates an empty @pdf-number.
<xsl:key name="pdf-key" match="Item" use="Shelfmark"/> ... then you look up in the table for the desired value for Shelfmark. <xsl:template match="@* | node()"> <xsl:copy copy-namespaces="no"> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template>
<!--untested but I think it should work just fine--> <xsl:template match="Tag"> <!--preserve the element--> <xsl:copy> <!--preserve all attributes--> <xsl:copy-of select="@*"/> <!--add an attribute only if there is a Crawford number--> <xsl:for-each select="@crawford-number"> <!--get the value by looking up in the other document--> <xsl:attribute name="pdf-number" select="key('pdf-key',.,doc('FILE2.xml')"/> </xsl:for-each> </xsl:copy> </xsl:template> I hope this helps. . . . . . . Ken p.s. review pages 319-323 of my XSLT book that you have FILE 1: <List> <Record> <Field> <Tag>245</Tag> <Data>General-Anzeiger fC<r Philatelie.$bInternationales Insertions- Organ.</Data> </Field> <Field> <Tag crawford-number="Crawford 2411.">852</Tag> <Data>No.1-800. 10 Apr. 1883-15 Jan. 1913$aBritish Library$b5$cDPB$jCrawford 2411.$nxxk</Data> </Field> </Record> </List> -- 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 |
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|