[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: constructing an element with an element's content

Subject: Re: 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
Re:  constructing an element with an element's content
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
-available()).

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.

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

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

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

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

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

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

regards,
dana

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.