Solved

how to remove certain entries from an xml node using xslt

Posted on 2011-09-06
3
383 Views
Last Modified: 2013-11-18
I have the following requirement

Remove any entries for <dc:creator>Wiley InterScience (Online service)</dc:creator>
Remove full stops at end of entries
Separate entries with semicolon and space

Example:
<dc:creator>Ousey, Karen.</dc:creator>
<dc:creator>McIntosh, Caroline.</dc:creator>

"Ousey, Karen; McIntosh, Caroline"
0
Comment
Question by:mmalik15
  • 2
3 Comments
 

Author Comment

by:mmalik15
ID: 36491193
I have trying something like below but does not seem to work

<mauthorpersons>
							<xsl:choose>
								<xsl:when test="dc:creator != 'Wiley Inter Science(Online service)'">
									<xsl:value-of select="."/>
									<xsl:text>, </xsl:text>
								</xsl:when>
							</xsl:choose>
						</mauthorpersons>

Open in new window

0
 
LVL 18

Accepted Solution

by:
zc2 earned 500 total points
ID: 36491351
Please look at the sample below. It has two assumptions, so probably need to be elaborated.
<mauthorpersons>
			<!-- Make sure the condition is an exact match! 
			     If it's not, invent more smart way to compare -->
		   <xsl:for-each select="dc:creator[. != 'Wiley InterScience (Online service)']">

			<!-- I assume, it's ok to remove all the dot characters from the string
				 If it's wrong approach, need something more complex -->
				<xsl:value-of select="translate(., '.', '')"/>
				<xsl:if test="position() != last()">
					<xsl:text>; </xsl:text>
    			</xsl:if>
          </xsl:for-each>
		</mauthorpersons>

Open in new window

0
 

Author Closing Comment

by:mmalik15
ID: 36495706
Brilliant mate!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now