包括XML文档的项目符号

时间:2012-09-18 15:20:24

标签: xml xslt points

我有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>

我希望这可以像

一样
  • 本课程是对信息技术的介绍 安全,实用的电子信息系统所必需的 商务。
  • 将从文档表示的区域中选择主题 (XML,DTD,XML Schema,XSLT,CSS),安全性(加密,公钥, 对称密钥,PKI,认证);各种攻击和 漏洞,电子交易(自发的,审慎的,
    拍卖),
  • 电子文档管理(元数据,搜索,数字图书馆, 管理和处理),最近的发展和成熟 区域,例如Web应用程序框架,Web服务,语义 网络,移动商务

这样做我相信我应该在我的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>

我应该如何包含要点?谢谢!

1 个答案:

答案 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>

如果您想使用不同的规则来分解段落,可以将正则表达式值从.*?[\.;]更改为其他值。