【发布时间】:2013-11-16 10:18:18
【问题描述】:
我的问题是我想为每个项目按模型分组,但我只想加载单个实体的详细信息
<Search-Request search-term="1 tb">
<Items>
<Item href="SEA1TBST31000524AS.jpg" model="ST31000524AS">
<Name>Seagate Hard disk 1TB ST31000524AS 3.5"</Name>
<Price>60.50</Price>
<SupplierCode>TECSEA1TB</SupplierCode>
<Supplier>TEC001</Supplier>
<Manufacturer>Seagate</Manufacturer>
<CustomerReviews>
<Review>
<Reviewer>Hayley Park</Reviewer>
<Rating>5</Rating>
<Review>I bought this because my boyfriend suggested it. But I am glad I did since it has a good amount of storage. And was quite cheap.</Review>
</Review>
<Review>
<Reviewer>Bill Gates</Reviewer>
<Rating>3</Rating>
<Review>Not that big storage wise but can't complain too much about price.</Review>
</Review>
<Review>
<Reviewer>Jean Pierre Said</Reviewer>
<Rating>4</Rating>
<Review>So far I've been using this product for a year and have no disregrets since it is much better than the previous hdd which I had which was only 256GB.</Review>
</Review>
</CustomerReviews>
</Item>
<Item href="" model="ST31000524AS">
<Name>Seagate Hard disk 1TB ST31000524AS 3.5 inch</Name>
<Price>55.50</Price>
<SupplierCode>SCASEA1TB</SupplierCode>
<Supplier>SCA001</Supplier>
<Manufacturer>Seagate</Manufacturer>
<CustomerReviews>
<Review>
<Reviewer>Kyle Werner</Reviewer>
<Rating>4</Rating>
<Review>Very reliable product and at a great price.</Review>
</Review>
<Review>
<Reviewer>Scar Russo</Reviewer>
<Rating>5</Rating>
<Review>My only regret is that I didn't buy this after the price drop. Overall the product is great value for money.</Review>
</Review>
<Review>
<Reviewer>Stan Lee</Reviewer>
<Rating>1</Rating>
<Review>I don't know if it's me but this product burned out on me after just 2 weeks.</Review>
</Review>
</CustomerReviews>
</Item>
</Items>
所以上面的 XML 将包含遇到的第一个元素
<Item href="SEA1TBST31000524AS.jpg" model="ST31000524AS">
<Name>Seagate Hard disk 1TB ST31000524AS 3.5"</Name>
<Manufacturer>Seagate</Manufacturer>
</Item>
我想知道是否可以同时选择两个价格,然后只选择要显示的最佳价格。例如,其他价格可以在工具提示中列出。
并明智地将它们组合起来
我知道这并不简单。
我很容易就能在每个项目上用一个 for each 列出它们。
但我也希望它看起来更精致,但要求是不使用高级语言代码,所以我问你们这是否可能。
如果可能的话,可以将项目拆分为多个页面,例如每页显示 5 个。虽然这不是必需的,但它只是美观的东西,我想知道它是否可能。
【问题讨论】:
-
这是一个非常简单的任务。您要查找的关键字是“Muenchian grouping”和“
<xsl:key>”。仅在 StackOverflow 上就有数百个示例。您需要指定输出 HTML 的样子(我认为到目前为止您还没有这样做)。那请大家自己尝试解决,遇到卡住的时候发个代码示例。