You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2007/07/06 14:44:07 UTC

svn commit: r553866 - in /incubator/tuscany/cpp/sdo/runtime/core: src/commonj/sdo/SDOSchemaSAX2Parser.cpp src/commonj/sdo/SDOXMLWriter.cpp src/commonj/sdo/SchemaInfo.cpp src/commonj/sdo/SchemaInfo.h test/jira1112expected.xml test/loadload-output.txt

Author: robbinspg
Date: Fri Jul  6 05:44:06 2007
New Revision: 553866

URL: http://svn.apache.org/viewvc?view=rev&rev=553866
Log:
TUSCANY-1112 correct handling of element form (in HEAD)

Modified:
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.cpp
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.h
    incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml
    incubator/tuscany/cpp/sdo/runtime/core/test/loadload-output.txt

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp?view=diff&rev=553866&r1=553865&r2=553866
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp Fri Jul  6 05:44:06 2007
@@ -230,6 +230,14 @@
                         if (attributes[i].getName().equalsIgnoreCase("targetNamespace"))
                         {
                             schemaInfo.setTargetNamespaceURI(attributes[i].getValue());
+                        }
+
+                        if (attributes[i].getName().equalsIgnoreCase("elementFormDefault"))
+                        {
+                            if (attributes[i].getValue().equals("qualified"))
+                            {
+                                schemaInfo.setElementFormDefaultQualified(true);
+                            }
                         }                        
                     }
 
@@ -749,7 +757,23 @@
                 thisProperty.name,
                 thisProperty.localname);
 
-            thisProperty.namespaceURI = schemaInfo.getTargetNamespaceURI();
+            // Set the property's namespace if elementForm is "qualified"
+            bool elementFormQualified = schemaInfo.isElementFormDefaultQualified();
+            SDOXMLString elementForm = attributes.getValue("form");
+            if (!elementForm.isNull())
+            {
+                elementFormQualified = false;
+                if (elementForm.equals("qualified"))
+                {
+                    elementFormQualified = true;
+                }
+            }
+
+            if (elementFormQualified
+                || currentType.name.equals("RootType"))
+            {
+                thisProperty.namespaceURI = schemaInfo.getTargetNamespaceURI();
+            }
             
             setType(thisProperty, attributes, namespaces);
 

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp?view=diff&rev=553866&r1=553865&r2=553866
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp Fri Jul  6 05:44:06 2007
@@ -739,10 +739,12 @@
                 // Write the startElement for non-root object
                 SDOXMLString theName=elementName;
 
+                // If an elementURI is specified then the elementForm is "qualified"
                 if (!elementURI.isNull() 
                     && !elementURI.equals("")
                     && !elementURI.equals(s_commonjsdo)
-                    && !elementURI.equals(tnsURI))
+                    //&& !elementURI.equals(tnsURI)
+                    )
                 {
                     // Locate the namespace prefix
                     std::map<SDOXMLString,SDOXMLString>::iterator it = namespaceMap.find(elementURI);
@@ -1388,8 +1390,8 @@
               else
               {
                   // The property has been defined programatically so we will
-                  // assume it is the namespace fo the parent DataObject
-                  elementURI = typeImpl.getURI();
+                  // assume elementForm is "unqualified"
+                  elementURI = ""; 
               }
 
           }

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.cpp?view=diff&rev=553866&r1=553865&r2=553866
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.cpp Fri Jul  6 05:44:06 2007
@@ -26,7 +26,8 @@
     {
 
         SchemaInfo::SchemaInfo()
-            : targetNamespaceURI("")
+            : targetNamespaceURI(""),
+              elementFormDefaultQualified(false)
         {
         }
         

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.h?view=diff&rev=553866&r1=553865&r2=553866
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SchemaInfo.h Fri Jul  6 05:44:06 2007
@@ -49,9 +49,12 @@
             SDO_SPI const SDOXMLString& getTargetNamespaceURI() const {return targetNamespaceURI;}
             SDO_SPI void setTargetNamespaceURI(const SDOXMLString& URI) {targetNamespaceURI = URI;}            
             
+            SDO_SPI bool isElementFormDefaultQualified() {return elementFormDefaultQualified;}            
+            SDO_SPI void setElementFormDefaultQualified(bool qualified) {elementFormDefaultQualified = qualified;}            
         private:
             SAX2Namespaces    schemaNamespaces;
-            SDOXMLString    targetNamespaceURI;            
+            SDOXMLString    targetNamespaceURI;           
+            bool elementFormDefaultQualified;
             
         };
     } // End - namespace sdo

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml?view=diff&rev=553866&r1=553865&r2=553866
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml Fri Jul  6 05:44:06 2007
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <BOGUS xmlns="http://Component" xsi:type="add" xmlns:tns="http://Component" xmlns:tns2="http://www.test.com/info" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <person>
-    <tns2:name>
-      <tns2:first>Will</tns2:first>
-      <tns2:last>Shakespeare</tns2:last>
-    </tns2:name>
+    <name>
+      <first>Will</first>
+      <last>Shakespeare</last>
+    </name>
   </person>
 </BOGUS>

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/loadload-output.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/loadload-output.txt?view=diff&rev=553866&r1=553865&r2=553866
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/loadload-output.txt (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/loadload-output.txt Fri Jul  6 05:44:06 2007
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<company xmlns="companyNS" xsi:type="CompanyType" xmlns:tns="companyNS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ACME"><sdo:changeSummary xmlns:sdo="commonj.sdo" logging="true"><create>#/departments.0/employees.0/opendataobjectlist.0</create><create>#/departments.0/employees.0/opendataobject</create><create>#/departments.0/employees.0</create></sdo:changeSummary><departments name="Advanced Technologies" location="NY" number="123"><employees name="Albert" SN="E0001" openstring="Value Of Open String" openboolean="true"><openintlist>45</openintlist><opendataobjectlist name="MyOpenName"/><opendataobject name="MyOpenName"/></employees><employees name="Boris" SN="E0002" manager="true"/><employees name="Carl" SN="E0003"/></departments></company>
+<company xmlns="companyNS" xsi:type="CompanyType" xmlns:tns="companyNS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ACME"><sdo:changeSummary xmlns:sdo="commonj.sdo" logging="true"><create>#/departments.0/employees.0/opendataobjectlist.0</create><create>#/departments.0/employees.0/opendataobject</create><create>#/departments.0/employees.0</create></sdo:changeSummary><departments name="Advanced Technologies" location="NY" number="123"><employees name="Albert" SN="E0001" openstring="Value Of Open String" openboolean="true"><openintlist>45</openintlist><tns:opendataobjectlist name="MyOpenName"/><tns:opendataobject name="MyOpenName"/></employees><employees name="Boris" SN="E0002" manager="true"/><employees name="Carl" SN="E0003"/></departments></company>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org