Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
After Aristotle explained to me that there's no reasonable way I can auto-generate JSON and YAML from the same Bermuda island file which defines the XML output format, I've decided to stop work on that for a while. Instead, I'm focusing my energy on the XML work. Today I've normalized the attribute and element island syntax. They're the same, except that the only quantifier allowed on an attribute is '?' (optional). Then I turned to RelaxNG generation.
This island:
---
package: My::Card
island: card
name: card
attributes:
- href:
type: anyURI
method: url
- revision?:
if: 'defined $instance->revision'
type: positiveInteger
elements:
- name:
type: string
attributes:
some_attr:
method: dummy_attribute
- email*:
type: string
- phone+:
method: phone_numbers
type: string
- active:
data: yes
Allows you to automatically generate this xml from an object:
<?xml version="1.0" encoding="utf-8"?>
<card revision="3" href="http://www.example.com/">
<name some_attr="foo">John Smith</name>
<email>js@example.com</email>
<email>js2@example.com</email>
<phone>111</phone>
<phone>222</phone>
<active>yes</active>
</card>
But it also generates RelaxNG which properly validates that XML:
<?xml version="1.0" encoding="UTF-8"?>
<element name="card" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-da
<attribute name="href">
<data type="anyURI"/>
</attribute>
<optional>
<attribute name="revision">
<data type="positiveInteger"/>
</attribute>
</optional>
<element name="name">
<attribute name="some_attr">
<text/>
</attribute>
<data type="string"/>
</element>
<zeroOrMore>
<element name="email">
<data type="string"/>
</element>
</zeroOrMore>
<oneOrMore>
<element name="phone">
<data type="string"/>
</element>
</oneOrMore>
<element name="active">
<value>yes</value>
</element>
</element>
Yeah, I have a lot more work to do (like switching to full grammars), but this is coming along nicely.
Currently we default to UTF8, but that's easy to change. Also, I don't yet have "includes" to reference another island. That might take some major reworking of the XML to get that right, but I want to refactor a lot more of what I'm doing in order to make this workable.
Bermuda RelaxNG Generation Started 0 Comments More | Login | Reply /