Uni Era's profileThe Unified EraBlogLists Tools Help

Blog


    Metadata for DB

    <ebook product="Apache Derby" driver="Apache Derby Network Client JDBC Driver"
        ver="10.3.1.1 - (554502)" url="jdbc:derby://localhost:1527/db/eBook">
      <customer schema="ADMIN" name="CUSTOMER" type="TABLE">
        <id unique="1" def="0" name="ID" empty="0" type="integer" size="10"/>
        <name unique="0" def="0" name="NAME" empty="0" type="varchar" size="50"/>
        <address unique="0" def="0" name="ADDRESS" empty="0" type="varchar" size="30"/>
        <phone unique="0" def="0" name="PHONE" empty="1" type="varchar" size="20"/>
        <sex unique="0" def="0" name="SEX" empty="0" type="varchar" size="8"/>
      </customer>
      <greetings schema="ADMIN" name="GREETINGS" type="TABLE">
        <i unique="0" def="1" name="I" empty="0" type="integer" size="10"/>
        <ch unique="0" def="0" name="CH" empty="1" type="char" size="50"/>
      </greetings>
      <item schema="ADMIN" name="ITEM" type="TABLE">
        <id unique="1" def="0" name="ID" empty="0" type="integer" size="10"/>
        <name unique="0" def="0" name="NAME" empty="0" type="varchar" size="50"/>
        <author unique="0" def="0" name="AUTHOR" empty="0" type="varchar" size="30"/>
        <isbn unique="0" def="0" name="ISBN" empty="1" type="varchar" size="20"/>
        <price unique="0" def="0" name="PRICE" empty="0" type="double" size="52"/>
      </item>
      <ccc schema="APP" name="CCC" type="TABLE">
        <id unique="1" def="0" name="ID" empty="0" type="integer" size="10"/>
        <name unique="0" def="0" name="NAME" empty="0" type="varchar" size="50"/>
        <address unique="0" def="0" name="ADDRESS" empty="0" type="varchar" size="30"/>
        <phone unique="0" def="0" name="PHONE" empty="1" type="varchar" size="20"/>
        <sex unique="0" def="0" name="SEX" empty="0" type="varchar" size="8"/>
      </ccc>
      <v0001 schema="ADMIN" name="V0001" type="VIEW">
        <id unique="0" def="0" name="ID" empty="0" type="integer" size="10"/>
        <name unique="0" def="0" name="NAME" empty="0" type="varchar" size="50"/>
        <author unique="0" def="0" name="AUTHOR" empty="0" type="varchar" size="30"/>
        <isbn unique="0" def="0" name="ISBN" empty="1" type="varchar" size="20"/>
        <price unique="0" def="0" name="PRICE" empty="0" type="double" size="52"/>
      </v0001>
    </ebook>


    Now imaging...
    -----------------------------------------------------
    ebook.admin:item.[id == 101].name = 'JSDB Cooking Book';

    or

    jBooks = ebook.v0001.[name like 'J%'];
    print(jBooks);




    DOM Impl Removed

    The dom-impl for e4x is erased from ecmax, because:

    1, stax-impl has better speed than dom-impl.
    2, the dom-impl needs dom level 3, which depends on Java 5.

    So ecmax has 2 kinds of e4x impl: one is stax, the other is xbean.

    That is enough!

    Binary early access for ecmax

    An early binary package of ecmax is released now. Only the change summary feature is not finished yet.

    The file list:
    • ecmax_1.6a.chm: the API document.
    • rhinox_1.6a.jar: full binary package.
    • rhinox_1.6a_dom_jdk5.jar: special binary package only with DOM-based e4x impl (JVM 5.0 needed for running).
    • rhinox_1.6a_stax.jar: special binary package only with StAX-based e4x impl.
    • rhinox_1.6a_stax_jdk6.jar: special binary package only with StAX-based e4x impl (JVM 5.0 needed for running).
    • rhinox_1.6a_xbean.jar: special binary package only with xbean-based e4x impl.

    Features from Mozilla Rhino
    • 'like' expr support.
    • BigDecimal instead of double.
    • Defered xml and joint xml.
    • xml + number expr is redefined.
    • xml.idx_from_1 expr for xml.
    • xml.ns:name expr for xml.
    • *change summary for xml.
    • Some bug fixes.

    Note: ecmax™ means the extensions for ECMA-262 and ECMA-357.


    Rhino E4X Impl in StAX way

    As a byproduct of xobj, A new E4X impl has been finished here based on StAX API (implemented by JDK 6 or BEA's open source impl).

    The source code is released now, contains the StAX impl code (from codehaus) already.

    To build a full release package, please get the source code of Mozilla Rhino 1.6_5, and replace the org.mozilla.javascript.xmlimpl package with this impl.

    ------------
    This zip was updated at 2007-5-13 for some bug fixes.

    About ecmax.xobj

    A sub project, 'xobj', as part of project ecmax, is in development right now. Its goal is to implement a simple set of XmlCursor api like Apache XmlBeans.

    The ecmax.xobj project is based on the Streaming API for Xml(StAX) and its open source RI from BEA.


    Switching to DOM from xmlBeans

    ecmax's e4x impl is replaced with a dom-based impl delivered by David Caldwell. Now, the speed is at least 50% faster than before, the size of release package is smaller than half of the old one which contains even a simplified xmlBeans impl.

    Change log of ecmax:
    -----------------------------------------------
     1, 'like' expr.
     2, big decimal instead of double.
     3, defered xml and joint xml
     4, xml + number redefined.
     5, xml.idx_from_1 expr for xml.
     6, xml.ns:name expr for xml.
    -7, change summary for xml.

    New Changes

    The pervious proposal of ecmax.change was disposed, and the idea about sequence change(whole updated once its length changed) is also removed.

    To prepare to suggest the new proposal, one new promotion for e4x has been done in ecmax to support elements-accessing via 'xml.index_form_1' style.

    It's remarkable that the 'a.1' expression in ecmax is not equal to the same expression but the 'a[1]' expression in xpath or sdo.

    It's notable also that the new promotion has no side-effect upon
    the specifications about DecimalLiteral at chapter 7.8.3 of ecma-262.

    Finally, for example:

    x = <a><aa>bbb</aa></a>;

    print(x.1.toXMLString());  // x.1 is equivalent to x[0]
    print(x[0].toXMLString());
    print(1.+.2);              // equivalent to 1.0+0.2

    ------------------------------------------------------------------
    System.out - <a>
      <aa>bbb</aa>
    </a>
    System.out - <a>
      <aa>bbb</aa>
    </a>
    System.out - 1.2

    Sophisticated Change Tracing

    x = <a id="1" value="a" lock='true'>
      text in a.
      <b id='b1' value='b'>text in b</b>
      string in a.
      <c id='b1'>text in c</c>
    </a>;
    x = new SDO(x);

    x.@id = 2;
    delete x.@value;
    x.@name='A';
    x.b.* = 'new text in b.';
    x.b.c.@a = 'ca';             // cause element <c> created.
    x.b.@name='b';
    x.b.@id='b2';
    x.*[3] = 'new string in a.'; // cause length of x.* changed.
    x.*[3] = <bd>aaaa</bd>;
    x.*[3] = '<dd>
    eeeeeeee</dd>';
    //delete x.*[3];

    print(x);

    ------------------------------------------------------------------

    logUpdate(N'.@id', 2, L'1') called.
    logDelete(N'.@value', L'a') called.
    logCreate(N'.@name', 'A') called.
    logUpdate(N'.b.*', 'new text in b.', L'text in b') called.
    logCreate(N'.b.c', L'') called.
    logCreate(N'.b.c.@a', 'ca') called.
    logCreate(N'.b.@name', 'b') called.
    logUpdate(N'.b.@id', 'b2', L'b1') called.
    logUpdate(N'.*', L{3}, L{4}) called.
    logCreate(N'.*.3', X'aaaa') called.
    logUpdate(N'.*.3', '<dd>eeeeeeee</dd>', X'aaaa') called.

    System.out - <a id="2" lock="true" name="A">
      text in a.
      <b id="b2" value="b" name="b">
        new text in b.
        <c a="ca"/>
      </b>
      string in a.new string in a.
      <dd>eeeeeeee</dd>
    </a>


    Note: in ecmax.sdo, if a sequence's length has been changed by some operation(but not append() operation, updated at 2007-4-16), it must be marked whole updated, instead of marking the changed element(s) within this sequence.

    Differences between .[] and .()


    Q: A new filter operator .[] has been introduced into E4X in ecmax to coexist with the old filter .(), but what's the difference between them?

    A: Generally in the two aspects:

    1, when applied to common xml object, .[] behaves as the same as .(), and the extended syntax in .[] does no effect.

    2, when applied to deferred xml object, .[] returns the same deferred xml object with internal changes, but .() may return a newer xml object or changes it 'instant' from defered.


    Redefine operation of '+'

    The ECMA-262 Spec has said at section 8.2.6.2, when method [[DefaultValue]] of Object called with no typeHint, it should behave as if the hint were Number.

    But ECMA-357 changed the rule upon XML object at section 9.1.1.5 to do always as String.

    Then,
    according to defination upon the operator '+' at the section 11.4.1 of ECMA-357(essentially, there is almost no defference between it and the section 11.6.1 of ECMA-262), there is a fact as following:

    a = <price>8.1</price>;
    print(a * 5); // -> this got 40.5
    print(a + 1); // -> we got not 9.1 but 8.11


    Yes, that's sure! The operator '+' doesn't consist with the operator '*' and any other arithmetical operators('/', '-', '%'). I think that maybe a little mistake.

    So ecmax has redefined the '+' operation for XMLs: if one operand is XML and another operand is Number, and also if the XML object can be converted as Number(but not NaN), then addition operation upon the two Number is applied; otherwise, it behaves as ECMA-357.

    (proposal) ecmax: ChangeSummary and its XML Format

    1, New type: SDO extends XML

        x = <a id='1' val='a'/>;
        s = new SDO(x);
        y = s.copy(); // get a xml copy for current value.
        print(y.toXMLString()); // -> "
    <a id='1' val='a'/>"

    2, SDO objects consist of context sections and change summary
    section

        2.1 Each modifying operation on SDO object is always recorded into its changeSummary section
        2.2 The changeSummary section is read-only and can't be
    directly modified.
        2.3 Initially, the changeSummary section is empty for SDO object
        2.4 SDO object has a 'restore()' method to undo all modifications and empty the
    changeSummary section

    3, SDO object internally uses an XMLList to represent both the xml content and its change summary.

        3.1 SDO object's toXMLString() method shows the content of the internal XMLList
        3.2 the changeSummary with a
    namespace 'ecmax.sdo' is the last section of the internal XMLList.
        3.3 SDO.length() = its XMLList.length() - 1
        3.4 By declaring xmlns:x='ecmax.sdo', the following attributes in changeSummary section have given meaning:
           x:r='ref' -> reference to retrieve current value in content sections
           x:c
    ='list' -> space-separated list of references, each refers to created element in content sections
           x:d
    ='list' -> space-separated list of references, each refers to deleted element's copy in summary section
           x:u
    ='list' -> space-separated list of references, each refers to updated element's copy in summary section
           <x:text/> -> special element to refer to and/or backup unstructured text

    ------------------------------------------------------------------------

    For example:

    x = <a id="1" value="a" lock='true'>
      text in a
      <b id='b1'>text in b</b>
      string in a
      <c:d xmlns:c='foo/core' width='100' height='200'>draw oval here</c:d>
    </a>;
    x = new SDO(x);

    x.@id = 2;
    delete x.@value;
    x.@name='A';
    x.b.* = 'new text in b';
    x.b.@name='b';
    x.b.@id='b2';
    x.*[2] = 'new string in a';
    x.*[3].@width = 200;

    print(x.copy());
    print(x.toXMLString());

    ------------------------------------------------------------------------
    System.out - <a id="2" lock="true" name="A">
      text in a
      <b id='b2' name='b'>new text in b</b>
      new string in a

      <c:d xmlns:c='foo/core' width='200' height='200'>draw oval here</c:d>

    </a>
    System.out - <a id="2" lock="true" name="A">
      text in a
      <b id='b2' name='b'>new text in b</b>
      new string in a

      <c:d xmlns:c='foo/core' width='200' height='200'>draw oval here</c:d>

    </a>

    <x:changeSummary xmlns:x="ecmax.sdo" x:u='*[0]'>
      <a x:r="*[0]" x:c="@name" x:u="@id *[1] *[2] *[3]" x:d="@value" id="1" value="a">
        <x:text x:r='*[0].*[0]'/>
       
    <b x:r='*[0].*[1]' x:u='@id *' x:c='@name' id='b1'>text in b</b>
        <x:text x:r='*[0].*[2]'>string in a</x:text>
        <c:d x:r="*[0].*[3]" x:u="@width" xmlns:c='foo/core' width='100' />

      </a>
    </x:changeSummary>

    Newly added syntax in ecmax

    joinExpr::=
        expr [left | right | full] join expr
    filterExpr::=
        expr.[itemExpr Op itemExpr];

        expr.[(string|{expr}) [,(string|{expr})] ];

    itemExpr ::=
        [(left | right).][@][ns::]name|number|string|null|true|false|{expr}
    Op::=
        != | == | > | < | >= | <= | like

    --------------------------------------
    Note:
    1, If either operand is not an xml object in a joinExpr, then TypeError is thrown.
    2, If expr is a deferred xml object in a filterExpr, then the filter() method of this expr will be evaluated to decide whether should enter into the dot-query loop.

    Goals of ECMAX - 2


    • Cartesian product
    1. new operator: [left|right|full] join

        a = <a id='1' name='a'>
            <foo>text in a</foo>
        </a>;

        b = <>
            <b id='1' name='b'>
                <bar>text in b1</bar>
            </b>
            <b id='2' name='a'>
                <bar>text in b2</bar>
            </b>
        </>;
        c = a left join b;

    2. new filter: .[] vs. .()

        c.[left.@id == right.@id].(@id != null);
        print(c);


    Output:
        System.out - <ab id="1" name="b">
            <foo>text in a</foo>
            <bar>text in b1</bar>
        </ab>

    ---------------------------
    Updated at 2007-3-13

    Goals of ECMAX - 1

    • like - new operator
    var a = '000001';
    var b = '%1';
    var c = 1871;

    then:

    a like b -> true
    c like b -> true


    • using BigDecimal in Floating-Point Arithmetic
    e.g.

    5.2/0.0000065 -> 800000 (not 800000.0000000001 when using double)




    About ECMAX

    A new sub-project, ecmax, is started based on Mozilla Rhino 1.6R5 to achieve goals:

    • 2 for ECMA-262
    1, add new operator: like
    2, BigDecimal instead of double in Floating-Point Arithmetic

    • 2 for ECMA-357
    1, add new expression for xml objects: Cartesian product
    2, add Change Summay for xml objects.