最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

xproc - How can I store xpath value in a variable? - Stack Overflow

programmeradmin3浏览0评论

With XProc I try to get value returned by a XPath on a loaded document and store it in a variable to apply next.

input.xml

<root>
 <element id="test"/>
</root>

test.xpl

<p:load name="load-source-document" href="input.xml"/>
<p:variable select="/root/element/@id"/>

I tried this with Calabash but I get following error:

Cannot invoke "String.startsWith(String)" because "lexicalQName" is null

With XProc I try to get value returned by a XPath on a loaded document and store it in a variable to apply next.

input.xml

<root>
 <element id="test"/>
</root>

test.xpl

<p:load name="load-source-document" href="input.xml"/>
<p:variable select="/root/element/@id"/>

I tried this with Calabash but I get following error:

Cannot invoke "String.startsWith(String)" because "lexicalQName" is null

Share Improve this question edited Nov 18, 2024 at 22:00 isherwood 61.2k16 gold badges122 silver badges170 bronze badges asked Nov 18, 2024 at 21:59 NicolasNicolas 12 bronze badges 1
  • Please don't tag your title question. See How to Ask. – isherwood Commented Nov 18, 2024 at 22:01
Add a comment  | 

1 Answer 1

Reset to default 0

Yes, it is possible to store the xpath value into the variable. Try updating your code to:

test.xpl

<p:declare-step xmlns:p="http://www.w3./ns/xproc">
  <p:variable name="id-value" select="doc('input.xml')/root/element/@id"/>
  <p:log message="Value is: {$id-value}"/>
</p:declare-step>

Getting the ID value can store into the variable like so.

发布评论

评论列表(0)

  1. 暂无评论