yeison / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

anchor and alias in different files #117

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

this is more a question than an issue. Pardon me if it makes some noise on the 
list. I'm wondering if it's possible with snakeyaml to make an anchor and an 
alias refering to it from another document. According to the specs, I guess 
it's not feasible.
Something like: 
person: &jsmith
  name : smith
  firstname : john

---
who: 
  person: *jsmith
Ideally anchor and alias would be in distinct files.

Is this valid and could be used with snakeyaml?
Thanks in advance,
Best regards, 
jg

Original issue reported on code.google.com by jgrand...@gmail.com on 23 May 2011 at 8:40

GoogleCodeExporter commented 9 years ago
1) Any deviation from the specification is considered as a bug. Your proposal 
violates the spec far too much to be implemented as the part of the core logic. 
For instance, the aliases would appear in a YAML document without any anchors.

2) you do not need to use anchor and aliases to achieve the result. Try your 
own tags:

person: !my-anchor:jsmith
  name : smith
  firstname : john
---
who: 
  person: !my-alias jsmith

In the first document the anchor is a part of the tag. In the second document 
the person is a just a scalar. The tag and the value of the scalar provide 
enough information to create the proper object.
This is just a proposal. Your solution does not have to be the same.

3) The proposal from p.2 can be included to SnakeYAML as an extension which is 
explicitly enabled when a Yaml instance is created. Then it can be distributed 
as part of the core package. Feel free to implement it and we can discuss how 
to include it into the package.

Original comment by py4fun@gmail.com on 23 May 2011 at 10:29

GoogleCodeExporter commented 9 years ago
Since there is no progress (the reporter does not contribute anything) the 
issue will be closed.

Original comment by py4fun@gmail.com on 16 Jul 2011 at 9:13