Solved

how to concatenate multiple xml node entries using xslt 1.0

Posted on 2011-09-06
9
993 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML filtering Windows Event Viewer 10 63
XML to SQL Table using c# 5 69
I dont know why my code is no longer working help please 9 62
xslt 1.0 - How to split value 8 28
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

820 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