You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2001/03/02 23:26:47 UTC

[Bug 823] New - default namespace declaration node inherited by child elements

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=823

*** shadow/823	Fri Mar  2 14:26:47 2001
--- shadow/823.tmp.28569	Fri Mar  2 14:26:47 2001
***************
*** 0 ****
--- 1,150 ----
+ +============================================================================+
+ | default namespace declaration node inherited by child elements             |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 823                         Product: Xerces-J                |
+ |       Status: NEW                         Version: 1.3.0                   |
+ |   Resolution:                            Platform: Sun                     |
+ |     Severity: Normal                   OS/Version: Solaris                 |
+ |     Priority:                           Component: Schema-Structures       |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: xerces-j-dev@xml.apache.org                                  |
+ |  Reported By: matt@avolent.com                                             |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ It seems that default namespace declarations are not inherited by child 
+ elements.
+ 
+ -----------------------------------------------------------------
+ Message.xml:
+ 
+ <?xml version="1.0" encoding="UTF-8"?>
+ <Message 
+     xmlns="depo://MetaInfo/Components/Transport/Message"
+     xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" 
+     xsi:schemaLocation="depo://MetaInfo/Components/Transport/Message 
+                         Message.xsd
+                         depo://MetaInfo/Components/PaymentMessageBody 
+                         PaymentMessageBody.xsd">
+     <Header>
+         <Version>1</Version>
+         <UniqueId>123123</UniqueId>
+         <MessageContext>fooContext</MessageContext>
+         <MessageId>4534634</MessageId>
+         <AddressStack>xxx</AddressStack>
+         <ReplyTo>yyy</ReplyTo>
+         <Throwable>zzz</Throwable>
+         <Timestamp>aTimestamp</Timestamp>
+     </Header>
+     <Body xmlns="depo://MetaInfo/Components/PaymentMessageBody">
+         <PaymentID>234234</PaymentID>
+         <ConsumerID>345345</ConsumerID>
+         <PaymentInfo>
+             <PaymentDate>345</PaymentDate>
+             <PaymentAmount>345345</PaymentAmount>
+             <FundingAccountID>345</FundingAccountID>
+         </PaymentInfo>
+     </Body>
+ </Message>
+ 
+ -----------------------------------------------------------------
+ Message.xsd:
+ 
+ <?xml version="1.0" encoding="UTF-8"?>
+ <xsd:schema
+     targetNamespace="depo://MetaInfo/Components/Transport/Message"
+     xmlns="depo://MetaInfo/Components/Transport/Message"
+     xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
+     elementFormDefault="unqualified"
+     attributeFormDefault="unqualified">
+     <xsd:complexType name="MessageBodyType">
+         <xsd:sequence minOccurs="0">
+             <xsd:any processContents="strict" 
+                      minOccurs="0" maxOccurs="unbounded"/>
+         </xsd:sequence>
+     </xsd:complexType>
+     <xsd:complexType name="MessageHeaderType">
+         <xsd:sequence>
+             <xsd:element name="Version" type="xsd:string"/>
+             <xsd:element name="UniqueId" type="xsd:string"/>
+             <xsd:element name="MessageContext" type="xsd:string"/>
+             <xsd:element name="MessageId" type="xsd:string"/>
+             <xsd:element name="AddressStack" type="xsd:string"/>
+             <xsd:element name="ReplyTo" type="xsd:string"/>
+             <xsd:element name="Throwable" type="xsd:string"/>
+             <xsd:element name="Timestamp" type="xsd:string"/>
+         </xsd:sequence>
+     </xsd:complexType>
+     <xsd:complexType name="MessageType">
+         <xsd:sequence>
+             <xsd:element name="Header" type="MessageHeaderType"/>
+             <xsd:element name="Body" type="MessageBodyType"/>
+         </xsd:sequence>
+     </xsd:complexType>
+     <xsd:element name="Message" type="MessageType"/>
+ </xsd:schema>
+ 
+ -----------------------------------------------------------------
+ PaymentMessageBody.xsd:
+ 
+ <?xml version="1.0" encoding="UTF-8"?>
+ <xsd:schema
+     xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
+     xmlns="depo://MetaInfo/Components/PaymentMessageBody"
+     targetNamespace="depo://MetaInfo/Components/PaymentMessageBody"
+     elementFormDefault="unqualified"
+     attributeFormDefault="unqualified">
+     <xsd:element name="PaymentID" type="xsd:string"/>
+     <xsd:element name="ConsumerID" type="xsd:string"/>
+     <xsd:element name="PaymentInfo">
+         <xsd:complexType>
+             <xsd:sequence>
+                 <xsd:element name="PaymentDate" type="xsd:string"/>
+                 <xsd:element name="PaymentAmount" type="xsd:string"/>
+                 <xsd:element name="FundingAccountID" type="xsd:string"/>
+             </xsd:sequence>
+         </xsd:complexType>
+     </xsd:element>
+ </xsd:schema>
+ -----------------------------------------------------------------
+ 
+ I use this java to parse the Message.xml:
+ 
+ -----------------------------------------------------------------
+ DocumentBuilderFactory factory = DocumentBuilderFactoryImpl.newInstance();
+ factory.setValidating( true );
+ factory.setNamespaceAware( true );
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.parse( new InputSource( aReader ) );
+ -----------------------------------------------------------------
+ 
+ Xerces reports these errors:
+ 
+ -----------------------------------------------------------------
+ Element type "Header" must be declared.
+ Element type "Version" must be declared.
+ Element type "UniqueId" must be declared.
+ Element type "MessageContext" must be declared.
+ Element type "MessageId" must be declared.
+ Element type "AddressStack" must be declared.
+ Element type "ReplyTo" must be declared.
+ Element type "Throwable" must be declared.
+ Element type "Timestamp" must be declared.
+ Element type "Body" must be declared.
+ Element type "PaymentDate" must be declared.
+ Element type "PaymentAmount" must be declared.
+ Element type "FundingAccountID" must be declared.
+ The content of element type "PaymentInfo" must match 
+     "(PaymentDate,PaymentAmount,FundingAccountID)".
+ The content of element type "Message" must match "(Header,Body)".
+ -----------------------------------------------------------------
+ 
+ As I understand namespaces, the namespace of all child elements should 
+ be inherited from the xmlns attribute in the parent element.
+ 
+ It does not appear to work in Xerces 1.3.0.
+ 
+ Thanks,
+ matt