enter image description here我上课的期末考试有些麻烦。我有我的XML,它已经过验证。我做了一个XSL,我只能在客户信息表中看到一个表。我已经尽一切努力使这些其他表显示在网页上,但是什么也没有。请帮我。我将在评论部分发布图片,以便每个人都可以看到正在发生的事情。另外,当我检查XSL时,它也得到了很好的验证,这就是为什么它如此混乱的原因,我不知道我要怎么做。
XML
True
XSL
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="vendor.xsl"?>
<!DOCTYPE orderform1 SYSTEM "vendor.dtd">
<orderform1>
<customers>
<customer>
<name>
<title>MR.</title>
<first>Bob</first>
<middle>Thomas</middle>
<last>Smith</last>
</name>
<mail_a>
<line1>453 N. Hartman St.</line1>
<line2></line2>
<city>Omaha</city>
<state>NE</state>
<zip>68111</zip>
</mail_a>
<c_num>001</c_num>
</customer>
<customer>
<name>
<title>MRS.</title>
<first>Mary</first>
<middle>Bell</middle>
<last>Moore</last>
</name>
<mail_a>
<line1>2104 Jones Ave.</line1>
<line2></line2>
<city>Carson City</city>
<state>NV</state>
<zip>89701</zip>
</mail_a>
<c_num>020</c_num>
</customer>
<customer>
<name>
<title>MISS.</title>
<first>Brittany</first>
<middle>Lynn</middle>
<last>Murry</last>
</name>
<mail_a>
<line1>3526 Jackson ST</line1>
<line2></line2>
<city>Millersburg</city>
<state>MO</state>
<zip>65251</zip>
</mail_a>
<c_num>003</c_num>
</customer>
<customer>
<name>
<title>DR.</title>
<first>Edward</first>
<middle>Taylor</middle>
<last>Jones</last>
</name>
<mail_a>
<line1>3411 Dewey Ave</line1>
<line2></line2>
<city>Fulton</city>
<state>MO</state>
<zip>65364</zip>
</mail_a>
<c_num>400</c_num>
</customer>
<customer>
<name>
<title>MS.</title>
<first>Anne</first>
<middle>Marie</middle>
<last>Love</last>
</name>
<mail_a>
<line1>3132 Willit St..</line1>
<line2></line2>
<city>Reno</city>
<state>NV</state>
<zip>89601</zip>
</mail_a>
<c_num>051</c_num>
</customer>
</customers>
<product_information>
<product_description>2 pack of Gold Forks</product_description>
<catgory>Ktichenware</catgory>
<upc>3426381901</upc>
<p_vend>ABC Inc.</p_vend>
<c_information>1 qty</c_information>
<cost>$2.99</cost>
<retail_cost>$6.99</retail_cost>
<product_description>4 pack of Teal Plates</product_description>
<catgory>Ktichenware</catgory>
<upc>942676142</upc>
<p_vend>ABC Inc.</p_vend>
<c_information>1 qty</c_information>
<cost>$10.24</cost>
<retail_cost>$24.99</retail_cost>
<product_description>6 pack of Clear Glass Drinking Glasses</product_description>
<catgory>Ktichenware</catgory>
<upc>3064491314</upc>
<p_vend>ABC Inc.</p_vend>
<c_information>1 qty</c_information>
<cost>$13.56</cost>
<retail_cost>$34.99</retail_cost>
<product_description>EVG A Geforce GTX 970 4GB SC Gaming ACX 2.0 26% cooler and 36% quieter cooling Graphics Card 04G-P4-2974-KR</product_description>
<catgory>Computer Hardware</catgory>
<upc>1706191112</upc>
<p_vend>Molly's Computer Repair</p_vend>
<c_information>1 qty</c_information>
<cost>$120.00</cost>
<retail_cost>$246.37</retail_cost>
<product_description>Corsair CMZ32GX3M4Z1600C10 Vengance 32GB (4x8GB) DDR3 1600 MHz (PC3 12800) Desktop Memory</product_description>
<catgory>Computer Hardware</catgory>
<upc>1231274213</upc>
<p_vend>Molly's Computer Repair</p_vend>
<c_information>1 qty</c_information>
<cost>$175.64</cost>
<retail_cost>$264.24</retail_cost>
<product_description>Axial LS1238,muffin 120V AC PC Cooling Fan</product_description>
<catgory>Computer Hardware</catgory>
<upc>0647069969</upc>
<p_vend>Molly's Computer Repair</p_vend>
<c_information>1 qty</c_information>
<cost>$2.99</cost>
<retail_cost>$14.99</retail_cost>
<product_description>Pink Lace Push-up Bra size 46 FF</product_description>
<catgory>Clothing</catgory>
<upc>3696841106</upc>
<p_vend>Love B's Underclothes Company</p_vend>
<c_information>1 qty</c_information>
<cost>$5.42</cost>
<retail_cost>$24.99</retail_cost>
<product_description>Themed Boy Shorts (Underware) 3 pair</product_description>
<catgory>Clothing</catgory>
<upc>4252698403</upc>
<p_vend>Love B's Underclothes Company</p_vend>
<c_information>1 qty</c_information>
<cost>$3.08</cost>
<retail_cost>$13.41</retail_cost>
<product_description>Mens White Ankle Sock (1 pack,8 pair)</product_description>
<catgory>Clothing</catgory>
<upc>1926769334</upc>
<p_vend>Love B's Underclothes Company</p_vend>
<c_information>1 qty</c_information>
<cost>$1.99</cost>
<retail_cost>$6.75</retail_cost>
</product_information>
<vendor>
<bus_name>ABC Inc.</bus_name>
<contact_information>Mattew Smith</contact_information>
<b_address>
<line1>511 N. 3rd</line1>
<line2></line2>
<city>Reno</city>
<state>NV</state>
<zip>89889</zip>
</b_address>
<vendor_id>982746</vendor_id>
<bus_name>Molly's Computer Repair</bus_name>
<contact_information>Bucky Daniels</contact_information>
<b_address>
<line1>9564 N.96th St.</line1>
<line2></line2>
<city>Elko</city>
<state>NV</state>
<zip>89801</zip>
</b_address>
<vendor_id>467910</vendor_id>
<bus_name>Love B's Underclothes Company</bus_name>
<contact_information>Kristie Robbs</contact_information>
<b_address>
<line1>549 S. 55 Ave.</line1>
<line2></line2>
<city>Reeding</city>
<state>CA</state>
<zip>96723</zip>
</b_address>
<vendor_id>116424</vendor_id>
</vendor>
<orders>
<order>
<date>04-20-2017</date>
<c_num>001</c_num>
<pur_deatails>6 pack of Clear Glass Drinking Glasses,Axial LS1238,muffin 120V AC PC Cooling Fan, Mens White Ankle Sock (1 pack,8 pair)</pur_deatails>
<total_before_tax>$56.37</total_before_tax>
<tax>$3.94</tax>
<total_after_tax>$60.31</total_after_tax>
<item_count>3</item_count>
</order>
<order>
<date>03-05-2016</date>
<c_num>020</c_num>
<pur_deatails>2 pack of Gold Forks, 4 pack of Teal Plates, Pink Lace Push-up Bra size 46 FF</pur_deatails>
<total_before_tax>$56.97</total_before_tax>
<tax>$3.98</tax>
<total_after_tax>$60.95</total_after_tax>
<item_count>3</item_count>
</order>
<order>
<date>07-13-2018</date>
<c_num>003</c_num>
<pur_deatails>2 pack of Gold Forks, 4 pack of Teal Plates, Themed Boy Shorts (Underware) 3 pair</pur_deatails>
<total_before_tax>$45.39</total_before_tax>
<tax>$3.17</tax>
<total_after_tax>$48.56</total_after_tax>
<item_count>3</item_count>
</order>
<order>
<date>02-29-2017</date>
<c_num>400</c_num>
<pur_deatails>EVG A Geforce GTX 970 4GB SC Gaming ACX 2.0 26% cooler and 36% quieter cooling Graphics Card 04G-P4-2974-KR, Corsair CMZ32GX3M4Z1600C10 Vengance 32GB (4x8GB) DDR3 1600 MHz (PC3 12800) Desktop Memory, Axial LS1238,muffin 120V AC PC Cooling Fan</pur_deatails>
<total_before_tax>$525.60</total_before_tax>
<tax>$36.79</tax>
<total_after_tax>$562.39</total_after_tax>
<item_count>3</item_count>
</order>
<order>
<date>10-10-2016</date>
<c_num>051</c_num>
<pur_deatails>6 pack of Clear Glass Drinking Glasses, Pink Lace Push-up Bra size 46 FF, Themed Boy Shorts (Underware) 3 pair</pur_deatails>
<total_before_tax>$73.39</total_before_tax>
<tax>$5.13</tax>
<total_after_tax>$78.52</total_after_tax>
<item_count>3</item_count>
</order>
</orders>
</orderform1>
答案 0 :(得分:0)
为显示product
,vendor
和order
信息而指定的XPath不正确,这就是原因,您在这些表的输出中未得到任何结果。>
节点<customers>
,<product_information>
,<vendor>
和<orders>
是彼此的兄弟姐妹和orderform1
的子元素,因此应使用XPath {{ 1}},orderform1/customers
等。因此,orderform1/product_information
循环的XPath应该看起来像
for-each
第二,输入XML对<xsl:for-each select="orderform1/product_information">
....
</xsl:for-each>
<xsl:for-each select="orderform1/vendor">
....
</xsl:for-each>
<xsl:for-each select="orderform1/orders/order">
....
</xsl:for-each>
重复了<customer>
个节点,对Customer Information
重复了order
个节点。可以使用Order Information
轻松地循环这些,以获取所需的输出。
但是,为了获得for-each
和Product Information
,没有像Vendor Information
或product
这样的重复节点,并且多个vendor
和product
的数据是分别在单个节点vendor
和product_information
下可用。在这种情况下,vendor
将无法准备表,因为它将在单个for-each
中输出多个元素的所有数据。
如果您使用的是XSLT 2.0,则需要使用<td>
和for-each-group
功能来准备输出数据。
我不确定输入的XML是否缺少某些内容,但是需要根据上述建议修复XSL,以使这些内容正常工作。