Add the PureXML.XPointer namespace resolving the shorthand bare-name form (id), the element() scheme (child-element positions from an id or the document root), and the xpointer() scheme (a full XPath expression). Scheme parts chain with the XPointer fallback rule: the first non-empty selection wins. element() data is translated to the equivalent XPath and evaluated by PureXML.XPath, so no separate evaluator is needed. Closes #46 Closes #47 Closes #23
17 lines
520 B
Swift
17 lines
520 B
Swift
public extension PureXML.XPointer {
|
|
/// An error parsing an XPointer.
|
|
enum XPointerError: Swift.Error, Equatable, Sendable, CustomStringConvertible {
|
|
case empty
|
|
case malformed
|
|
case unknownScheme(String)
|
|
|
|
public var description: String {
|
|
switch self {
|
|
case .empty: "the XPointer is empty"
|
|
case .malformed: "the XPointer is malformed"
|
|
case let .unknownScheme(name): "unknown XPointer scheme '\(name)'"
|
|
}
|
|
}
|
|
}
|
|
}
|