Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday February 28, 2008
10:40 AM

Bermuda RelaxNG Generation Started

[ #35787 ]

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
  - href:
      type: anyURI
      method: url
  - revision?:
      if: 'defined $instance->revision'
      type: positiveInteger
  - name:
      type: string
          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="">
  <name some_attr="foo">John Smith</name>

But it also generates RelaxNG which properly validates that XML:

<?xml version="1.0" encoding="UTF-8"?>
<element name="card" xmlns="" datatypeLibrary="
  <attribute name="href">
    <data type="anyURI"/>
    <attribute name="revision">
      <data type="positiveInteger"/>
  <element name="name">
    <attribute name="some_attr">
    <data type="string"/>
    <element name="email">
      <data type="string"/>
    <element name="phone">
      <data type="string"/>
  <element name="active">

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.