开发者

XSL Stylesheet need help

I'm having a few problems with my style sheet. Here is my code but now I want to create a style sheet but I'm not sure where to start. Any help would be great. I am not asking anyone to tell me everything but if someone can get me started. I have been through the forums and asked google but its just not sinking in.

<?xml-stylesheet type="text/xsl" href="autotxt.xsl" ?>
<delivery>
<wName>Reston</wName>
<wContact>John McAdams</wContact>
<orderDate>8/15/2005</orderDate>
<recvDate>8/21/2005</recvDate>
<recvBy>David Hanson</recvBy>
<sCost>385</sCost>
<manifest>
  <item itemID="CM204">
     <itemName>Camshaft (Box 20)</itemName>
     <itemQty>10</itemQty>
     <itemPrice>289.95</itemPrice>
  </item>
  <item itemID="CR201">
     <itemName>Carburetor (Box 25)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>159.95</itemPrice>
  </item>
  <item itemID="CRK310">
     <itemName>Crankshaft (Box 10)</itemName>
     <itemQty>3</itemQty>
     <itemPrice>109.95</itemPrice>
  </item>
  <item itemID="DS503">
     <itemName>Distributor (Box 15)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>125.95</itemPrice>
  </item>
  <item itemID="EC501">
     <itemName>Engine Computer (Box 1)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>414.59</itemPrice>
  </item>
  <item itemID="OP460">
     <itemName>Oil Pump (Box 20)</itemName>
     <itemQty>3</itemQty>
     <itemPrice>214.95</itemPrice>
  </item>
  <item itemID="SP300">
     <itemName>Standard Spark Plugs (Box 100)</itemName>
     <itemQty>10</itemQty>
     <itemPrice>114.45</itemPrice>
  </item>
  <item itemID="SP310">
     <itemName>Delux Spark Plugs (Box 100)</itemName>
     <itemQty>10</itemQty>
     <itemPrice>139.95</itemPrice>
  </item>
  <item itemID="TB261">
     <itemName>Timing Belt (Box 40)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>94.90</itemPrice>
  </item>
  <item itemID="TR301">
     <itemName>Transmission (Box 1)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>310.95</itemPrice>
  </item>
  <item itemID="BA105">
     <itemName>Standard Batteries (Box 12)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>495.40</itemPrice>
  </item>
  <item itemID="BA205">
     <itemName>Security Batteries (Box 4)</itemName>
     <itemQty>3</itemQty>
     <itemPrice>289.95</itemPrice>
  </item>
  <item itemID="BA115">
     <itemName>Delux Batteries (Box 12)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>525.95</itemPrice>
  </item>
  <item itemID="SF305">
     <itemName>Standard Air Filters (Box 16)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>148.25</itemPrice>
  </item>
  <item itemID="FI372">
     <itemName>Fuel Injection Kits (Box 1)</itemName>
     <itemQty>15</itemQty>
     <itemPrice>129.95</itemPrice>
  </item>
  <item itemID="BRK681">
     <itemName>Brake Line Kit (Box 1)</itemName>
     <itemQty>25</itemQty>
     <itemPrice>29.95</itemPrice>
  </item>
  <item itemID="CF401">
     <itemName>Cooling Fans (Box 20)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>34.41</itemPrice>
  </item>
  <item itemID="ALT561">
     <itemName>Chrome-plated Alternators (Box 5)</itemName>
     <itemQty>3</itemQty>
     <开发者_开发知识库;itemPrice>105.95</itemPrice>
  </item>
  <item itemID="ALT610">
     <itemName>Alternator Case Kit (Box 1)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>69.95</itemPrice>
  </item>
  <item itemID="CC310">
     <itemName>Catalytic Converters (Box 5)</itemName>
     <itemQty>3</itemQty>
     <itemPrice>121.59</itemPrice>
  </item>
  <item itemID="CC315">
     <itemName>Universal Catalytic Converters (Box 5)</itemName>
     <itemQty>5</itemQty>
     <itemPrice>68.95</itemPrice>
  </item>
  </manifest>
  </delivery>

Here is what I've tried so far

I am doing something wrong can someone give me a idea what.

<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" />
<xsl:template match="/">
<html>
<head>
  <title>Election Night Results</title>
  <link href="autotxt.css" rel="stylesheet" type="text/css" />
</head>

Here is the error I am getting

 Reason: one of the following is expected (see below)
'&'
'&#'
'&#x'
'<!--'
'<![CDATA['
'</'
'<?'
element


You are pretty close with your XSLT, but it is very strict when it comes to formatting. The example you posted is missing the closing template tag and closing stylesheet tag. I updated it and did a simple loop through the items for an example. I also did a quick test using this xslt processor to verify it is generating an html page - http://www.shell-tools.net/index.php?op=xslt

<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" />
<xsl:template match="/">
<html>
    <head>
      <title>Election Night Results</title>
      <link href="autotxt.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <ul>
            <xsl:for-each select="delivery/manifest/item">
            <li>
                <xsl:value-of select="itemName" />
            </li>
            </xsl:for-each>
        </ul>
    </body>
</html>
</xsl:template>
</xsl:stylesheet>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