首页 \ 问答 \ XSLT Select with 2 contains(XSLT Select with 2 contains)

XSLT Select with 2 contains(XSLT Select with 2 contains)

我们使用以下命令选择'ExperienceInfo'包含'582'的所有节点:

<xsl:apply-templates disable-output-escaping="yes" select="td:Benutzer_zu_Gastro[contains(td:ExperienceInfo, '582')]">

这将选择'Kategorien'包含'Restaurant'的所有节点:

<xsl:apply-templates disable-output-escaping="yes" select="td:Benutzer_zu_Gastro[contains(td:Kategorien, 'Restaurant')]">

我们如何将两者合并为一个语句,以便在ExperienceInfo包含582 AND Kategorien包含餐馆的地方选择ONLY节点?

非常感谢您的帮助!


We are using the following to select all nodes where 'ExperienceInfo' contains '582':

<xsl:apply-templates disable-output-escaping="yes" select="td:Benutzer_zu_Gastro[contains(td:ExperienceInfo, '582')]">

And this to select all nodes where 'Kategorien' contains 'Restaurant':

<xsl:apply-templates disable-output-escaping="yes" select="td:Benutzer_zu_Gastro[contains(td:Kategorien, 'Restaurant')]">

How do we combine the two into ONE statement so that ONLY nodes are selected where ExperienceInfo contains 582 AND Kategorien contains Restaurant?

Many thanks for any help!


原文:https://stackoverflow.com/questions/17588923
更新时间:2023-01-03 11:01

最满意答案

问题是这个值取决于上下文。 它通常是指当前对象,在第二种情况下是回调函数。 通过赋值obj = this您可以在变量obj保留对Slider的原始引用,因此调用了managed.push ,在第二种情况下,您尝试调用不存在的回调函数的managed.push函数。

一个非常好的解释: http : //www.quirksmode.org/js/this.htmlhttp://javascriptweblog.wordpress.com/2010/08/30/understanding-javascripts-this/


The problem is that value of this depends on the context. It usually refers to the current object, which in the second case is the callback function. By assigning obj = this you keep the original reference to Slider in the variable obj, therefore calling managed.push works, in the second case you are trying to call managed.push function on the callback function which doesn't exist.

A really great explanation of this: http://www.quirksmode.org/js/this.html and http://javascriptweblog.wordpress.com/2010/08/30/understanding-javascripts-this/

相关问答

更多
  • 问题是您没有在任何地方定义customData变量。 以下创建变量来存储JSON的方法将解决您的问题。 检查以下代码: var customData = {"foo":"bar"}; $('#calendar').fullCalendar({ .... firstDay: 1, customData: customData, dayClick: function(date, allDay, jsEvent, view) { // Within the callback function, this ...
  • 问题是这个值取决于上下文。 它通常是指当前对象,在第二种情况下是回调函数。 通过赋值obj = this您可以在变量obj保留对Slider的原始引用,因此调用了managed.push ,在第二种情况下,您尝试调用不存在的回调函数的managed.push函数。 一个非常好的解释: http : //www.quirksmode.org/js/this.html和http://javascriptweblog.wordpress.com/2010/08/30/understanding-javascrip ...
  • "*ok*" 这是无效的JSON。 如果您需要使用纯文本进行响应,请不要发送JSON响应。 format.text { render text: “*ok*” } 或者如果服务器没有发出text/plaintext GET请求,只需在没有respond_to块的情况下进行响应。 render text: "*ok*" and return "*ok*" This is invalid JSON. If you need to respond with plaintext, don't send a ...
  • setInterval(update, 0); 您可以尽快生成Ajax请求。 然后你的资源耗尽(可能在第一个请求被处理之前)。 运行update功能一次 ,然后从success和error功能内部再次调用它(最好使用基于setTimeout的延迟)。 setInterval(update, 0); You keep spawning Ajax requests as fast as possible. Then you run out of resources (probably before the ...
  • 我假设您的代码所在的文档不在http://postnummersok.se 。 如果不是,那么您将遇到同源策略 ,该策略不会(通常)允许ajax请求跨越原点。 如果这是一个公开可用的服务,他们可能支持JSON-P ,它不受SOP的约束。 jQuery也支持它,因此它可能像更改代码一样简单: $.getJSON(url, function(data) { $('#result').html(data); }); 对此 $.ajax({ url: url, dataType: ...
  • callback参数用于实现JSONP 。 jQuery的getJSON方法创建一个