YPath ain't XPath?
Trans <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <24260819.300.1333034947729.JavaMail.geo-discussion-forums@ynpp8> |
I've been playing around with implementation of a very simplistic YPath lib
for Ruby. It's nothing anyone would consider conforming to a definitive
YPath spec. Rather, it's just so there is at least something that basically
works so I can use it with YES schema project. In other words I am throwing
together a hack as a stand in until a *real* YPath library comes along. --
I so wish there was already a YPath library out there I could use.
In any case, working on this I realize that any YPath spec that's more or
less patterned after XPath (which always seems to be the idea) is going to
have some limitations. An obvious example is a YPath for mapping keys of
some odd type. That makes me suspect of the the whole idea of an XPath-like
YPath. So, what if YPath where just a YAML document with "match slots"?
e.g. given a YAML document
---
a: 1
b: 2
YPath document:
--- !ypath
a: <?>
Then in code something like:
ypath = YPath.new(ypath_document)
ypath.match(yaml_document)
The return value would be a list containing 1 or the YAML node for 1.
Nod sure to search every node though (rather than just root), maybe
something like
--- !ypath-any
a: <?>
Or
--- !ypath
<*>:
a: <?>
Thoughts?
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core