Inserting spaces between text of elements with same name

LexCentury

New Member
this question is probably fairly trivial to answer for versed XSLT authors.I have the following example XML document:\[code\]<?xml version="1.0" encoding="UTF-8"?><students> <student num="12345678"> <name>Dona Diller</name> <dob>1970-07-21</dob> <education>BSc</education> <education>MSc</education> <status>Married</status> </student><!-- more student elements to follow... --></students>\[/code\]And the following XSL:\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <html> <title>Test</title> <body> <h1>Personal details</h1> <xsl:apply-templates select="students/student"/> </body> </html> </xsl:template> <xsl:template match="student"> <p> Student number: <xsl:value-of select="@num"/> </p> <p>Full name: <xsl:value-of select="name"/> </p> <p>Date of birth <xsl:value-of select="dob"/> </p> <!-- TODO: text of 'education' elements must be separated by a space --> <p>Degrees: <xsl:apply-templates select="education"/> </p> <p>Status: <xsl:value-of select="status"/> </p> </xsl:template></xsl:stylesheet>\[/code\]Which produces the following XHTML output when applied to the XML document included at the beginning of this post:\[code\]<html> <title>Test</title> <body> <h1>Personal details</h1> <p> Student number: 12345678 </p> <p>Full name: Dona Diller </p> <p>Date of birth 1970-07-21 </p> <p>Degrees: BScMSc </p> <p>Status: Married </p> </body></html>\[/code\]My issue is that the degree names are merged as one string (text of education element). So instead of getting 'BScMSc' in the output, I'd like to display 'BSc MSc' in the previous example. Any thoughts?
 
Back
Top