|
Subject: [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 20:07:18 -0500 |
Greetings,
Hoping someone can point out my misunderstanding of the solution in my
transformation to the construction of an element, <controlfield>, with
a preferred ISBN and the use of a second ISBN (13 characters vs. 10)
if the preferred is unavailable; otherwise, nothing.
<productidentifier>
<b221>02</b221>
<b244>160542868X</b244>
</productidentifier>
<productidentifier>
<b221>03</b221>
<b244>9781605428680</b244>
</productidentifier>
<productidentifier>
<b221>15</b221>
<b244>9781605428680</b244>
</productidentifier>
All of the product records have 3 productidentifiers with b221 element
values in the following order: 02, 03, 15.
To test the element construction with the second ISBN (b221=02) if the
preferred ISBN (b221=15) is missing, I removed the productidentifer
with element b221=15 from the second product record; I removed all
productidentifiers from the third record.
<xsl:for-each select="productidentifier">
<xsl:variable name="isbn13">
<xsl:choose>
<xsl:when test="b221='15'">
<xsl:value-of select="b244"/>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="isbn10">
<xsl:choose>
<xsl:when test="b221='02'">
<xsl:value-of select="b244"/>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="not(empty($isbn13))">
<controlfield tag="001">
<xsl:text>xyz</xsl:text><xsl:value-of select="$isbn13"/>
</controlfield>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="empty($isbn13)">
<controlfield tag="001">
<xsl:text>xyz</xsl:text><xsl:value-of select="$isbn10"/>
</controlfield>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
The results of the three records:
record 1
<controlfield tag="001">xyz</controlfield>
<controlfield tag="001">xyz</controlfield>
<controlfield tag="001">xyz9781605428680</controlfield>
record 2
<controlfield tag="001">xyz</controlfield>
<controlfield tag="001">xyz</controlfield>
record 3 has the desired result of no controlfield tag=001
I am apparently not accounting for productidentifier/b221=03 but have
tried creating a similar variable which would result in an empty
string...have tried using exists()...not using variables...but always
get the same result..
hope the problem is clear...a little cross-eyed at this point..
any help would be greatly appreciated...
regards,
dana
--
Dana Pearson
dbpearsonmlis.com
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] analyze-string help?, Michael Müller-Hille | Thread | Re: [xsl] constructing an element w, Syd Bauman |
| Re: [xsl] analyze-string help?, Michael Kay | Date | Re: [xsl] constructing an element w, Syd Bauman |
| Month |