以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  谁能帮我看看下面的XML+DTD+XSL为什么在浏览器上显示不出来?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=41194)


--  作者:落地尘埃
--  发布时间:12/14/2006 11:32:00 AM

--  谁能帮我看看下面的XML+DTD+XSL为什么在浏览器上显示不出来?
该project由三个文件组成:shoppingt-cart.dtd,shopping-cart.xml,transform.xsl,这三个文档经检验都是格式良好的文档,但是在浏览器上却没有任何内容显示出来,请高手帮我看看!
     下面是各文件的主要内容:
1.DTD
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT shopping-cart (header, items)>
<!ELEMENT header (customer, order-type)>
<!ELEMENT customer (contact)>
<!ELEMENT order-type (#PCDATA)>
<!ELEMENT contact (#PCDATA)>
<!ATTLIST shopping-cart
 xmlns CDATA #REQUIRED
>
<!ATTLIST customer
 id ID #REQUIRED
 billingId CDATA "001"
 shippingId CDATA "001"
>
<!ELEMENT items (item*)>
<!ELEMENT item (quantity, list-price, description)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT list-price (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ATTLIST item
 id ID #REQUIRED
 productLine CDATA #REQUIRED
>

2. 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="item">
    <div>
      Name=<xsl:value-of select="@id"/>,
      Quantity=<xsl:value-of select="quantity"/>
    </div>
  </xsl:template>

<xsl:template match="/">
    <html>
      <head>
        <title>Transformation Example</title>
      </head>
      <body>
        <xsl:apply-templates select="//item" />
      </body>
    </html>
</xsl:template>

</xsl:stylesheet>

3.XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"   href="transform.xslt"?>
<?custom-error code="0" message="OK"?>
<!--Shopping Cart Example-->
<!DOCTYPE shopping-cart SYSTEM "shopping-cart.dtd">
<shopping-cart xmlns="urn:wrox-asp.net-xml-xpath">
 <header>
  <customer id="P4LLC" billingId="001" shippingId="001">
   <contact>Toshia Palermo</contact>
  </customer>
  <order-type>Regular</order-type>
 </header>
 <items>
  <item id="ITM-1001" productLine="1">
   <quantity>1</quantity>
   <list-price>123.45</list-price>
   <description>Gadget XYZ</description>
  </item>
  <item id="ITM-1002" productLine="1">
   <quantity>3</quantity>
   <list-price>4.00</list-price>
   <description>XYZ Accessory</description>
  </item>
  <item id="ITM-1003" productLine="2">
   <quantity>1</quantity>
   <list-price>15.00</list-price>
   <description>Gizmo Part</description>
  </item>
  <item id="ITM-1004" productLine="3">
   <quantity>1</quantity>
   <list-price>44.00</list-price>
   <description>Widget X</description>
  </item>
 </items>
</shopping-cart>

    万分谢谢!

[此贴子已经被作者于2006-12-14 12:03:08编辑过]

--  作者:hexun831012
--  发布时间:12/14/2006 12:22:00 PM

--  
在XML中添加DTD声明DOM是不识别的
--  作者:落地尘埃
--  发布时间:12/14/2006 6:44:00 PM

--  
不太明白楼上的意思啊,能否说的具体一点。上面给出的DTD文档与XML文档的组合,偶在XMLSPY中检查是没有问题的,前提是要把上面的三个文件都放在同一个文件夹下。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms