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

A problem with concat()

Subject: A problem with concat()
From: Bridger Dyson-Smith <bdysonsmith@xxxxxxxxx>
Date: Mon, 18 Apr 2011 14:39:37 -0400
 A problem with concat()
Hi all,
Thanks for reading. I'm sure I'm making an error, but I'm not able to
determine where I'm going awry.

I want to use concat() to pull together three elements, separating the
values with a comma. I've done this, but it turns out that I need to
test the elements. When I perform the tests I'm able to concat() the
values (when appropriate), but I'm not getting any commas between my
values. I put up examples on pastebin: the XML is at
http://pastebin.com/tGbJMpGG and the XSLT is at
http://pastebin.com/DY4ELbh3, lines 11-18 and 25-58 respectively. The
examples below are shortened versions of the examples on Pastebin -
line numbers will be slightly different.

Thanks for your time and suggestions.
Cheers,
Bridger

PS here is an abbreviated example of the XML and the XSLT:

<?xml version="1.0" encoding="UTF-8"  ?>
<mods:mods xmlns:mods="http://www.loc.gov/mods/v3"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns="http://www.loc.gov/mods/v3"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.loc.gov/mods/v3
 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd" ID="MODS" version="3.2">
  <mods:titleInfo>
    <mods:title>Chimney and Indian Gap Hotel</mods:title>
  </mods:titleInfo>
  <mods:name  type="personal" authority="LCNAF">
    <mods:namePart type="family">Thompson</mods:namePart>
    <mods:namePart type="given">James Edward</mods:namePart>
    <mods:namePart type="date">1880-1976</mods:namePart>
    <mods:role>
      <mods:roleTerm authority="marcrelator">Photographer</mods:roleTerm>
    </mods:role>
  </mods:name>
</mods:mods>

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
    xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns="http://www.loc.gov/mods/v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.loc.gov/mods/v3
    http://www.loc.gov/standards/mods/v3/mods-3-2.xsd"
    xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">

    <xsl:output method="xml" media-type="text/xml" indent="yes" />
    <xsl:strip-space elements="*"/>
    <xsl:template match="mods:mods">
        <oai_dc
            xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
            <xsl:apply-templates/>
        </oai_dc>
    </xsl:template>

    <xsl:template match="mods:titleInfo">
        <dc:title>
            <xsl:value-of select="./mods:title"/>
        </dc:title>
    </xsl:template>

    <xsl:template match="mods:name">
        <xsl:choose>
            <xsl:when test="./mods:role/mods:roleTerm">
                <dc:creator>
                    <!--<xsl:value-of
select="concat(./mods:namePart[@type='family'], ', ',
./mods:namePart[@type='given'], ', ',
./mods:namePart[@type='date'])"/>-->
                    <xsl:choose>
                        <xsl:when test="not(@attribute)">
                            <xsl:value-of select="mods:namePart"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:choose>
                                <xsl:when test=".[@type='corporate']">
                                    <xsl:value-of select="mods:namePart"/>
                                </xsl:when>
                                <xsl:when test=".[@type='personal']">
                                    <xsl:if test="count(mods:namePart) = 1">
                                        <xsl:value-of
select="mods:namePart"/>
                                    </xsl:if>
                                    <xsl:if test="count(mods:namePart) > 2">
                                        <xsl:value-of
select="concat(./mods:namePart[@type='family'], ', ',
./mods:namePart[@type='given'], ', ',
./mods:namePart[@type='date'])"/>
                                    </xsl:if>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:otherwise>
                    </xsl:choose>
                </dc:creator>
            </xsl:when>
            <xsl:otherwise>
                <dc:contributor>
                    <xsl:value-of select="./mods:namePart[@type='*']"/>
                </dc:contributor>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


</xsl:stylesheet>

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.