Loose and strict XPath variables/namespaces
還沒有人認領這個 Issue。
評估
研究方向
從 REXML 的 XPath 入口開始,追蹤 namespace 和變數繫結的處理方式。將所要求的 symbol 鍵和 namespace 值行為與 Nokogiri 範例及 XPath 1.0 規範進行比較。決定未定義的變數是在參照時評估期間檢查,還是在評估之前檢查,然後以測試涵蓋所選擇的行為。
由索引模型根據 Issue 內容生成。
描述
Loose keys
XPath namespaces and variables doesn't accept symbol keys. It'll be convenient if symbol keys are accepted.
Nokogiri accepts both string and symbol keys.
namespaces = { ns: 'url' }
variables = { id: 'a' }
xml = '<foo xmlns="url"><bar id="a"/></foo>'
Nokogiri::XML.parse(xml).xpath('//ns:bar[@id=$id]', namespaces, variables)
Strict value check
XPath variables have value validation. Namespaces can also have validation
Nokogiri::XML.parse('<a/>').xpath('//a', { ns: 42 }) #=> TypeError
Strict variable existence check
There's two options
- Reference time check
- Pros: easy to implement
- Cons: error is document dependent
- Pre-check all variables in xpath
- Pros: can detect variable name typo easily
- discussed in https://github.com/ruby/rexml/pull/342#discussion_r3586024018
Nokogiri(libxml2) implements reference time check.
Nokogiri::XML.parse('<b/>').xpath('//a[@id=$foo]', nil, {fooo: '1'}) # => []
Nokogiri::XML.parse('<a/>').xpath('//a[@id=$foo]', nil, {fooo: '1'}) # => ERROR: Undefined variable
XPath 1.0 spec:
A VariableReference evaluates to the value to which the variable name is bound in the set of variable bindings in the context. It is an error if the variable name is not bound to any value in the set of variable bindings in the expression context.
I'm not sure whether it should be an error in evaluation context (reference-time) or in pre-check phase.
In XPath 2.0, it's explicitly defined to be a static-error, so XPath 1.0 spec might be ambiguous.
- 主要語言
- Ruby
- 星號
- 181
- 分支
- 105
- 平均合併
- 11 小時 3 分鐘
- 30 天內合併 PR
- 1
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ruby/rexml 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 55/100
-
XPath underscored function name is wrongly accepted可能已有人在做 @sjh9714 於 48 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
-
難度 3/5 1-2 天 新手友好度 55/100
-
難度 4/5 3-5 天 新手友好度 48/100
-
RELAX NG Validator fails to handle XML documents with XML declaration可能已有人在做 @Shaisolaris 於 5 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 70/100
WikiEducationFoundation/WikiEduDashboard#7157 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
aws/homebrew-aws#68 ·
-
難度 2/5 1-3 小時 新手友好度 66/100
-
data entry
難度 2/5 1-3 小時 新手友好度 76/100
riscv/riscv-unified-db#2746 ·
維護者通常 1 天內回覆