xpath-2.0

Evaluate XPath 2.0 in PHP

☆樱花仙子☆ 提交于 2021-01-28 04:45:59
问题 I am currently working on a project written in PHP and want to evaluate XPath expression on XML files. Since the files are a quite complex, my XPath contains expressions like for...in...return -loops or other features introduced with XPath 2. Unfortunately PHP's DOMXPath class supports only XPath 1.0, and I didn't find any XPath 2.0 evaluator for PHP. Has anybody faced the same problem and found a solution? 回答1: Saxon/C (currently in beta) can be called from PHP. It's open source, covered

Enable XPath2 queries in System.Xml.XPath (XPathException: invalid token)

落花浮王杯 提交于 2021-01-28 03:56:09
问题 Microsofts System.Xml.XPath nuget-package, available for .NET 4.6, claims to support XPath 1.0 and 2.0. De documentation says descibes the namespace: The System.Xml.XPath namespace contains the classes that define a cursor model for navigating and editing XML information items as instances of the XQuery 1.0 and XPath 2.0 Data Model. After upgrading Visual Studio, upgrading and all my projects to framework version 4.6 I still can't get the simplest XPath-2.0 for-expression to work. According

How to check a node contains empty string or space or null in xpath?

烂漫一生 提交于 2021-01-27 06:50:06
问题 I want to check using xpath an node in the xml contains empty string/spaces. What is the xpath expression i need to use? eg: <p:insert_acc_data_file xmlns:p="http://ws.wso2.org/dataservice"> <p:Id>123</p:Id> <p:Name></p:pName> </p:insert_acc_data_file> How to check the Name node is empty or containing space values? 回答1: By checking if a node is empty I guess you mean has no child element (text or node) . Checking if a node contains only space values can be done using normalize-space()

How to check a node contains empty string or space or null in xpath?

冷暖自知 提交于 2021-01-27 06:44:55
问题 I want to check using xpath an node in the xml contains empty string/spaces. What is the xpath expression i need to use? eg: <p:insert_acc_data_file xmlns:p="http://ws.wso2.org/dataservice"> <p:Id>123</p:Id> <p:Name></p:pName> </p:insert_acc_data_file> How to check the Name node is empty or containing space values? 回答1: By checking if a node is empty I guess you mean has no child element (text or node) . Checking if a node contains only space values can be done using normalize-space()

Telegram's instant view API: Element <img> is not supported in <p>

℡╲_俬逩灬. 提交于 2020-05-29 10:14:05
问题 I have problem when trying to create my Telegram's Instant View template, with this error: Element <img> is not supported in <p>: <img src="mysrc" /> So, I decided to replace tag <p> if has <img> tag with <figure> tag @replace_tag(<figure>): $body//p//img But the result is not showing the image. FYI, the <img> doesn't have attributes except src . Sample code: <p><img src="mysrc"/></p> I have no idea, please help me 回答1: The problem with your code is it replaces the <img> . Like what you've

Evaluate Xpath2.0 in python

隐身守侯 提交于 2020-05-29 03:18:06
问题 I have an XPath expression as shown below. if(replace(//p[1]/text(),'H','h') = 'hello') then //p[1]/text() else if(//p[1]/text() = 'world') then //p[2]/text() else 'notFound' I want to display which 'if ' expression worked. e.g //p[1]/text() if first 'if' expression worked. 'If' expression can have nested if, for loops and xpath2.0 functions. I can't find any xpath2.0 library for python. So I tried to convert this Js library to python still I can able to split xpath2.0 expression to lexers

How to use for loop in XSLT and get node values based on the iteration

倖福魔咒の 提交于 2020-02-04 05:57:41
问题 How do we use for loop in XSLT? I have this requirement where I want to convert the below shown xml into a comma separated file. Number of rows in CSV file would be equal to count of COBRA_Records_within_Range nodes for an employee's report entry. All values in 3 rows will be same except the child element values for COBRA_Records_within_Range nodes. I am able to create 3 rows but not able to retrieve the value for child elements of COBRA_Records_within_Range . I want to run the for loop on a

Last day of previous month in XSLT

时光毁灭记忆、已成空白 提交于 2020-01-15 07:35:21
问题 Is it possible to get the last day of the previous month in XSLT? I found this function: http://www.xsltfunctions.com/xsl/functx_last-day-of-month.html but I'm not sure how to use it to get the previous month. 回答1: Use : current-date() - xs:dayTimeDuration(concat('P', day-from-date(current-date()), 'D')) This produces (when evaluated on any day of May 2012): 2012-04-30-07:00 来源: https://stackoverflow.com/questions/10483246/last-day-of-previous-month-in-xslt

How get attribute content by another attribute value with XPath?

倖福魔咒の 提交于 2020-01-07 03:16:58
问题 I have XML like: <?xml version='1.0' encoding='UTF-8'?> <ClinicalDocument xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='urn:hl7-org:v3' xmlns:ext='urn:hl7-RU-EHR:v1' xsi:schemaLocation='urn:hl7-org:v3'> <author> <time value='20160809000000+0300'/> <assignedAuthor> <id root='1.2.643.5.1.13.3.25.1.1.100.1.1.70' extension='1'/> <id root='1.2.643.100.3' extension='03480134121'/> <id nullFlavor='NI'/> </assignedAuthor> </author> </ClinicalDocument> I have to get extension in id with

How to refer to position when using xf:setvalue function with iterate

◇◆丶佛笑我妖孽 提交于 2020-01-06 14:08:14
问题 Considering this code example and this post ... <xf:action> <xf:setvalue iterate="instance('fr-send-submission-params')/@*" ref="." value="event(name(context()))"/> </xf:action> ... How can refer to current iterated position? Like value="position()" Can i use this position as variable to xpath expressions? Like ref="/AnotherElement[position()]" 回答1: The following works: <xf:action iterate="instance('fr-send-submission-params')/@*"> <xf:var name="p" value="position()"/> <xf:setvalue ref="."