Solved

how to concatenate multiple xml node entries using xslt 1.0

Posted on 2011-09-06
9
977 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
ID: 36489851
Is each XML element shown a different row in SQL Server? Or is this a straight XSL transformation question?
0
 

Author Comment

by:mmalik15
ID: 36489876
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
ID: 36489891
I dont know why sql server zone has been selected as i only selected xml :S
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:mmalik15
ID: 36489926
thanks
0
 
LVL 18

Accepted Solution

by:
zc2 earned 500 total points
ID: 36489960
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
ID: 36489984
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
ID: 36489993
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
ID: 36490888
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SP to delete duplicates 15 70
XSL-FO - show results in 2 columns 5 31
Fixed div within Bootstrap carousel item 11 58
ebay devID, appID, certID, userToken 2 25
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

805 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