xpath-2.0

Shortest XPath to find minimum/maximum of sibling dateTime nodes

99封情书 提交于 2019-12-04 19:45:49
I have the following simple xml: <root> <item> <d>2002-05-30T09:00:00</d> </item> <item> <d>2005-05-30T09:00:00</d> </item> <item> <d>2003-05-30T09:00:00</d> </item> </root> Now I want to find the minimum or maximum dateTime node using XPath. My solution at the moment is: /root/item[not(number(translate(./d, 'TZ:-', '.')) <= number(translate(following-sibling::item, 'TZ:-', '.')))][not(number(translate(./d, 'TZ:-', '.')) <= number(translate(preceding-sibling::item, 'TZ:-', '.')))][1]/d It works but is is ugly as hell and not very efficient. Basically it converts the dateTime to a number and

How to get only numbers from string with XPath

萝らか妹 提交于 2019-12-04 19:33:02
问题 I have a string which contains numbers. Is it feasible only with XPath that I get only numbers from it? For example: myString="abcd12ef34gh567", result: 1234567 回答1: Use : translate(., translate(.,'0123456789',''), '') This is the so called "double-translate" method , first proposed by @Michael Kay and can be used both in XPath 1.0 and in XPath 2.0. Of course, in XPath 2.0 using RegeX will generally be more efficient : replace('abc123def590xyz', '[^\d]', '') 回答2: If you can guarantee that the

Apache Camel Xpath 2.0 with Saxon does not look to work in RouteBuilder / Predicates

筅森魡賤 提交于 2019-12-04 17:21:50
I am using ServiceMix 4.5.3 which includes Camel 2.10.7 and I am able to make XSLT 2.0 transformations with the Saxon library using the option endpoint like this: ... to("xslt:stylesheet.xsl?transformerFactoryClass=net.sf.saxon.TransformerFactoryImpl") ... However when I try to use the xpath function like this: private Namespaces ourNS = new Namespaces("myns", "urn:com:company:domain:namespace:myns/1"); // ... some code ... // Make a predicate to filter according a header : // The code attribute looks like: urn:phone:apple:iphone:4s Predicate isNotSamePhoneBrand = PredicateBuilder.isNotEqualTo

Is there any XPath expression for String Padding in wso2 ESB?

孤者浪人 提交于 2019-12-04 04:56:15
问题 I have enabled XPath 2.0 configuration synapse.xpath.dom.failover.enabled=true in synapse.properties but still unable to get string padding done. Is there any expression to achieve it? Edit : The length of a particular string needs to be 10 chars, if it is lesser than it, we have to pad it with the special character '%'. Eg., Input = ' WSO2 ', after padding it should be ' WSO2%%%%%% ' Thanks in advance 回答1: This can be achieved using XPath 1.0 like so, assuming that "WSO2" will be replaced by

XSL if test starts-with

拈花ヽ惹草 提交于 2019-12-03 13:15:41
Given this piece of XML <dc:date>info:eu-repo/date/embargoEnd/2013-06-12</dc:date> <dc:date>2012-07-04</dc:date> I should need with XSL to output only the year of the string not starting with info:eu-repo . I'm trying this way, but it doesn't work. I'm wrong with the for-each ? <xsl:if test="not(starts-with('dc:date', 'info:eu-repo'))"> <xsl:for-each select="dc:date"> <publicationYear> <xsl:variable name="date" select="."/> <xsl:value-of select="substring($date, 0, 5)"/> </publicationYear> </xsl:for-each> </xsl:if> I guess you don't need ' in your start-with query, and you may want to iterate

How to get only numbers from string with XPath

不打扰是莪最后的温柔 提交于 2019-12-03 13:14:33
I have a string which contains numbers. Is it feasible only with XPath that I get only numbers from it? For example: myString="abcd12ef34gh567", result: 1234567 Use : translate(., translate(.,'0123456789',''), '') This is the so called "double-translate" method , first proposed by @Michael Kay and can be used both in XPath 1.0 and in XPath 2.0. Of course, in XPath 2.0 using RegeX will generally be more efficient : replace('abc123def590xyz', '[^\d]', '') If you can guarantee that the non-digit characters will be only lower-case letters (like in your example), you could do the following in XPath

XPath: Match whole word (using matches function with case insensitive flag)

依然范特西╮ 提交于 2019-12-03 03:34:26
Using XPath, I would like to "Match whole word" (option for user, just like in VS search). It seems as though the functions contains and matches work similarly though matches allows for flags like i for case insensitivity. In other words, I am getting the same results with these two XPath queries: <pets> <dog name="Rupert" color="grey"/> <dog name="Ralph" color="brown"/> <cat name="Marvin the Cat" color="white"/> <cat name="Garfield the Cat" color="orange"/> <cat name="Cat" color="grey"/> <cat name="Fluffy" color="black"/> </pets> Matches XPath: //cat[descendant-or-self::*[@*[matches(.,'Cat')]

How to escape apostrophe in WSO2 property XPath expression

試著忘記壹切 提交于 2019-12-02 03:12:24
My problem is to quote the values obtained from get-property('cf') in <property expression="fn:concat(get-property('whereConcat'),' AND PA_INATO=', get-property('cf'))" name="whereConcat" scope="default" type="STRING"/> I have tried in different ways(character encoding: &apos; , character escape: \' ) but without success. the cleanest way is to define a constant: <property name="apos" scope="default" type="STRING" value="'"/> and then use it as follow: <property expression="fn:concat(get-property('whereConcat'),' AND PA_INATO=',get-property('apos'), get-property('cf'),get-property('apos'))"

How to escape apostrophe in WSO2 property XPath expression

我只是一个虾纸丫 提交于 2019-12-02 02:12:44
问题 My problem is to quote the values obtained from get-property('cf') in <property expression="fn:concat(get-property('whereConcat'),' AND PA_INATO=', get-property('cf'))" name="whereConcat" scope="default" type="STRING"/> I have tried in different ways(character encoding: &apos; , character escape: \' ) but without success. 回答1: the cleanest way is to define a constant: <property name="apos" scope="default" type="STRING" value="'"/> and then use it as follow: <property expression="fn:concat(get

Is there any XPath expression for String Padding in wso2 ESB?

只谈情不闲聊 提交于 2019-12-02 01:35:32
I have enabled XPath 2.0 configuration synapse.xpath.dom.failover.enabled=true in synapse.properties but still unable to get string padding done. Is there any expression to achieve it? Edit : The length of a particular string needs to be 10 chars, if it is lesser than it, we have to pad it with the special character '%'. Eg., Input = ' WSO2 ', after padding it should be ' WSO2%%%%%% ' Thanks in advance har07 This can be achieved using XPath 1.0 like so, assuming that "WSO2" will be replaced by dynamic input string in the actual implementation : substring(concat('WSO2', '%%%%%%%%%%'), 1, 10)