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

Re: [xsl] constructing an element with an element's content based on the content of sibling element

Subject: Re: [xsl] constructing an element with an element's content based on the content of sibling element
From: Dana Pearson <dbpearsonmlis@xxxxxxxxx>
Date: Sun, 10 Jun 2012 23:02:05 -0500

Thanks very much for your reply, Syd.

My apologies, I didn't search the XSL archive
specifically, many of the results from my google
search queries included the archive.  I also poured
over Kay's tomb for the functions not(), exists(),
empty() (got really excited for a moment with element

My stylesheet has nearly 1300 lines of code
transforming ONIX for Books 2.1 into MARCXML.  I'm
using XSLT 2.0 (use tokenize() not available in 1.0);
Stylus Studio Enterprise edition 2010.

In fact, the scenario for the need of an alternate
ISBN is small but the variability of publisher
encoding warrants this test I think.

In place of the stylesheet segment in my OP, I
substituted a call-template based on your reply.  The
main template of my stylesheet matches the product
element with ONIXMessage as the context and I use
call-template for the construction of 1XX, 7XX and 245
MARC fields given the complexity of those fields with
respect to name and title elements in ONIX as well as
punctuation in the MARCXML fields.

Hadn't thought to use call-template here but also
hadn't considered the predicates you offered, so I
tried this based on your suggestion but get no
controlfields at all.  Wan't sure about the context of
the value-of select paths, so tried value-of
select="following-sibling::b244", too.

<xsl:for-each select="productidentifier">
  <xsl:call-template name="isbn"/>

<xsl:template name="isbn" match="productidentifier">
   <xsl:when test="productidentifier/b221 = '15'">
     <xsl:apply-templates select="productidentifier[b221='15']"/>
    <xsl:apply-templates select="productidentifier[b221='02']"/>

<xsl:template match="productidentifier[b221 eq '02']">
  <controlfield tag="001">
    <xsl:value-of select="b244"/>

<xsl:template match="productidentifier[b221 eq '15']">
  <controlfield tag="001">
   <xsl:value-of select="b244"/>

Most of my earlier efforts centered on the use of
xsl:choose and xsl:otherwise.  All failed so think I'm
lacking a basic understanding of an important XSLT

Tried attaching a file with 3 records with the variation of presence
of different product identifiers but my message was rejected even
though in a text file.

thanks again..


Current Thread