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/14 13:48:37 UTC

[Bug 972] New - Element declaration with one child not created

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

*** shadow/972	Wed Mar 14 04:48:37 2001
--- shadow/972.tmp.10921	Wed Mar 14 04:48:37 2001
***************
*** 0 ****
--- 1,94 ----
+ +============================================================================+
+ | Element declaration with one child not created                             |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 972                         Product: Xerces-J                |
+ |       Status: NEW                         Version: 1.3.0                   |
+ |   Resolution:                            Platform: All                     |
+ |     Severity: Normal                   OS/Version: Other                   |
+ |     Priority:                           Component: DOM                     |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: xerces-j-dev@xml.apache.org                                  |
+ |  Reported By: johne@miles33.co.uk                                          |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ Given
+ 
+ DTD:d.dtd
+ 
+ <?xml version='1.0' encoding='UTF-8' ?>
+ <!--Generated by XML Authority-->
+ <!ELEMENT DATA (#PCDATA)>
+ <!ENTITY % global-attributes "DATA?">
+ <!ELEMENT BADSTUFF (%global-attributes;)?>
+ <!ELEMENT THINGS (#PCDATA)>
+ <!ELEMENT TESTS (THINGS? | BADSTUFF?)?>
+ 
+ 
+ and XML:
+ 
+ <?xml version = "1.0" encoding = "UTF-8"?>
+ <!DOCTYPE TESTS SYSTEM "d.dtd">
+ <TESTS>
+ 	<BADSTUFF>
+ 		<DATA>Oi</DATA>
+ 	</BADSTUFF>
+ </TESTS>
+ 
+ and test bed of dom.traversal.TreeWalkerView with grammar access allowed.
+ 
+ The org.\apache\xerces\parsers\DOMparser.java
+ 
+ 
+     /** Creates the children for the element decl. */
+     private Element createChildren(XMLContentSpec.Provider provider, 
+                                    int index, XMLContentSpec node,
+                                    DocumentImpl factory,
+                                    Element parent) throws Exception {
+ 
+ 
+ ...
+ ...
+ 
+         // flatten model
+ 
+ does not handle the single element declaration for BADSTUFF
+ 
+ 
+ 
+ i added the following cases code which kept me happy - but may notbe the 
+ correct thing to do!
+ 
+ 			//jbe mod 6/03/01
+ 			case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE:
+ 			case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE:
+ 			case XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE:
+ 			{
+                 // one node on its own
+                 int nIndex  = node.value;
+                 Element nchild = createChildren(provider, nIndex, node, 
+                                               factory, parent);
+ 
+                 String type = "choice";
+                 Element model = nchild;
+                 // set occurrence count
+                 switch (occurs) {
+                     case '+': {
+                         model.setAttribute("maxOccurs", "unbounded");
+                         break;
+                     }
+                     case '*': {
+                         model.setAttribute("minOccurs", "0");
+                         model.setAttribute("maxOccurs", "unbounded");
+                         break;
+                     }
+                     case '?': {
+                         model.setAttribute("minOccurs", "0");
+                         break;
+                     }
+                 }
+ 
+                 return model;
+ 			}

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org