我有XML文档,一个标签有很长的描述,所以我想在几个要点中对其进行格式化
例如,
<description>This course is an introduction to the information technologies required for secure, practical information systems for electronic commerce.
Topics will be chosen from areas such as document representation (XML, DTDs, XML Schema, XSLT, CSS), security (encryption, public key, symmetric key,
PKI, authentication); kinds of attack and vulnerabilities, electronic trading (spontaneous, deliberative, auctions), electronic document management
(metadata, search, digital libraries, management and processing), recent developments and maturation of the area,
such as web application frameworks, web services, the semantic web , mobile commerce</description>
我希望这可以像
一样这样做我相信我应该在我的XSL文件中改变一些东西,这是
<xsl:template match="/">
<html>
<head>
<title> Course Catalogue </title>
</head>
<body bgcolor="#FF9999">
<xsl:for-each select="xsi:catalogue/xsi:course">
<br />
<xsl:apply-templates select="xsi:title" />
<br />
<xsl:apply-templates select="xsi:year" />
<br />
<xsl:apply-templates select="xsi:science" />
<br />
<xsl:apply-templates select="xsi:area" />
<br />
<xsl:apply-templates select="xsi:subject" />
<br />
<xsl:apply-templates select="xsi:unit" />
<br />
<xsl:apply-templates select="xsi:description" />
<br />
<xsl:apply-templates select="xsi:outcomes" />
<br />
<xsl:apply-templates select="xsi:incompatibility" />
</xsl:for-each>
</body>
</html>
</xsl:template>
和xsi:description,
<!-- The template for course description -->
<xsl:template match="xsi:description">
<div style="font-family:times;font-size:16">
<span style="color:#000">
Course Description:
</span>
<xsl:value-of select="." />
</div>
</xsl:template>
我应该如何包含要点?谢谢!
答案 0 :(得分:1)
您必须决定分隔符以将您的描述拆分为项目符号。下面是一个使用句点和分号作为分隔符进行拆分的示例:
<xsl:template match="xsi:description">
<div style="font-family:times;font-size:16">
<span style="color:#000">Course Description:</span>
<ul>
<xsl:analyze-string select="string()" regex=".*?[\.;]" flags="sm">
<xsl:matching-substring>
<li><xsl:value-of select="."/></li>
</xsl:matching-substring>
<xsl:non-matching-substring>
<li><xsl:value-of select="."/></li>
</xsl:non-matching-substring>
</xsl:analyze-string>
</ul>
</div>
</xsl:template>
<div style="font-family:times;font-size:16">
<span style="color:#000">Course Description:</span>
<ul>
<li>This course is an introduction to the information technologies required for secure, practical information systems for electronic commerce.</li>
<li>Topics will be chosen from areas such as document representation (XML, DTDs, XML Schema, XSLT, CSS), security (encryption, public key, symmetric key, PKI, authentication);</li>
<li> kinds of attack and vulnerabilities, electronic trading (spontaneous, deliberative, auctions), electronic document management (metadata, search, digital libraries, management and processing), recent developments and maturation of the area, such as web application frameworks, web services, the semantic web , mobile commerce</li>
</ul>
</div>
如果您想使用不同的规则来分解段落,可以将正则表达式值从.*?[\.;]
更改为其他值。