You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by bu...@apache.org on 2001/07/16 21:06:30 UTC
[Bug 2643] New: - derivation by extension of complex types does not permit addition of ONLY element content
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2643
*** shadow/2643 Mon Jul 16 12:06:30 2001
--- shadow/2643.tmp.10276 Mon Jul 16 12:06:30 2001
***************
*** 0 ****
--- 1,118 ----
+ +============================================================================+
+ | derivation by extension of complex types does not permit addition of ONLY |
+ +----------------------------------------------------------------------------+
+ | Bug #: 2643 Product: Xerces-C++ |
+ | Status: NEW Version: 1.5 |
+ | Resolution: Platform: PC |
+ | Severity: Normal OS/Version: Windows NT/2K |
+ | Priority: Other Component: Validating Parser (Sche |
+ +----------------------------------------------------------------------------+
+ | Assigned To: xerces-c-dev@xml.apache.org |
+ | Reported By: tdodd@iss.net |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ Okay, I know support for complex type derivation is experimental, but I figured
+ you'd want to know abou this. Derivation by extension of complex types does
+ not permit addition of ONLY element content. Here's a sample schema, Bug.xsd:
+
+ <!-- Bug schema -->
+ <schema targetNamespace='http://www.foo.com'
+ xmlns='http://www.w3.org/2001/XMLSchema'
+ xmlns:foo='http://www.foo.com'
+ elementFormDefault='qualified'
+ version='1.0'>
+
+ <complexType name='BaseType'>
+ <attribute name='base-attr' type='string' use='required'/>
+ </complexType>
+
+ <complexType name='DummyElementType'>
+ <attribute name='added-element-attr' type='string' use='required'/>
+ </complexType>
+
+ <complexType name='DerivedType'>
+ <complexContent>
+ <extension base='foo:BaseType'>
+ <sequence>
+ <element name='added-element' type='foo:DummyElementType'
+ maxOccurs='unbounded'/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name='root' type='foo:DerivedType'/>
+ </schema>
+
+ Here's an instance document:
+
+ <?xml version='1.0' encoding='UTF-8' standalone='no'?>
+ <root xmlns='http://www.foo.com'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:schemaLocation='http://www.foo.com file:///dev/Bug.xsd'
+ base-attr='1'>
+ <added-element added-element-attr='2'/>
+ </root>
+
+ Here's how I parse it:
+
+ DOMParser parser;
+
+ parser.setErrorHandler(&m_errHandler);
+
+ parser.setIncludeIgnorableWhitespace(false);
+ parser.setDoValidation(true);
+ parser.setDoSchema(true);
+ parser.setValidationScheme(DOMParser::Val_Auto);
+ parser.setDoNamespaces(true);
+
+ parser.setCreateEntityReferenceNodes(false);
+ parser.setToCreateXMLDeclTypeNode(false);
+
+ try
+ {
+ parser.parse(wszFilename);
+ .
+ .
+ .
+
+ Parsing the instance document yields a SAXParseException specifying: "Parse
+ operation: Error parsing file 'D:\dev\Bug.xml', line 5, column 19
+ Message: Attribute '{}base-attr' is not declared for element 'root'."
+
+ Adding an attribute along with the element content in foo:DerivedType allows
+ the document to validate okay:
+
+ <!-- Bug schema -->
+ <schema targetNamespace='http://www.foo.com'
+ xmlns='http://www.w3.org/2001/XMLSchema'
+ xmlns:foo='http://www.foo.com'
+ elementFormDefault='qualified'
+ version='1.0'>
+
+ <complexType name='BaseType'>
+ <attribute name='base-attr' type='string' use='required'/>
+ </complexType>
+
+ <complexType name='DummyElementType'>
+ <attribute name='added-element-attr' type='string' use='required'/>
+ </complexType>
+
+ <complexType name='DerivedType'>
+ <complexContent>
+ <extension base='foo:BaseType'>
+ <sequence>
+ <element name='added-element' type='foo:DummyElementType'
+ maxOccurs='unbounded'/>
+ </sequence>
+ <!-- Dummy attribute to make Xerces happy. -->
+ <attribute name='dummy' type='string' use='optional'/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name='root' type='foo:DerivedType'/>
+ </schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org