xpath-2.0

Nested conditional if else statements in xpath

情到浓时终转凉″ 提交于 2019-11-30 18:54:07
I have this XML: <property id="1011"> <leasehold>No</leasehold> <freehold>Yes</freehold> <propertyTypes> <propertyType>RESIDENTIAL</propertyType> </propertyTypes> </property> and I want to create an xpath statement that is same as the following nested if-else pseudocode block. if( propertyTypes/propertyType == 'RESIDENTIAL') { if( leasehold == 'Yes' ){ return 'Rent' } else return 'Buy' } } else { if( leasehold == 'Yes' ){ return 'Leasehold' } else return 'Freehold' } } I've seen something about Becker's method but I couldn't really follow it. XPath isn't my strong point really. I. In XPath 2.0

Convert dateTime to unix epoch in xslt

混江龙づ霸主 提交于 2019-11-30 14:53:29
问题 I have a dateTime variable, and I want to convert it to a decimal value of epoch. How can this be done? I tried using: seconds-from-duration($time, xs:dateTime('1970-01-01T00:00:00')) but it just returns 0. Please advice. Thanks. 回答1: This transformation : <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:sequence select="current-dateTime()"/> <xsl:sequence

Convert dateTime to unix epoch in xslt

偶尔善良 提交于 2019-11-30 12:09:41
I have a dateTime variable, and I want to convert it to a decimal value of epoch. How can this be done? I tried using: seconds-from-duration($time, xs:dateTime('1970-01-01T00:00:00')) but it just returns 0. Please advice. Thanks. This transformation : <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:sequence select="current-dateTime()"/> <xsl:sequence select= "( current-dateTime() - xs:dateTime('1970-01-01T00:00:00') ) div xs:dayTimeDuration('PT1S') "/> </xsl

XPathEvalError: Unregistered function for matches() in lxml

白昼怎懂夜的黑 提交于 2019-11-30 10:06:11
i am trying to use the following xpath query in python from lxml.html.soupparser import fromstring root = fromstring(inString) nodes = root.xpath(".//p3[matches(.,'ABC')]//preceding::p2//p3") but it gives me the error nodes = root.xpath(".//p3[matches(.,'ABC')]//preceding::p2//p3") File "lxml.etree.pyx", line 1507, in lxml.etree._Element.xpath (src\lxml\lxml.etree.c:52198) File "xpath.pxi", line 307, in lxml.etree.XPathElementEvaluator.__call__ (src\lxml\lxml.etree.c:152124) File "xpath.pxi", line 227, in lxml.etree._XPathEvaluatorBase._handle_result (src\lxml\lxml.etree.c:151097) File "xpath

Nested conditional if else statements in xpath

邮差的信 提交于 2019-11-30 03:04:02
问题 I have this XML: <property id="1011"> <leasehold>No</leasehold> <freehold>Yes</freehold> <propertyTypes> <propertyType>RESIDENTIAL</propertyType> </propertyTypes> </property> and I want to create an xpath statement that is same as the following nested if-else pseudocode block. if( propertyTypes/propertyType == 'RESIDENTIAL') { if( leasehold == 'Yes' ){ return 'Rent' } else return 'Buy' } } else { if( leasehold == 'Yes' ){ return 'Leasehold' } else return 'Freehold' } } I've seen something

XPathEvalError: Unregistered function for matches() in lxml

佐手、 提交于 2019-11-29 15:44:08
问题 i am trying to use the following xpath query in python from lxml.html.soupparser import fromstring root = fromstring(inString) nodes = root.xpath(".//p3[matches(.,'ABC')]//preceding::p2//p3") but it gives me the error nodes = root.xpath(".//p3[matches(.,'ABC')]//preceding::p2//p3") File "lxml.etree.pyx", line 1507, in lxml.etree._Element.xpath (src\lxml\lxml.etree.c:52198) File "xpath.pxi", line 307, in lxml.etree.XPathElementEvaluator.__call__ (src\lxml\lxml.etree.c:152124) File "xpath.pxi",

how to get the most deeply nested element nodes using xpath? (implementation with XMLTWIG)

偶尔善良 提交于 2019-11-29 07:48:57
I need to extract (XSLT, xpath, xquery... Preferably xpath) the most deeply nested element nodes with method (DEST id="RUSSIA" method="delete"/>) and his direct ancestor (SOURCE id="AFRICA" method="modify">). I don't want to get the top nodes with methods ( main method="modify"> or main method="modify"> ). The deepest nested elements with method correspond to real actions. The top elements with method actually are dummy actions that must not be taken into account. Here is my XML sample file: <?xml version="1.0" encoding="UTF-8"?> <main method="modify"> <MACHINE method="modify"> <SOURCE id=

how to get the most deeply nested element nodes using xpath? (implementation with XMLTWIG)

邮差的信 提交于 2019-11-28 01:20:03
问题 I need to extract (XSLT, xpath, xquery... Preferably xpath) the most deeply nested element nodes with method (DEST id="RUSSIA" method="delete"/>) and his direct ancestor (SOURCE id="AFRICA" method="modify">). I don't want to get the top nodes with methods ( main method="modify"> or main method="modify"> ). The deepest nested elements with method correspond to real actions. The top elements with method actually are dummy actions that must not be taken into account. Here is my XML sample file:

What browsers support Xpath 2.0?

巧了我就是萌 提交于 2019-11-27 14:18:31
I have recently been working with XPath and have been searching for information on which browsers support XPath 2.0 without much luck. The best I could find was the query technologies comparison table of various rendering engines. This clearly tells me that Firefox and IE (all versions of both) do not support XPath 2.0, but what about the other rendering engines for Chrome, Safari, etc.? Does anybody have any information on this or know where one can find it? I do not know of any, and the official list of implementations doesn't include one either. An alternative - of course less performant

How do you identify duplicate values in a numerical sequence using XPath 2.0?

我只是一个虾纸丫 提交于 2019-11-27 09:05:00
I have an XPath expression which provides me a sequence of values like the one below: 1 2 2 3 4 5 5 6 7 It is easy to convert this to a set of unique values 1 2 3 4 5 6 7 using distinct-values() . However, what I want to extract is the list of duplicate values = 2 5 . I can't think of an easy way to do this. Can anyone help? Use this simple XPath 2.0 expression : $vSeq[index-of($vSeq,.)[2]] where $vSeq is the sequence of values in which we want to find the duplicates. For explanation of how this "works", see : http://dnovatchev.wordpress.com/2008/11/16/xpath-2-0-gems-find-all-duplicate-values