[xsd-users] RE: Accessing embedded sub-schemas

Matt Burnham mwburn at mhpcc.hpc.mil
Thu Jun 29 19:01:41 EDT 2006


Boris,

I've made some progress in accessing my embedded sub-schema.

 From my previous email the issue with, "Trying to access a container 
directly won't compile", works if I do this.
    event::detail::type& dtl = obj->detail().get();
        instead of
    event::detail& dtl = obj->detail().get();

When I make this change in the keep-dom approach, I can now create a 
valid DOMElement, and the exception (since the DOMElement created was 
NULL) goes away.  I'm now down to actually "parsing" the embedded schema 
using the following code:
    class embedded edata( ede );
This doesn't work, and the only "Dom" constructor I find for the 
embedded class takes a DOMDocument.  I've gone through the xerces API 
docs and can't find any way to create a DOMDocument from the DOMElement, 
or to simply create a string/stream,etc from the DOMElement).

Also, in the substitution group approach, I can also access the detail 
container directly, but still can't create an xml_schema::type directly 
from it.

Thanks,
Matt

Matt Burnham wrote:
> Hi Boris,
>
> I've been trying to get my embedded sub-schemas to work, both through 
> the "keep-dom" and "substitution group" approach.  I haven't had any 
> luck with either one and have put together 2 different test cases.  In 
> the code I've put comments where I either have compile errors or where 
> an exception gets thrown.  All of this testing was done using version 
> 2.1.1 on Windows XP, and Visual Studio 7.1.  I'd like to get both of 
> these working, then I can use either approach, though I'm leaning 
> towards modifying the schemas and using the substitution groups approach.
>
> Here are the issues that I'm having:
>
> 1 - Trying to acces a container directly won't compile (in both 
> approaches).
>     event::detail::container dtl = obj->detail();   // this compiles
>     event::detail& dtl = obj->detail().get();       // this doesn't
>
> 2 - In the substitution group approach, converting the "content" to an 
> xml_schema::type won't compile (see test_sg.cxx):
>    xml_schema::type& c( dtl.get().content() );    // error: 'content' 
> : is not a member of 'detail'
>
> 3 - Trying to accessing non-embedded data when using keep-dom throws 
> an exception (see test_dom.cxx accessing "stuff"). I'm sure I'm 
> probably doing something wrong here, but can't figure out what.
>    event::stuff::type stuff = obj->stuff();  // throws an exception
>
> 4 - In the keep-dom approach, I cast the contents of the detail 
> container to a DOMElement and create the DOMElement (see 
> test_dom.cxx).   When I then try and acces this DOMElement, it throws 
> an exception.
>    xercesc::DOMElement* de( 
> static_cast<xercesc::DOMElement*>(dtl.get()._node()) );
>    xercesc::DOMNodeList* nl( de->getElementsByTagName(ename) );  // 
> this throws an exception
>
> I'm attaching a zip file containing these 2 test cases, including a 
> solution and project files.  Here is a list of some of the files:
> test_dom\event_dom.xsd - core schema for keep-dom parsing test
> test_dom\embedded_dom.xsd - sub-schema for keep-dom parsing test
> test_dom\test_dom.cxx - driver app for keep-dom parsing test
> test_sg\event_sg.xsd - core schema for substitution group test
> test_sg\ embedded_sg.xsd - sub-schema for substitution group test
> test_sg\ test_sg.cxx - driver app for substitution group test
> test_*\test_event.xml - example input file
>
> I've also, added a comment in the test apps showing how the cxx-tree 
> was created.
>
> Thanks,
> Matt
>




More information about the xsd-users mailing list