[XML4Lib] Style sheet question (UNCLASSIFIED)
Binkley, Peter
Peter.Binkley at ualberta.ca
Thu Jun 12 17:54:08 EDT 2008
Do I understand rightly that the problem is here, where it trims the
(presumably) trailing period?
<xsl:variable name="title"
select="substring-before($title_tmp, '.')" />
If there is no final period, that returns an empty string.
The answer would be to remove the final character only if it is a
period. This would do it:
concat(
substring($title_tmp, 1, string-length($title_tmp - 1),
translate(
substring($title_tmp, string-length($title_tmp),
1),
'.',
''
)
)
(Indented for legibility). I may be off-by-one with those
string-lengths, but you get the idea: chop off the final character and
then use translate() to remove any unwanted punctuation.
Or a simpler approach: append a period, so that it will always be there
as a delimiter; if there already is one, the first one will be the
delimiter so the second one does no harm.
substring-before(concat($title_tmp, '.'), '.')
So if the title ends with a question mark, that will be the last
character before the appended period and will be preserved.
I hope this helps
Peter
-----Original Message-----
From: xml4lib-bounces at webjunction.org
[mailto:xml4lib-bounces at webjunction.org] On Behalf Of Metz, Edward J Mr
CIV USA TRADOC
Sent: Tuesday, June 10, 2008 11:59 AM
To: xml4lib at webjunction.org
Subject: [XML4Lib] Style sheet question (UNCLASSIFIED)
Classification: UNCLASSIFIED
Caveats: NONE
I'm trying to convert our digital library metadata to MARC so we can
upload the records to our local OPAC and to OCLC. I've hit a snag that
maybe someone can help me with. It involves the 245 tag and subfield b.
I created this call-template below and it seems to work okay with one
major exception that I've found so far. I haven't been able to get it to
handle correctly those instances where a title containing a subfield b
happens to end with a question mark. Can anyone offer any advice?
<!--title template-->
<xsl:template name="title_template">
<xsl:param name="string" />
<xsl:param name="field" />
<xsl:param name="ind1" />
<xsl:param name="ind2" />
<xsl:param name="type" />
<datafield>
<xsl:attribute name="tag">
<xsl:value-of select="$field" />
</xsl:attribute>
<xsl:attribute name="ind1">
<xsl:value-of select="$ind1" />
</xsl:attribute>
<xsl:attribute name="ind2">
<xsl:value-of select="$ind2" />
</xsl:attribute>
<xsl:choose>
<!-- IF A Colon, STOP AT AN OPENING PAREN -->
<xsl:when test="contains($string, ':')!=0">
<subfield code="a">
<xsl:value-of select="substring-before($string, ':')"
/>:</subfield>
</xsl:when>
<!-- NO colons, commas JUST OUTPUT THE NAME -->
<xsl:otherwise>
<subfield code="a">
<xsl:value-of select="$string" />
</subfield>
</xsl:otherwise>
</xsl:choose>
<!-- CAPTURE subfield b -->
<xsl:if test="contains($string, ':')!=0">
<xsl:variable name="title_tmp"
select="substring-after($string, ':')" />
<xsl:variable name="title"
select="substring-before($title_tmp, '.')" />
<subfield code="b">
<xsl:value-of select="$title" /></subfield>
</xsl:if>
</datafield>
</xsl:template>
Edward Metz
Systems Librarian
Combined Arms Research Library, USACGSC
250 Gibbon Ave
Fort Leavenworth KS 66027-2314
Tel: 913-758-3027
Fax: 913-758-3014
DSN: 585-3027
http://carl.army.mil
Classification: UNCLASSIFIED
Caveats: NONE
_______________________________________________
XML4Lib mailing list
XML4Lib at webjunction.org
http://lists.webjunction.org/mailman/listinfo/xml4lib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webjunction.org/wjlists/xml4lib/attachments/20080612/81826197/attachment.htm
More information about the XML4Lib
mailing list