【发布时间】:2011-01-02 01:08:24
【问题描述】:
感谢 Bishiboosh 和 fmsf。作为 建议,我们要做 通过看起来更明显的XSL 问题的答案(详细 请阅读以下问题)。
我们必须创建一个 XSL,它将 搜索关键字并与节点匹配 名称/值、属性名称/值等。 一切都在 XML 中。
XML
<?xml version="1.0"?> <CustomerList> <Customer> <CustomerID>1111</CustomerID> <CompanyName>Sean Chai</CompanyName> <City>New York</City> <NewCustomer>N</NewCustomer> </Customer> <Customer> <CustomerID>1112</CustomerID> <CompanyName>Tom Johnston</CompanyName> <City>Los Angeles</City> <NewCustomer>N</NewCustomer> </Customer> <Customer> <CustomerID>1113</CustomerID> <CompanyName>Institute of Art</CompanyName> <City>Chicago</City> <NewCustomer>Y</NewCustomer> </Customer> </CustomerList>XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:choose> <!-- // We'll match the node/attribute name/values // with search text. If it is match to node // name/value we have to put a div/b tag around // it or it is match to attribute then the div/b // tag will be around it's node. --> <xsl:when test=""> <xsl:value-of select="" /> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="@* | node()"/> </xsl:otherwise> </xsl:choose> </xsl:copy> </xsl:template> </xsl:stylesheet>我在完成时遇到问题 XSL。我们希望得到一些帮助 搞定。
谢谢。
嗨,
我必须在产品的基于 Web 的帮助系统中添加一项功能。外观和功能与我们在桌面软件帮助中看到的几乎相同,按 F1 会弹出。
我必须添加的功能是一个搜索功能,用户输入一个文本,一个 Ajax 将被调用,请求将定向到服务器,在那里它将响应作为一个包含列表的 XML XML 模式。这已经完成了!除了。
让我先来看看应用程序 UI。所以,当我们讨论这个技术细节时,你会有一个更好的主意。
_________________________________________________
| Search |
|__________________| XML SCHEMA OPEN HERE ...
(1) FRAME A | Type here... | (2) FRAME B
|__________________|
| |
| . RESULT LINK 1 |
| . RESULT LINK 2 |
| . RESULT LINK 3 |
| |
| |
| |
| |
| |
它是如何工作的?搜索结果将显示为超链接(如上图 RESULT LINK 1...3)。当用户单击这些链接之一时,架构将加载到框架 B 中,并且浏览器滚动到搜索的关键字。
如果您需要了解,还有一件更重要的事情,XML Schema 将直接在 Frame B 中引用。即
$(iframe).src = "XMLSchema.xml"
首先,让我们假设几乎所有初始工作都已完成,例如搜索、处理、构成结果链接并单击它们,我们在正确的框架(框架 B)中获得了正确的架构。
问题是当 XML 模式加载到正确的框架中时,它还应该滚动并突出显示第一个搜索到的关键字。
我不认为高亮在那里是可能的,因为文档是 XML 格式,而且我告诉 Frame B 有 XML 文件的直接引用。但是,搜索和滚动有一个公平的概率吗?是的?没有?
您知道如何滚动到 XML 文件中的搜索关键字吗?
谢谢。
PS:如果您有任何疑问,请发表评论。
【问题讨论】:
标签: javascript xml xslt