Subject: Re: [xsl] A problem with concat() From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx> Date: Mon, 18 Apr 2011 15:18:11 -0400 |
I notice you have a test of "not(@attribute)" in your code. Should this be "not(@authority)", instead? -Brandon :) On Mon, Apr 18, 2011 at 2:39 PM, Bridger Dyson-Smith <bdysonsmith@xxxxxxxxx> wrote: > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] A problem with concat(), Bridger Dyson-Smith | Thread | Re: [xsl] A problem with concat(), Bridger Dyson-Smith |
Re: [xsl] A problem with concat(), G. Ken Holman | Date | Re: [xsl] A problem with concat(), Bridger Dyson-Smith |
Month |