Re: Extract schema from YAML

Gabriel de Perthuis <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
* Gabriel de Perthuis:
> I'd like to build some kind of schema describing the structure of big
> YAML documents. For example, from the invoice example [1]:
> [snip]
> 
> Can someone show me how to do that?
> Alternatively, I can do that with XML; so if there is no other way, I'll
> try to convert into XML and use the « xmlstarlet elements » command.

I've figured out how to convert into XML, with the help of the
yaml<=>XML post (and various perl tutorials :P ).

In file yaml2xml.pl:
  #!/usr/bin/perl

  use strict;
  use warnings;

  use YAML;
  use XML::Simple;
  use IO::All;

  io('-') < (XML::Simple::XMLout(YAML::Load(io('-')->all)));

So to get a schema, I run:

< doc/data.yml ./yaml2xml.pl > xml
< xml xmlstarlet elements -a | sort -u

-- 
Gabriel de Perthuis


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.