[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Compositional Documents

  • From: Derek Denny-Brown <derekdb@m...>
  • To: 'Chris Berry' <CBerry@w...>, "'xml-dev@i...'" <xml-dev@i...>
  • Date: Tue, 2 Feb 1999 14:28:23 -0800

appendchild ixmldomdocument
The problem with the code below is that the first:
   doc.appendChild( docFrag );
moves the contents of docFrag into doc.  It does not copy/clone or otherwise
duplicate, but rather removes the contents of the document fragment, and
appends them to the list of children of doc.  Before executing that line,
the following would be a true assertion:
    docFrag.getChildNodes().getLength() == 1
after executing that line the following is true
    docFrag.getChildNodes().getLength() == 0

Thus executing the following tidbit after the above
doc.appendChild(docFrag), is an obfuscated no-op.
   doc2.appendChild( docFrag );

-derek

-----Original Message-----
From: Chris Berry [mailto:CBerry@w...]
Sent: Tuesday, February 02, 1999 10:11 AM
To: 'xml-dev@i...'
Subject: Compositional Documents


Greetings,
Sorry for the wasted bandwidth, but I posted this last night (without 
a Subject) and did not receive any response.  I'm hoping this time 
around I might be luckier...

I am a relative newbie to XML, so please bear w/ me if this is a poor
question...

It looks like everything in the DOM must be dealt w/ in the context of a
particular document. It seems you cannot drop one Document into another, or
even one DocumentFragment into another Document context. I have tried to do
the following... (using Microsoft's implementation of the DOM) 

   IXMLDOMDocument doc = (IXMLDOMDocument) new DOMDocument();
   IDOMDocumentFragment docFrag = doc.createDocumentFragment();

   IDOMElement userElem = doc.createElement("USER");
   userElem.setAttribute("TIMESTAMP", new Variant("123456") );

   docFrag.appendChild( userElem );

   doc.appendChild( docFrag );
   System.out.println( doc.getXml() );   // >>>> Yields the correct results
               
   IXMLDOMDocument doc2 = (IXMLDOMDocument) new DOMDocument();
   doc2.appendChild( docFrag );
   System.out.println( doc2.getXml() );  // >>>> Yields an empty string

It seems like this should work to me. Shouldn't we be able to cut and paste
between documents?? Or more important, shouldn't we be able to build up
documents compositionally?? I.e. compose Address 1 and Address 2 as
DocumentFragments (or as their own Documents -- with their own DTDs) 
and then drop these into, say, User (providing that the User DTD agrees).

I must be missing something here.
Thanks in advance,
Cheers,
-- Chris

Chris Berry            cberry@w...          512-231-1341
works.com     6850 Austin Center Blvd.      Austin, TX 78731


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following
message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.