Subject: Re: [xsl] constructing an element with an element's content based on the content of sibling element From: Dana Pearson <dbpearsonmlis@xxxxxxxxx> Date: Mon, 11 Jun 2012 20:20:58 -0500 |
actually that helps a lot...my problem is not with a procedural programming past but virtually no programming past...although a javascript course in graduate school provided practice in pseudocode.. this is something that I can use elsewhere in my stylesheet....contributor names come in 4 different elements and dozens upon dozens of type... thanks again.. regards, dana On Mon, Jun 11, 2012 at 8:05 PM, Syd Bauman <Syd_Bauman@xxxxxxxxx> wrote: >> don't yet understand how the empty xsl:when does it (although I've >> used it before)...but works like a charm.. > > Perhaps more intensive commenting will help: > > <!-- > We're going to hit this template several times in a row, once for > each <productidentifier>. We want to print out the ISBN13 if there > is one, and the ISBN10 if there is no ISBN13. So when we are > called for a <productidentifier>, we have to figure out whether to > generate output or not by looking at ourself and our siblings. > * if we are the ISBN13 case, print out > * if we are not the ISBN13 case, but one of our siblings is, then > don't do anything (the ISBN13 will be printed when our sibling is > matched by this very template) > * if we are not the ISBN13 case, and none of our siblings are > ISBN13, and we are the ISBN10, then print it out > * if we are not the ISBN13 case, and none of our siblings are > ISBN13, but we are not the ISBN10, then a warning message > --> > <xsl:template name="isbn" match="productidentifier"> > <xsl:choose> > <!-- first take care of the "I am ISBN 13" case --> > <xsl:when test="child::b221 = '15'"> > <controlfield tag="001"> > <xsl:text>ISBN13 = </xsl:text> > <xsl:value-of select="b244"/> > </controlfield> > </xsl:when> > <!-- if we've gotten this far, this is not the "I am ISBN 13" case --> > <!-- test to see if we have a sibling that is hte ISBN 13 case; > if so, do nothing, as this template will do the work (above) when > it hits that sibling --> > <xsl:when test="parent::*/child::productidentifier/child::b221 = '15'"/> > <!-- we've gotten this far, so there is no sibling ISBN 13; > so use ISBN 10, if that's what I am --> > <xsl:when test="child::b221 = '02'"> > <controlfield tag="001"> > <xsl:text>ISBN10 = </xsl:text> > <xsl:value-of select="b244"/> > </controlfield> > </xsl:when> > <xsl:otherwise> > <xsl:message>Danger, Will Robinson! a 'productidentifier' that is confusing</xsl:message> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > -- Dana Pearson dbpearsonmlis.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] constructing an element w, Syd Bauman | Thread | [xsl] Modes (was RE: [xsl] Re: Keys, Michele R Combs |
Re: [xsl] constructing an element w, Syd Bauman | Date | Re: [xsl] pass variable length para, Michel Hendriksen |
Month |