xsl-list
[Top] [All Lists]

Re: [xsl] use contains() function on a node set in XPath 1.0

2022-03-05 10:26:42
Thank you very much, Wendell, for the prompt reply! Yes, both options work in my case.


On 05-03-22 12:49, Wendell Piez wapiez(_at_)wendellpiez(_dot_)com wrote:
Wolfhart --

Try this -- //notion[*[contains(.,'string')]]

It returns all notion elements with any children containing 'string'.

More concisely, //notion[contains(.,'string')] returns all notions containing 'string' - which is the same thing if notions contain only elements, not text nodes.

XPath 1.0 is still in scope for this list!

Enjoy, Wendell





On Sat, Mar 5, 2022 at 10:44 AM Wolfhart Totschnig wolfhart(_dot_)totschnig(_at_)mail(_dot_)udp(_dot_)cl <mailto:wolfhart(_dot_)totschnig(_at_)mail(_dot_)udp(_dot_)cl> <xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com <mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>> wrote:

    Hello,

    My question is about XPath 1.0, not XSL, but I hope that I may still
    pose it here. The problem is, precisely, that I cannot use XSL
    because I
    am in a PHP context, using DOM to perform XPath queries on an XML
    document.

    The situation is the following: I have <notion> elements that contain
    one <name> element and zero or more <translation> elements. I want to
    select them according to whether any of these child elements
    contains a
    certain string. I was hoping that it would be as easy as this:

    //notion[contains(*, "string")]

    But then I realized that the contains() function evaluates only the
    first node of the set of child elements. So how can I do what I
    want to
    do? Since I am using DOM, I have to remain within XPath 1.0.

    Thanks in advance for your help!
    Wolfhart




--
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez. <http://github.com/wendellpiez.>.. ...gitlab.coko.foundation/wendell...
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2652055> (by email <>)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>