我有这个XML数据文件:
<?xml-stylesheet type="text/xsl" href="CounselForm.xsl"?>
<CounselForm Name="A N OTHER">
<StudyPoint Assigned="0" Completed="0">
<Number>1</Number>
<Description>Accurate Reading</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>2</Number>
<Description>Words Clearly Spoken</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>3</Number>
<Description>Correct Pronunciation</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>4</Number>
<Description>Fluent Delivery</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>5</Number>
<Description>Appropriate Pausing</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>6</Number>
<Description>Proper Sense Stress</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>7</Number>
<Description>Principal Ideas Emphasized</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>8</Number>
<Description>Suitable Volume</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>9</Number>
<Description>Modulation</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>10</Number>
<Description>Enthusiasm</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>11</Number>
<Description>Warmth And Feeling</Description>
</StudyPoint>
<StudyPoint Assigned="1" Completed="0">
<Number>12</Number>
<Description>Gestures and Facial Expressions</Description>
<StartDate>07/03/2016</StartDate>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>13</Number>
<Description>Visual Contact</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>14</Number>
<Description>Naturalness</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>15</Number>
<Description>Good Personal Appearance</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>16</Number>
<Description>Poise</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>17</Number>
<Description>Use of Microphone</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>18</Number>
<Description>Use of Bible in Replying</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>19</Number>
<Description>Use of Bible Encouraged</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>20</Number>
<Description>Scriptures Effectively Introduced</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>21</Number>
<Description>Scriptures Read With Proper Emphasis</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>22</Number>
<Description>Scriptures Correctly Applied</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>23</Number>
<Description>Practical Value Made Clear</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>24</Number>
<Description>Choice of Words</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>25</Number>
<Description>Use of an Outline</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>26</Number>
<Description>Logical Development of Material</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>27</Number>
<Description>Extemporaneous Delivery</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>28</Number>
<Description>Conversational Manner</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>29</Number>
<Description>Voice Quality</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>30</Number>
<Description>Interest Shown in the Other Person</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>31</Number>
<Description>Respect Shown to Others</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>32</Number>
<Description>Expressed With Conviction</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>33</Number>
<Description>Tactful Yet Firm</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>34</Number>
<Description>Upbuilding And Positive</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>35</Number>
<Description>Repetition for Emphasis</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>36</Number>
<Description>Theme Developed</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>37</Number>
<Description>Main Points Made to Stand Out</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>38</Number>
<Description>Interest - Arousing Introduction</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>39</Number>
<Description>Effective Conclusion</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>40</Number>
<Description>Accuracy of Statement</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>41</Number>
<Description>Understandable to Others</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>42</Number>
<Description>Informative to Your Audience</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>43</Number>
<Description>Use of Assigned Material</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>44</Number>
<Description>Effective Use of Questions</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>45</Number>
<Description>Illustrations / Examples That Teach</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>46</Number>
<Description>Illustrations From Familiar Situations</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>47</Number>
<Description>Effective Use of Visual Aids</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>48</Number>
<Description>Reasoning Manner</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>49</Number>
<Description>Sound Arguments Given</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>50</Number>
<Description>Effort To Reach the Heart</Description>
</StudyPoint>
<StudyPoint Assigned="0" Completed="0">
<Number>51</Number>
<Description>Accurately Timed, Properly Proportioned</Description>
</StudyPoint>
</CounselForm>
这是当前的 XSL 文件:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" version="4.01"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="//W3C//DTD XHTML 1.0 Transitional//EN"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>
Counsel Form
</title>
</head>
<body>
<h1>
Counsel Form for <xsl:value-of select="/CounselForm/@Name"/>
</h1>
<table>
<thead>
<tr>
<td>Study Point</td>
<td>Date Assigned</td>
<td>Date Completed</td>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="CounselForm/StudyPoint"/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="StudyPoint">
<tr>
<td>
<xsl:value-of select="Number"/>
 
<xsl:value-of select="Description"/>
</td>
<td>
<xsl:choose>
<xsl:when test="@Assigned=1">
<xsl:value-of select="StartDate"/>
</xsl:when>
<xsl:otherwise>
 
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test="@Completed=1">
<xsl:value-of select="EndDate"/>
</xsl:when>
<xsl:otherwise>
 
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
现在,当我在Internet Explorer中查看此内容并查看源代码时,为什么它有这么多过多的空格?
<!DOCTYPE html PUBLIC "//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>
Counsel Form
</title>
</head>
<body>
<h1>
Counsel Form for A N OTHER</h1>
<table>
<thead>
<tr>
<td>Study Point</td>
<td>Date Assigned</td>
<td>Date Completed</td>
</tr>
</thead>
<tbody>
<tr xmlns="">
<td>1
Accurate Reading</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>2
Words Clearly Spoken</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>3
Correct Pronunciation</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>4
Fluent Delivery</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>5
Appropriate Pausing</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>6
Proper Sense Stress</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>7
Principal Ideas Emphasized</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>8
Suitable Volume</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>9
Modulation</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>10
Enthusiasm</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>11
Warmth And Feeling</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>12
Gestures and Facial Expressions</td>
<td>07/03/2016</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>13
Visual Contact</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>14
Naturalness</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>15
Good Personal Appearance</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>16
Poise</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>17
Use of Microphone</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>18
Use of Bible in Replying</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>19
Use of Bible Encouraged</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>20
Scriptures Effectively Introduced</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>21
Scriptures Read With Proper Emphasis</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>22
Scriptures Correctly Applied</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>23
Practical Value Made Clear</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>24
Choice of Words</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>25
Use of an Outline</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>26
Logical Development of Material</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>27
Extemporaneous Delivery</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>28
Conversational Manner</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>29
Voice Quality</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>30
Interest Shown in the Other Person</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>31
Respect Shown to Others</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>32
Expressed With Conviction</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>33
Tactful Yet Firm</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>34
Upbuilding And Positive</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>35
Repetition for Emphasis</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>36
Theme Developed</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>37
Main Points Made to Stand Out</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>38
Interest - Arousing Introduction</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>39
Effective Conclusion</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>40
Accuracy of Statement</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>41
Understandable to Others</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>42
Informative to Your Audience</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>43
Use of Assigned Material</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>44
Effective Use of Questions</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>45
Illustrations / Examples That Teach</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>46
Illustrations From Familiar Situations</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>47
Effective Use of Visual Aids</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>48
Reasoning Manner</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>49
Sound Arguments Given</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>50
Effort To Reach the Heart</td>
<td>
</td>
<td>
</td>
</tr>
<tr xmlns="">
<td>51
Accurately Timed, Properly Proportioned</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</body>
</html>
我需要在 XSL 文档中更改哪些内容以使生成的 HTML 看起来更美观?
谢谢。
安德鲁
如果您希望在输出中使用更紧凑的代码,请将所有文字文本节点放在<xsl:text>
指令中 - 例如,更改:
<title>
Counsel Form
</title>
自:
<title>
<xsl:text>Counsel Form</xsl:text>
</title>
或删除空格,以便:
<title>Counsel Form</title>
与您的问题无关,但您有一个命名空间问题:您的表行及其后代位于 no-namespace 中,而表及其祖先位于 XHTML 命名空间中:您应该在样式表级别将 XHTML 命名空间声明为默认命名空间。