|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Question about isolating records
Ken,
In my original question, when @crawford-number from File1 matched <Shelfmark> in FILE2, I wanted the contents of <PDF> from File2 as the value of pdf-number in File1. (An entire <Item> from File2 is reproduced after the stylesheet below, if needed.) I returned to my original structure as the code you provided failed to reproduce the <Tag> value. Inserting substring-before(key(...), 'Crawford') worked on my test file of one record, but when I presented the complete file, Saxon complained that the first argument of substring-before() can not be a sequence. I tried putting the key() in a variable and calling substring-before() on the variable, but got the same complaint. What is being returned when I run the full file of multiple records is: (with <xsl:strip-space elements="*"/>) pdf-number="016677041Crawford 2212.The Journal of the Philatelic Literature Society.">852</Tag> pdf-number="016677042Crawford 2215.Le Magasin pittoresque,">852</Tag> (without <xsl:strip-space elements="*"/>) pdf-number="
 016677041
 Crawford 2212.
 The Journal of the Philatelic Literature Society.
 ">852</Tag> pdf-number="
 016677042
 Crawford 2215.
 Le Magasin pittoresque,
 ">852</Tag> The PDF numbers, from FILE2's <PDF> are 016677041 and 016677042. All <PDF> numbers contain the same number of digits, if that helps, and are always the first piece of data in the return from key(). That is, the key() is finding the right <Item> in FILE2 (single-crawford-docs.xml), but is returning the entire contents of that <Item>. How can it be limited to <PDF>? I cannot understand where I tell the stylesheet I am only interested in the contents of <PDF>. Here is the entire stylesheet which I think reproduces your code with the exception that the <Tag> data is hard coded. <xsl:output method="xml"/>
<xsl:strip-space elements="*"/> <xsl:key name="pdf-key" match="Item" use="Shelfmark"/>
<xsl:template match="@* | node()">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template><xsl:template match="Tag"> <xsl:choose> <xsl:when test=". eq '852'"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:for-each select="@crawford-number"> <xsl:attribute name="pdf-number" select="key('pdf-key', ., doc('single-crawford-docs.xml'))"/> <xsl:value-of select="'852'"/> </xsl:for-each> </xsl:copy> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template>
----------------
FILE2:
<List>
<Item>
<PDF>016678286</PDF>
<Shelfmark>Crawford 2411.</Shelfmark>
<Title>General-Anzeiger f|r Philatelie.</Title>
</Item>
</List>On 9/5/2015 8:49 PM, Mark Wilson pubs@xxxxxxxxxxxx wrote: Thank you,
|
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
|

Cart








