Solved

how to concatenate multiple xml node entries using xslt 1.0

Posted on 2011-09-06
9
972 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
 

Author Comment

by:mmalik15
ID: 36489926
thanks
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RSS Feed Parsing for Images 5 60
Getting attribute Values using xslt 4 41
Create associate webpages / websites 3 67
Issue with XSLT mapping 10 20
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

920 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

16 Experts available now in Live!

Get 1:1 Help Now