XSLT 1 对祖先的不同选择
我在制定正确的语句以返回唯一的值列表时遇到了一些麻烦。下面的路径只是一个例子,和我的困境类似。
/Root/Books/Book/Writers/Writer/Fullname
什么会返回“全名”的唯一列表,请记住这里的假设是每本书都有多个作者,并且他们可能涉及多本书。
感谢您的帮助
这是 XML 文档的示例
<Root>
<Books>
<Book>
<Title>Book A</Title>
<Writers>
<Writer>Jon Smith</Writer>
<Writer>Peter Smith</Writer>
</Writers>
</Book>
<Book>
<Title>Book B</Title>
<Writers>
<Writer>Jon Smith</Writer>
<Writer>Peter Smith</Writer>
<Writer>James Bloggs</Writer>
</Writers>
</Book>
<Book>
<Title>Book C</Title>
<Writers>
<Writer>Bob Peterson</Writer>
<Writer>Peter Smith</Writer>
<Writer>James Bloggs</Writer>
</Writers>
</Book>
</Books>
</Root>
我想返回的是不同作者的列表。
乔恩·史密斯 彼得·史密斯 詹姆斯·布洛格斯 鲍勃·彼得森。
这比较棘手,因为有多本书有多个作者。
I've had a bit of trouble working out the correct statement to return a unique list of values. The following path is just an example, which is similar to my dilemma.
/Root/Books/Book/Writers/Writer/Fullname
What would return the unique list of "fullnames", keeping in mind that the assumption here is there are multiple writers for each book and they may be involved in multiple books.
Thanks for your help
Here is an example of the XML document
<Root>
<Books>
<Book>
<Title>Book A</Title>
<Writers>
<Writer>Jon Smith</Writer>
<Writer>Peter Smith</Writer>
</Writers>
</Book>
<Book>
<Title>Book B</Title>
<Writers>
<Writer>Jon Smith</Writer>
<Writer>Peter Smith</Writer>
<Writer>James Bloggs</Writer>
</Writers>
</Book>
<Book>
<Title>Book C</Title>
<Writers>
<Writer>Bob Peterson</Writer>
<Writer>Peter Smith</Writer>
<Writer>James Bloggs</Writer>
</Writers>
</Book>
</Books>
</Root>
What I'd like to return is a list of the different writers.
Jon Smith
Peter Smith
James Bloggs
Bob Peterson.
It's trickier because there are multiple books with multiple writers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
按照 Robert 的 链接 进行分组操作的第一步:
Follow Robert's link and just do the first step of the grouping recipe: