[xsd-users] RE: Serialisation issue.

Moss, David R (SELEX Comms) (UK Christchurch) david.r.moss at selex-comm.com
Wed Jan 3 11:22:14 EST 2007


Boris,

Comments below.

Cheers
Dave.

Dave Moss
SELEX Communications
Grange Road
Christchurch 
Dorset  BH23 4JE
United Kingdom
Tel: + 44 (0) 1202 404841
Email: david.r.moss at selex-comm.com

> I tend to think it is a general XML Schema design flaw (or limitation)
> rather than a bug in Xerces-C++. The idea is that you need to always
> specify a complete, top-level schema file for a namespace in import
> declarations and schemaLocation attributes. In your case that would
> mean to import test-users.xsd instead of test-user-config.xsd in
> derived-user-config.xsd. There are also a couple of alternative
> solutions:
> 
> 1. Use different namespaces for test-users.xsd and
test-user-config.xsd.
> 
> 2. Instead of specifying schemas in instance documents, you can
>    programmatically load them into Xerces-C++ grammar cache. This way
>    you can make sure that you load schemas in the proper order (i.e.,
>    first test-users.xsd, then derived-user-config.xsd). For more
>    information on how to do this see the following resources:
> 
>    http://www-128.ibm.com/developerworks/webservices/library/x-
> xsdxerc.html
>    http://wiki.codesynthesis.com/Tree/FAQ
> 

[Moss, David R] 

Right. Importing test-users.xsd instead does the job nicely. 

> 
> Since XML Schema identity constraints are based on XPath and XPath
> operates
> in terms of elements and attributes (instead of types), identity
> constraints
> do not work very well with substitution groups where you change
element
> names (they work ok with xsi:type, since the element name stays the
same).
> 
[Moss, David R] 

I thought I'd try again the xsi:type method (see attached files,
ignoring the commented-out bits from the substitution approach), but I'm
getting 'error, unknown element Age' messages when loading the xml
file.... I'm probably suffering from first-day-back stupidity!


> The only way to make it work with substitution groups is to list all
> possible substitutions in the selector:
> 
> xpath="b:TestUserConfig|DerivedUserConfig"
> 
> (Note, you need to use xpath="b:TestUserConfig" since TestUserConfig
is a
> qualified element.)
> 
> This is not very flexible since you have to hard-code all possible
> substitutions. I think the best solution in this case is to scrap XML
> Schema identity constraints altogether and implement the check in the
> code:
> 

[Moss, David R] 

I think I might end up doing this even if the xsi:type approach works as
it's more user-friendly - clients don't have to add
xsi:type="DerivedUserConfig_t" statements to each record in the
database!

Happy New Year :)
 

> hth,
> -boris


********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: derived-user-config.xsd
Type: application/octet-stream
Size: 742 bytes
Desc: derived-user-config.xsd
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070103/52138b22/derived-user-config.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-user-config.xsd
Type: application/octet-stream
Size: 600 bytes
Desc: test-user-config.xsd
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070103/52138b22/test-user-config.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-users.xsd
Type: application/octet-stream
Size: 890 bytes
Desc: test-users.xsd
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070103/52138b22/test-users.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-users.xml
Type: text/xml
Size: 745 bytes
Desc: test-users.xml
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070103/52138b22/test-users.bin


More information about the xsd-users mailing list