Seth Ladd wrote:
<snip/>
> 
> All excellent points.  Maybe what we're trying to do is have a very
> light-weight "mini" DOM.  I do see ECS moving towards that direction.  I
> think the best part about ECS is its very small footprint.  We could learn
> from the W3C's DOM and take what we like.  I would like the ability to
> move up and down the ECS tree, but w/ semantics more like the DOM, but
> without some of the lame DOM methods and the size of DOM.
> 
> Does that make sense? :)

Ahh, I see... I am building my (current) implementation more for pure
output.  For example, I might have:
<code>
  public String createXML() {
    // Create an XML Document, Version 1.0, that is standalone
    XMLDocument screen = new XMLDocument(1.0, true);
    screen.addStylesheet("xsl/sheet.xsl");
    screen.addDTD("page", "dtd/sheet.dtd");
    screen.addToProlog(new PI().setTarget("cocoon-process")
                               .addInstruction("type", "xslt"));

    XML root = new XML("page");
    root.addElement(doSomeContent());
    root.addElement(doMoreContent());

    screen.addElement(root);

    return screen.toString();
  }

  private XML doSomeContent() {
    XML content = new XML("userInfo");
    content.addElement(new XML("usename", "bmclaugh"))
           .addElement(new XML("firstName", "Brett"))
           .addElement(new XML("lastName", "McLaughlin"));
    return content;
  }

  private doMoreContent() {
    XML content = new XML("applicationInfo");
    content.addElement(new XML("name", "ECS Test"))
           .addElement(new XML("purpose", "Test ECS Distribution"));
    return content;
  }
</code>

This would result in:
<code>
<?xml version="1.0" standalone="yes"?>
<?xsl-stylesheet href="xsl/sheet.xsl" type="text/xsl"?>
<!DOCTYPE page SYSTEM "dtd/sheet.dtd">
<page>
  <userInfo>
    <username>bmclaugh</username>
    <firstName>Brett</firstName>
    <lastName>McLaughlin</lastName>
  </userInfo>
  <applicationInfo>
    <name>ECS Test</name>
    <purpose>Test ECS Distribution</purpose>
  </applicationInfo>
</page>
</code>

That isn't possible now, because there is no concept of a document
object that contains more than one "root" element, which is essentially
what an XML document is when viewed by ECS.  The XMLDocument object has
to keep track of all the elements in the prolog, plus the root element
(which contains everything else).

What I don't want to do or believe is right is to try to write a
lightweight DOM - that is not what ECS is for.  I also don't think you
should be doing XML manipulation using ECS.  You don't do HTML parsing
with ECS, it's the same thing.  ECS is for construction of content in an
easy manner.  I think that trying to add in any notion of a tree is
tying ECS to DOM, which is not the purpose of ECS, plus a mistake.  An
XML document is _not_ a tree, until it is parsed and converted to a DOM
nodeset, result tree fragment, et. al.  To treat it as one is a mistake,
IMHO.

I just want a way to create XML presentation, nothing more.  In my case,
it will be fed through a producer into the Cocoon engine, but it could
be fed to XP, XSLP, whatever... Make sense?

XML _handling_ is a different project space than ECS.  Then you would
either use DOM or SAX (or JAXP ;-) )

-Brett


--
------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to