XML转换与XSL错误 - 请真的需要回答

时间:2014-11-16 14:02:22

标签: xml xslt

我尝试将XML转换为HTML

它已经说转型完成了,但生成的新文件说

Ln 6 Col 6 - 元素类型"链接"必须由匹配的结束标记终止""。 1错误

我已经尝试添加结束标记,然后它只是继续显示另一个错误...

这是代码

XML:

<?xml version="1.0" encoding="UTF-8"?>
<!--<?xml-stylesheet type="text/xsl" href="announcement.xsl" ?>-->

<announcement>

    <content>
        <a_num>Announcement</a_num>
        <a_date>Friday, November 7th 2014</a_date>
        <a_subject>Announcement Page</a_subject>
        <a_details>
            We are pleased to announce of Harbour Tennis CupTournament is open to all members of Harbour Island Tennis Club and preliminary rounds will need to be played in the weeks leading up to Finals Day on Saturday 21st November.

            Players can enter more than one age group, ie their own and one age group above. We have added an additional Girls Hardball group for ages 12 through 18, but feel free to enter mixed groups too. Entry is RM20 per event and all juniors are encouraged to enter.

            Consolation rounds will be played for those knocked out in the first round so everyone is guaranteed at least 2 matches.

            Finals Day is a great day of tennis with senior and junior matches being played. There will be a BBQ and the bar will be open so make a note in your diary and come along with family and friends.

            The deadline for entries is 10th May.

            Any questions, please feel free to contact me.

            Many thanks,
            Ahmad Naqib
        </a_details>
    </content>

    <content>
        <a_num>Announcement 2</a_num>
        <a_date>October 1st, 2014</a_date>
        <a_subject>Court Maintenance</a_subject>
        <a_details>
            Hi Harbour Tennis Players!

            We are pleased to announce that our maintenance work is complete and all tennis facilities are now available to our section members.
            On that subject, we would like to remind all tennis members of the importance of having tennis section membership and having proper tennis cards in order to use the facilities. As a section we are both partially and fully funding the replacement and maintenance of the infrastructure (i.e. courts) and tennis equipment (nets, lights etc). For this reason non-section members are not allowed to use the tennis courts or receive tennis coaching. For further information, please contact Reza at 018 337-5754 or reza@harbourtennis.com

        </a_details>
    </content>

    <content>
        <a_num>Announcement 3</a_num>
        <a_date>October 17th, 2014</a_date>
        <a_subject>How to reserve court</a_subject>
        <a_details>
            1. Mon-Thurs (4-10pm) - courts are booked via a booking sheet at our tennis court. You can also phone or email our reception to reserve a court. Each afternoon the booking sheet is posted on the tennis notice board, for members to refer to.

            2. Fri – Sun – courts are booked via “walk-in” booking. In order to make a “Walk-in” booking you have to have a tennis section membership card. You make a walk-in booking using the green board on the wall near to the tennis shop. To make one of these bookings a valid booking requires members to fully understand the rules. Common rules to be reminded of are: 
                        • you can only make a booking 30mins beforehand
                        • only one member of the same family can book one court during each hour time-slot
                        • members of the same family cannot book a court for 2 consecutive hours
            It should be noted, however, that if you turn up (or you are already playing) and no one has booked the court you want to use (either by phone booking or Walk-In) or it is 5mins after the hour and the court is empty then any member can claim that court as their own until the hour time slot is finished. 
        </a_details>
    </content>

    <content>
        <a_num>Announcement 4</a_num>
        <a_date>November 3rd, 2014</a_date>
        <a_subject>How to reserve court</a_subject>
        <a_details>
        Our popular summer holiday tennis camps will be held on the following dates:

        11th - 15th November
        18th - 23rd November
        26th -29th November
        Morning session 9 a.m. to 12 noon
        Afternoon session 1 p.m. to 4 p.m.

        Lunch will be 12 noon to 1 p.m.

        Members : RM50 per session 
        Non Members : RM65 per session 
        </a_details>
    </content>

