Folks,
In the past week or so, I have been soaking up a lot on XML and DOM parsing and 
the like. The problem is a familiar one: Given an XML instance doc, parse it, 
while validating it against a schema, and get the stuff into a C/C++ struct. 
Simple enough? Maybe not quite. Here's what I want to do:

1. Put all the rules in the schema, including type info. I figure, why not use 
the power of tools to validate incoming data. Things like integer ranges, 
string lengths etc.

2. Use the XercesDOMParser to walk thru all nodes, and dump the values into my 
c-struct. I imagine I would define some sort of a handler to the 
XercesDOMParser, which would be called as it traverses nodes, making data and 
other info (type, attrs etc) available to me. Which handler would that be?

3. If the parser is using the schema, how will the handler make the data 
available to me, if it passed validation. For eg. if I have 2 nodes, an 
xs:integer and another one xs:string in the schema, then can I just say 
something like this?

    if ( strcmp(node.getName(), "quantity") == 0) {
      int qty = (int)node.getData() ;
    } else if ( strcmp(node.getName(), "name") == 0) {
      char* name = node.getData() ;
    }

Given the bewildering number of ways you can do this, is this the best 
approach? Let me say it outright. Is there a primer available?

Thanks!
Vijay
      



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to