Solved

how to concatenate multiple xml node entries using xslt 1.0

Posted on 2011-09-06
9
954 Views
Last Modified: 2013-11-18
I need to concatenate entries and need to separate each entry with a space.

For example:
<dc:description>Includes bibliographical references and index.</dc:description>
<dc:description>The need for a multiprofessional approach in wound care / Karen Ousey and Caroline McIntosh.</dc:description>  
<dc:description>Description based on print version record.</dc:description> and I want output like this
Includes bibliographical references and index. The need for a multiprofessional approach in wound care / Karen Ousey and Caroline McIntosh. Description based on print version record.
0
Comment
Question by:mmalik15
  • 4
  • 3
9 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
Is each XML element shown a different row in SQL Server? Or is this a straight XSL transformation question?
0
 

Author Comment

by:mmalik15
Comment Utility
its a straight xml to xml conversion using xslt

the xslt below creates three body elements but i want to merge all of them in one body element

<xsl:for-each select="dc:description">
                  <body>

                        <xsl:copy-of  select="./text()"/>

                  </body>
            </xsl:for-each>
0
 

Author Comment

by:mmalik15
Comment Utility
I dont know why sql server zone has been selected as i only selected xml :S
0
 

Author Comment

by:mmalik15
Comment Utility
thanks
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 18

Accepted Solution

by:
zc2 earned 500 total points
Comment Utility
I guess, you need something like this:
<body>
	<xsl:for-each select="dc:description">
		<xsl:value-of select="."/><xsl:text> </xsl:text>
	</xsl:for-each>
</body>

Open in new window

0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
You are most welcome. I am more on the database side, but from my past experience with XSLT I would think you want the <body> on the outside of the <xsl:for-each>. Then you are just using the for-each to get the copy-of or value-of each instance of <dc:description>. To get the additional space, try a <xsl:text> to include a literal " ".

e.g.,
<body>
   <xsl:for-each select="dc:description">
      <xsl:value-of  select="."/>
      <xsl:if test="position()!=last()">
         <xsl:text> </xsl:text>
      </xsl:if>
   </xsl:for-each>
</body>

Open in new window


Hope that helps until XML/XSL Experts arrive.
0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
Wow. See what I mean, it took me 10 minutes to type out what a true Expert could in five. *laughing*
See http:#a36489960 for answer.
0
 

Author Closing Comment

by:mmalik15
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 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

11 Experts available now in Live!

Get 1:1 Help Now