嘿所有我有一个XML文件,其中“course_desc”元素是来自网站的复制/粘贴值(具有多个段落和格式的单元描述),所以我想在CDATA中显示它并保留它的原始格式
<courses>
<course>
<course_desc>
<![CDATA[
This course structure contains information about the units which comprise the course as well as the credit points required to successfully complete it.
Students must complete the programme outlined below. All semester enrolments are subject to unit availability and students must consult the Course Coordinator prior to enrolling.
WORK INTEGRATED LEARNING
Students in this course have the opportunity to seek a Work Integrated Learning placement with an industry partner equivalent to one semester of fulltime study. Such placements are available to students who have:
Successfully completed any prerequisite units,
Successfully completed at least two thirds of the requirements towards the degree and,
Have a Weighted Average Mark (WAM) of 65% or higher across their course, or
Have a WAM of 70% or higher for the two semesters preceding their application.
Students who meet these criteria and who wish to participate in Work Integrated Learning must apply in writing to their Course Coordinator by the end of the first year of the course (or PRIOR to enrolling in Project Preparation). Students should seek the advice of the Course Coordinator as to the appropriateness of pursuing the work placement option within their course structure and also as to their eligibility to be considered. Selection will be based on academic performance, the application and a formal interview process.
Successful applicants for work placement must enroll in and complete the requirements for the unit Work Experience Project (in place of Project Preparation, Project 1 and Project 2). This is a 60 credit point unit and represents a full semester’s study load. Students are advised NOT to enroll in any additional units while taking the Work Experience Project unit. Students should also note that failure to successfully complete Work Experience Project could necessitate completing Project Preparation/Project 1/Project 2 instead, which could add two extra semesters to the course duration.
]]>
</course_desc>
</course>
</courses>
我希望输出保留其CDATA的原始格式,就像你在course_desc元素中看到的一样。这是一个只是复制/粘贴的描述部分,因此它应该看起来像粘贴的任何东西。在XSLT中我尝试过value-of和copy-of但我只是得到错误,因为它不会读出CDATA。 / p>
我是否在XML中存储了错误的CDATA,或者您不能使用value-of / copy-of来显示它?
感谢。
使用xslt文件编辑。
<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 some alternatives I 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>