469,913 Members | 1,947 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

substitution groups problem.

Hi all,
I am new to xml/xsd world. I want to know the differences between complex type and element being abstract and if both can be declared so, in case of substitution goups.Also can xsi:type usuage allowes in instance doucments in case of substitution goups.
I tried using abstarct complex type/element with substitution groups and I attached the code below.

In XX1.xsd which is imported and a reference to complex abstract type is made in YY1.xsd. But the instance document validation of ZZ1.xsd fails when YY1.xsd is imported to ZZ1.xsd and when the complex type is referenced. XMLSpy and Xerces give the same error as follows:This file is not valid. Unexpected element'signatureString' in element author. Expected signatureString,signatureText.

Please let me know what is wrong with the code and any help in this regard at the earliest is highly appeciated.

The code of each xsd file is as follows:
Expand|Select|Wrap|Line Numbers
  1. ********************************************************************
  2. XX1.XSD:
  3. ********************************************************************
  4. <?xml version="1.0" encoding="ISO-8859-1"?>
  5. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:PARTICIPATION="Participation" targetNamespace="Participation">
  6. <!-- ================================================= -->
  7. <!-- Package: Participation -->
  8. <!-- ================================================= -->
  9. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  10. <!-- Class: <<ST>> SignatureString -->
  11. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  12. <xs:element name="signatureString" type="PARTICIPATION:SignatureString" substitutionGroup="PARTICIPATION:signatureText"/>
  13. <xs:complexType name="SignatureString">
  14. <xs:complexContent>
  15. <xs:extension base="PARTICIPATION:SignatureText">
  16. <xs:attribute name="value" type="xs:string" use="required"/>
  17. </xs:extension>
  18. </xs:complexContent>
  19. </xs:complexType>
  20. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  21. <!-- Class: SignatureText -->
  22. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  23. <xs:element name="signatureText" type="PARTICIPATION:SignatureText" abstract="true"/>
  24. <xs:complexType name="SignatureText" abstract="true"/>
  25. </xs:schema>
  26. ***********************************************************************
  27. YY1.xsd:
  28. ***********************************************************************
  29. <?xml version="1.0" encoding="ISO-8859-1"?>
  30. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:CM3202="Common3202" xmlns:PARTICIPATION="Participation" targetNamespace="Common3202">
  31. <xs:import namespace="Participation" schemaLocation="Datatypes3203/RDT/Participation.xsd"/>
  32. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  33. <!-- Class: <<Participation>> PractitionerParticipation -->
  34. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  35. <xs:element name="practitionerParticipation" type="CM3202:PractitionerParticipation" abstract="true"/>
  36. <xs:complexType name="PractitionerParticipation" abstract="true">
  37. <xs:sequence>
  38. <!--xs:element name="signatureText" type="PARTICIPATION:SignatureText" minOccurs="0"/-->
  39. <xs:element ref="PARTICIPATION:signatureText"/>
  40. </xs:sequence>
  41. </xs:complexType>
  42. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  43. <!-- Class: <<Participation>> Author -->
  44. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  45. <xs:element name="author" type="CM3202:Author" substitutionGroup="CM3202:practitionerParticipation"/>
  46. <xs:complexType name="Author">
  47. <xs:complexContent>
  48. <xs:extension base="CM3202:PractitionerParticipation"/>
  49. </xs:complexContent>
  50. </xs:complexType>
  51.  
  52. </xs:schema>
  53. ********************************************************************
  54. ZZ1.xsd
  55. *******************************************************************
  56. <?xml version="1.0" encoding="ISO-8859-1"?>
  57. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:VS3203="VitalSigns3203" xmlns:CM3202="Common3202" targetNamespace="VitalSigns3203">
  58. <xs:import namespace="Common3202" schemaLocation="Common3202.xsd"/>
  59. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  60. <!-- Class: <<Observation>> VitalSignsObservationEvent -->
  61. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  62. <xs:element name="vitalSignsObservationEvent" type="VS3203:VitalSignsObservationEvent"/>
  63. <xs:complexType name="VitalSignsObservationEvent">
  64. <xs:sequence>
  65. <xs:element name="author" type="CM3202:Author" minOccurs="0">
  66. </xs:element>
  67. </xs:sequence>
  68. </xs:complexType>
  69. </xs:schema>
  70.  
Nov 12 '05 #1
1 2204
Hi all,

More info. regarding this problem: The error occurs when each xsd has a different namespace and thus has problem with imports.
It works fine when all the xsds are in the same namespace and when include statement is used.
But I want to avoid name collisions by using different namespaces.
Thus any input in this regard is highly appreciated.

Thanks in advance.
Nov 17 '05 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Paddy | last post: by
2 posts views Thread by John Carron | last post: by
reply views Thread by John Carron | last post: by
1 post views Thread by KERLOG | last post: by
14 posts views Thread by Malcolm | last post: by
4 posts views Thread by Don | last post: by
18 posts views Thread by james | last post: by
7 posts views Thread by MtiPaulo | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.