[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: constructing an element with an element's content
> 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|