html - Displaying CDATA in XML with XSLT -
hey have xml file "course_desc" element copy/pasted value(the unit description multiple paragraphs , formatting) website want display in cdata , retain it's original formatting.
<courses> <course> <course_desc> <![cdata[ course structure contains information units comprise course credit points required complete it. students must complete programme outlined below. semester enrolments subject unit availability , students must consult course coordinator prior enrolling. work integrated learning students in course have opportunity seek work integrated learning placement industry partner equivalent 1 semester of fulltime study. such placements available students have: completed prerequisite units, completed @ least 2 thirds of requirements towards degree and, have weighted average mark (wam) of 65% or higher across course, or have wam of 70% or higher 2 semesters preceding application. students meet these criteria , wish participate in work integrated learning must apply in writing course coordinator end of first year of course (or prior enrolling in project preparation). students should seek advice of course coordinator appropriateness of pursuing work placement option within course structure , eligibility considered. selection based on academic performance, application , formal interview process. successful applicants work placement must enroll in , complete requirements unit work experience project (in place of project preparation, project 1 , project 2). 60 credit point unit , represents full semester’s study load. students advised not enroll in additional units while taking work experience project unit. students should note failure complete work experience project necessitate completing project preparation/project 1/project 2 instead, add 2 semesters course duration. ]]> </course_desc> </course> </courses>
i output retain orginal formatting of cdata see in course_desc element. description section copy/pasted in should whatever pasted in. in xslt have tried value-of , copy-of errors won't read out cdata.
have got cdata stored wrong in xml or can't use value-of/copy-of display it?
thanks.
edited xslt file.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <html> <body> <h2>course information</h2> <xsl:apply-templates select="courses/course" /> </body> </html> </xsl:template> <xsl:template match="course"> <strong>course: <xsl:text> </xsl:text></strong> <xsl:value-of select="text()" /><br /> <strong>coordinator name: <xsl:text> </xsl:text></strong><xsl:value-of select="course_coordinator/fname"/><xsl:text> </xsl:text><xsl:value-of select="course_coordinator/sname"/><br /><br /> <xsl:variable name="link" select="course_coordinator/image" /> <xsl:variable name="cname" select="course_corrdinator/image" /> <img src="{$link}" alt="{$cname}"/><br /><br /> <!-- <xsl:vaule-of select="course_desc"/> among alternatives tried here --> <strong>elective list: <xsl:text> </xsl:text></strong> <xsl:for-each select="electives/elective"> <li><a><xsl:attribute name="href"><xsl:value-of select="elective_link" /></xsl:attribute><xsl:value-of select="elective_code" /></a><xsl:text> </xsl:text><xsl:value-of select="elective_title" /></li> <br /> </xsl:for-each> <br /> <xsl:apply-templates select="year" /> </xsl:template> <xsl:template match="year"> <xsl:apply-templates select="semester" /> </xsl:template> <xsl:template match="semester"> <strong>year: <xsl:text> </xsl:text></strong><xsl:value-of select="../@ynum"/><br /> <strong>semester: <xsl:text> </xsl:text></strong><xsl:value-of select="@snum"/><br /> <table border="0"> <tr bgcolor="#b0c4de"> <th>unit</th> <th>description</th> <th>credit points</th> </tr> <xsl:apply-templates select="units/unit" /> </table> <br/><br/><br/> </xsl:template> <xsl:template match="unit"> <tr> <td><a><xsl:attribute name="href"><xsl:value-of select="unit_link" /></xsl:attribute><xsl:value-of select="unit_code" /></a></td> <td><xsl:value-of select="unit_title"/></td> <td><xsl:value-of select="cp"/></td> </tr> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment