473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Technique for creating deep elements?

Using the ms XMLDOM...

What techniques do you guys use to create deep elements in code for
appending to the main document as the user "adds" complex objects.

Currently I keep 3 files to do it like this:

1) The main xml file that the user is editing
2) The xsd file that validates the user-manipulated document
3) A "model" xml file that looks like the user xml file but only
contains empty element nodes or nodes with default values, and only
the bare minimum nodes needed to keep validity to the above xsd.

When the user wants to "add" a complex deep element to the main doc.
I use my model.xml file to instantiate a deep model of the complex
node they are trying to add, then I import that node into the users
document. Now the main doc contains the desired element and all it's
mandatory children.

This coding technique alleviates my code of having to actually know
what the structure is of a complex node and having to do many
appendChild commands to make it manually. IOW I basically just clone
it from the model.xml then the user fills out the values using the
existing web page code.

Are there other techniques for doing deep element creation using the
ms dom? Assuming my document has a known xsd schema, is there a
createDeepElement() or some such method? The ms DOM createElement()
method only generates a simple element, if one wants to free their
executing code from procedurally constructing complex elements, what
other techniques might be available than what I am doing?

Thanks

Mar 6 '07 #1
2 1501
RickH wrote:
Using the ms XMLDOM...
I don't touch the MS code, but if they've properly implemented the DOM
APIs its behavior should be just like every other DOM. See the DOM specs
for information about what methods are available.
createDeepElement() or some such method?
No. DOM Level 3, if supported, does add some schema-directed editing --
but because schemas under-specify the real-world structure of most
documents, attempting to synthesize a tree from a schema has been found
to generally be a losing proposition. Using the schema to guide user
input generally works better, but requires a more sophisticated user
interface.
The ms DOM createElement()
WARNING! OBSOLETE METHOD!! You should *always* be using the
namespace-aware versions these days (createElementNS() and so on).

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 6 '07 #2
On Mar 6, 3:35 pm, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:
RickH wrote:
Using the ms XMLDOM...

I don't touch the MS code, but if they've properly implemented the DOM
APIs its behavior should be just like every other DOM. See the DOM specs
for information about what methods are available.
createDeepElement() or some such method?

No. DOM Level 3, if supported, does add some schema-directed editing --
but because schemas under-specify the real-world structure of most
documents, attempting to synthesize a tree from a schema has been found
to generally be a losing proposition. Using the schema to guide user
input generally works better, but requires a more sophisticated user
interface.
The ms DOM createElement()

WARNING! OBSOLETE METHOD!! You should *always* be using the
namespace-aware versions these days (createElementNS() and so on).

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Thanks,

It sounds like I'm on the right track by keeping a model.xml file
(that references the same xsd) from which to derive instances of my
complex trees and business nodes. The same model.xml is also used to
intialize a new user.xml file from scratch.

I'm trying to avoid creating elements and structure programmatically
(avoiding createElement()), IOW just use the programming to fill in
the data points, with all node insertions being cloned from a valid
empty model. It's also proven to be a handy way of setting default
values for data points that the user might neglect to fill in.

Rick
Mar 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Gunnar G | last post by:
Is there anything like vector in STL, that performes deep copy of the elements it contains? I hope this will appear in future releases of STL :)
4
by: sp | last post by:
Hello everybody, How can I create xsl for the following xml? ******************************************************* <?xml version="1.0"?> <result state="success"> <row> <column...
4
by: fperfect13 | last post by:
Hi, I wanted to perform a deep copy of an array. Searching on google I ran into different opinions : C# Interview Questions (http://blogs.wwwcoder.com/tsvmadhav/archive/2005/04/08/2882.aspx)...
4
by: Dennis | last post by:
I have several Data Structures, say "mystruct" which contain arrays of bytes, other structures, etc. I then dimension a variable (var1) as "mystruct" and set the various elements var1 to data. I...
5
by: BenW | last post by:
Hello, What is the easiest way to make "deep copy" of my Hashtable? How about with other Collection classes in C#, any documents available? I don'r actually understand why Framework's...
38
by: djhulme | last post by:
Hi, I'm using GCC. Please could you tell me, what is the maximum number of array elements that I can create in C, i.e. char* anArray = (char*) calloc( ??MAX?? , sizeof(char) ) ; I've...
18
by: xahlee | last post by:
Last year, i've posted a tutorial and commentary about Python and Perl's sort function. (http://xahlee.org/perl-python/sort_list.html) In that article, i discussed a technique known among...
15
by: Matt Kruse | last post by:
Consider the following two functions: function func1() { var o ; if ( (o=document.forms) && (o=o) && (o=o.elements) && (o=o.sel) && (o=o.options) && (o=o)
6
by: olympus_mons | last post by:
Hi, I generated C# classes from some complex XMLSchemas usind xsd.exe. The result is that I get a class hierarchy that is quite deep (well for me 8 levels are deep). What I'm curiuos about is,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.