|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: AW: Restraining specific words from an elementtodi
Hi > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Joseph Tan > Sent: Thursday, August 21, 2003 4:59 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: AW: Restraining specific words from an > elementtodisplay > > > Hi there, good to hear from you again. > > The whole XML fragment is build on one record. It's one of > the journals we have but located at different physical > location (South and North Library). > > Here's the exact CURRENT output: (all in one line) > North Campus Library NC-JOURNAL -- Vol 71-86 1993-2000 Not owned: > 71n18(1993) Online access; years vary. LIBWEBSITE -- Online > access; years vary. South Campus Library JOURNALS -- Vol 1- > 1958- Not Owned: > 84n5c(1999) > > Here's the DESIRED output: (in this exact order preferrably) > South Campus Library Vol 1- 1958- Not Owned: 84n5c(1999) > North Campus Library Vol 71-86 1993-2000 Not owned: 71n18(1993) > Online access; years vary. (Note: I want it only appear only once) > This wasn't easy to do. Your data structure isn't the most suitable to this task. If you have control on your input you might consider changing it. This template produces the expected result considering your xml. <!-- here you add an <h:text> for each text you want to skip --> <h:hold> <h:on name="MR870c"> <h:text>ONLINELIB</h:text> <h:text>JOURNALS --</h:text> <h:text>LIBWEBSITE --</h:text> <h:text>NC-JOURNAL --</h:text> </h:on> <h:on name="MR870a"> <h:text>ONLINELIB</h:text> </h:on> </h:hold> <xsl:variable name="holds" select="document('')/xsl:stylesheet/h:hold/h:on"/> <xsl:key match="MR870" name="mr" use="generate-id(preceding-sibling::MR870[MR870a][1])"/> <xsl:template match="Holdings"> <xsl:variable name="getHoldings"> <!-- I'm grouping the results by the MR870a with different text. This way we can skip the repeated text --> <xsl:for-each select="MR870/MR870a[not(.=../preceding-sibling::MR870/MR870a)]"> <!-- here we do the sort. Each letter is the initial of the referent word and the numbers represent the respective order --> <xsl:sort select="translate(.,'SNO','123')"/> <xsl:for-each select="self::MR870a[not(.=$holds[@name='MR870a']/h:text)] | key('mr',generate-id(current()/parent::MR870))/MR870c[not(.=$holds[@name='MR 870c']/h:text)]"> <xsl:choose> <xsl:when test="contains(.,'SOUTHLIB')"> <xsl:value-of select="substring-before(.,'SOUTHLIB')"/>South Campus Library <xsl:value-of select="substring-after(.,'SOUTHLIB')"/> </xsl:when> <xsl:when test="contains(.,'NORTHLIB')"> <xsl:value-of select="substring-before(.,'NORTHLIB')"/>North Campus Library <xsl:value-of select="substring-after(.,'NORTHLIB')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="text()"/> <xsl:text/> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:text> </xsl:text> </xsl:for-each> </xsl:variable> <xsl:if test="not($getHoldings = '')"> <xsl:call-template name="DisplayContent"> <xsl:with-param name="label" select="'Option(s)'"/> <xsl:with-param name="content" select="$getHoldings"/> </xsl:call-template> </xsl:if> </xsl:template> Hope this helps you (...) Regards, Americo Albuquerque XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








