[xsd-users] Re: Accessing embedded sub-schemas
Boris Kolpackov
boris at codesynthesis.com
Fri Jun 30 09:50:32 EDT 2006
Hi Matt,
Matt Burnham <mwburn at mhpcc.hpc.mil> writes:
> 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();
Right, that should work.
> 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).
Try compiling your tmp_embedded.xsd with the --morph-anonymous and
--root-element-none options. This will result in only embedded_data
class being generated. Then you can use:
embedded_data edata (ede, 0, 0);
> 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.
If 'detail' has the following definition
<xs:element name="content" type="xs:anyType"/>
<xs:complexType name="detail_type">
<xs:sequence>
<xs:element ref="content" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="detail" type="detail_type"/>
then you can write something like this:
detail& d = ...
for (detail_type::content::iterator i (d.content ().begin ());
i != d.content ().end ();
++i)
{
xml_schema::type& c = *i;
if (embedded_data* ed = dynamic_cast<embedded_data*> (&c))
{
// Got embedded_data
}
}
BTW, I downloaded the CoT schemas and now I can see where this design
is coming from.
hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060630/68aa9dbf/attachment.pgp
More information about the xsd-users
mailing list