</announcement>

XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
<head>
    <title>Announcement</title>
    <link href="style.css" type="text/css" rel="stylesheet"/>
</head>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
    <div id="wrapper">
        <header>
          <div id="header-left">
              <img src="images/logo-test.png"/>
          </div>
        </header>
        <div class="menu">
            <ul>
                <li class="borderradiusleft">
                    <a href="index.html">Home</a>
                </li>
                <li><a href="#">Information</a>
                    <ul class="sub-menu">
                        <li><a href="history.html">About &amp; History</a></li>
                        <li><a href="rules.html">Tennis Rules</a></li>
                        <li><a href="equipments.html">Equipments</a></li>
                        <li><a href="techniques.html">Techniques</a></li>
                        <li><a href="benefits.html">Benefits</a></li>
                        <li><a href="newsevents.html">News &amp; Events</a></li>
                        <li><a href="tennisclub.html">Tennis Club</a>
                        <ul>
                            <li><a href="newsevents.html">Organization Chart</a></li>
                            <li><a href="membership.html">Membership</a></li>
                        </ul>
                        </li>
                        <li><a href="announcement.xml">Announcement</a></li>
                    </ul>
                </li>
                <li><a href="shop.html">Shop</a></li>
                <li><a href="gallery.html">Gallery</a></li>
                <li class="borderradiusright"><a href="contact_us.html">Contact Us</a></li>
            </ul>
        </div>
        <div id="content-wrapper">
            <xsl:for-each select="announcement/content">
                  <div style="background-color:teal;color:white;padding:4px;margin:2px;">
                    <span style="font-weight:bold"><xsl:value-of select="a_num"/> - </span>
                    <xsl:value-of select="a_date"/>
                  </div>
                  <div style="margin:20px 0px;font-weight:bold"><xsl:value-of select="a_subject"/></div>
                  <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
                    <p>
                    <xsl:value-of select="a_details"/>
                    </p>
                  </div>
            </xsl:for-each>
        </div>
        <footer>
            <div id="footer-left">
                <div class="block">
                    <ul>
                        <li><a href="index.html">Home</a></li>    
                        <li><a href="history.html">About</a></li>
                        <li><a href="gallery.html">Gallery</a></li>
                        <li><a href="newsevents.html">News &amp; Events</a></li>                           
                        <li><a href="cluborganization.html">Club Organization Chart</a></li>          
                    </ul>
                </div>
                <div class="block">
                    <ul>
                      <li><a href="equipments.html">Equipments</a></li>
                      <li><a href="benefits.html">Benefits</a></li>
                        <li><a href="techniques.html">Techniques</a></li>
                        <li><a href="riles.html">Rules of Tennis</a></li>
                        <li><a href="equipments.html">Image Map</a></li>
                    </ul>
                </div>
                <div class="block">
                    <ul>
                      <li><a href="tennisclub.html">Tennis Club</a></li>
                        <li><a href="cluborganization.html">Organization Chart</a></li>
                        <li><a href="membership/form.html">Membership</a></li>
                        <li><a href="contact_us.html">Announcement</a></li>
                    </ul>
                </div>
            </div>
            <div id="footer-right">
                <h4>Get in touch with us</h4>
                <img src="images/logo-test.png" width="90"/>
                <p>
                    <strong>Harbour Island Tennis Centre</strong><br/>
                </p>
            </div>
        </footer>
    </div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

如果很难看到可以在这里下载:

https://www.dropbox.com/s/8p5mnc8e9inmxoj/Announcement.zip?dl=0

我真的非常感谢你的帮助......

非常感谢

1 个答案:

答案 0 :(得分:1)

如果我理解了这种情况,问题在于浏览器不接受未关闭的link元素。尝试将以下元素添加到样式表的顶层(在任何模板之外):

<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>