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/06/15 13:10:21 UTC

svn commit: r547619 - in /incubator/tuscany/cpp/sdo/runtime/core: src/commonj/sdo/SDOXMLWriter.cpp test/fidelity.xml test/fidelity.xsd test/jira1112expected.xml test/main.cpp test/person.xsd test/sdotest.h test/sdotest2.cpp test/types.xsd

Author: robbinspg
Date: Fri Jun 15 04:10:20 2007
New Revision: 547619

URL: http://svn.apache.org/viewvc?view=rev&rev=547619
Log:
TUSCANY-1112 write namespace prefix for primitive elements

Added:
    incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xml   (with props)
    incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xsd   (with props)
    incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml   (with props)
    incubator/tuscany/cpp/sdo/runtime/core/test/person.xsd   (with props)
    incubator/tuscany/cpp/sdo/runtime/core/test/types.xsd   (with props)
Modified:
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp

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=547619&r1=547618&r2=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp Fri Jun 15 04:10:20 2007
@@ -1145,7 +1145,27 @@
                             }
                             else
                             {
-                                xmlTextWriterStartElementNS(writer, NULL, propertyName, NULL);
+                                // Write the startElement for non-root object
+                                SDOXMLString theName=propertyName;
+
+                                if (!propertyTypeURI.isNull() 
+                                    && !propertyTypeURI.equals("")
+                                    && !propertyTypeURI.equals(s_commonjsdo)
+                                    && !propertyTypeURI.equals(tnsURI))
+                                {
+                                    // Locate the namespace prefix
+                                    std::map<SDOXMLString,SDOXMLString>::iterator it = namespaceMap.find(propertyTypeURI);
+                                    if (it != namespaceMap.end())
+                                    {
+                                        theName = (*it).second;
+                                        theName += ":";
+                                        theName += propertyName;
+                                    }
+                                }
+
+                                xmlTextWriterStartElement(writer, theName);
+
+                                //xmlTextWriterStartElementNS(writer, NULL, propertyName, NULL);
                                 if (dataObject->isNull(pl[i]))
                                 {
                                     xmlTextWriterWriteAttributeNS(writer, s_xsi, s_nil, NULL, s_true);

Added: incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xml?view=auto&rev=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xml (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xml Fri Jun 15 04:10:20 2007
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+     
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+<!--447-->
+<RootElement33 xmlns="http://www.apache.org/tuscany/interop"
+  xmlns:tns="http://www.apache.org/tuscany/interop"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.apache.org/tuscany/interop fidelity.xsd">
+
+  <ComplexTypeAttributesTest Attribute="Attribute"
+                             AttributeWithDefaultValue="AttributeWithDefaultValueDefaultValue"
+                             AttributeWithFixedValue="AttributeWithFixedValueFixedValue"
+                             AttributeWithSDOAliasName="AttributeWithSDOAliasName"
+                             AttributeWithSDODataType="AttributeWithSDODataType"
+                             AttributeWithSDOName="AttributeWithSDODataType"
+                             AttributeWithSDOPropertySDOOppositePropertyType="idvalue0"
+                             AttributeWithSDOPropertyType="idvalue0"
+                             AttributeWithSDOString="AttributeWithSDOString"
+                             AttributeReference="AttributeReference"/>
+
+  <!--450-->
+  <ElementOfSimpleTypeWithSDOPropertyType>idvalue0</ElementOfSimpleTypeWithSDOPropertyType>
+  <ElementOfSimpleTypeWithSDOOppositePropertyType>idvalue0</ElementOfSimpleTypeWithSDOOppositePropertyType>
+
+  <!--445-->
+  <ComplexTypeOpenContent> 
+    <tns:ElementSubstitutionGroupExtends> 
+      <ElementInSubstitutionGroupBase>ElementInSubstitutionGroupBase</ElementInSubstitutionGroupBase> 
+      <ElementInSubstitutionGroupExtends>ElementInSubstitutionGroupExtends</ElementInSubstitutionGroupExtends> 
+    </tns:ElementSubstitutionGroupExtends> 
+  </ComplexTypeOpenContent>
+
+</RootElement33>
\ No newline at end of file

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xsd?view=auto&rev=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xsd Fri Jun 15 04:10:20 2007
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+     
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+<!--447-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+        targetNamespace="http://www.apache.org/tuscany/interop"
+        xmlns:tns="http://www.apache.org/tuscany/interop"
+        xmlns:sdo="commonj.sdo">
+
+  <!--488-->
+  <simpleType name="SimpleTypeWithNameType">
+    <restriction base="string"/>
+  </simpleType>
+  <element name="RootElement6" type="tns:SimpleTypeWithNameType"/>
+
+  <!--445-->
+  <complexType name="ComplexTypeOpenContentType">
+    <sequence>
+      <any namespace="##any"/>
+    </sequence>
+  </complexType>
+
+  <attribute name="AttributeReference" type="string"/>
+
+  <complexType name="ComplexTypeAttributesTestType">
+    <sequence>
+    </sequence>
+    <attribute name="Attribute" type="string"/>
+    <attribute name="AttributeWithSDOName" sdo:name="AttributeWithSDONameSDOName" type="string"/>
+    <attribute name="AttributeWithSDOAliasName" sdo:aliasName="AttributeWithSDOAliasNameSDOAliasName" type="string"/>
+    <attribute name="AttributeWithDefaultValue" type="string" default="AttributeWithDefaultValueDefaultValue"/>
+    <attribute name="AttributeWithFixedValue" type="string" fixed="AttributeWithFixedValueFixedValue"/>
+    <attribute ref="tns:AttributeReference"/>
+    <attribute name="AttributeWithSDOString" type="string" sdo:string="true"/>
+    <attribute name="AttributeWithSDOPropertyType" type="IDREF" sdo:propertyType="tns:SimpleTypeWithNameType"/>
+    <attribute name="AttributeWithSDOPropertySDOOppositePropertyType" type="IDREF" sdo:propertyType="tns:SimpleTypeWithNameType" sdo:oppositeProperty="tns:AttributeWithSDOPropertyType"/>
+    <attribute name="AttributeWithSDODataType" sdo:dataType="string" type="string"/>
+  </complexType>
+
+  <element name="RootElement33">
+    <complexType>
+      <sequence>
+        <element name="ComplexTypeAttributesTest" type="tns:ComplexTypeAttributesTestType"/>
+
+        <!--450-->
+        <element name="ElementOfSimpleTypeWithSDOPropertyType" type="IDREF" sdo:propertyType="tns:SimpleTypeWithNameType"/>
+        <element name="ElementOfSimpleTypeWithSDOOppositePropertyType" type="IDREF" sdo:propertyType="tns:SimpleTypeWithNameType" sdo:oppositeProperty="tns:ElementOfSimpleTypeWithSDOPropertyType"/>
+
+        <!--445-->
+        <element name="ComplexTypeOpenContent" type="tns:ComplexTypeOpenContentType"/>
+
+      </sequence>
+    </complexType>
+  </element>
+
+  <!--449-->
+
+  <complexType name="ComplexTypeSubstitutionGroupBaseType">
+    <sequence>
+      <element name="ElementInSubstitutionGroupBase" type="string"/>
+    </sequence>
+  </complexType>
+  <element name="ElementSubstitutionGroupBase" type="tns:ComplexTypeSubstitutionGroupBaseType"/>
+
+  <complexType name="ComplexTypeSubstitutionGroupExtendsType">
+    <complexContent>
+      <extension base="tns:ComplexTypeSubstitutionGroupBaseType">
+        <sequence>
+          <element name="ElementInSubstitutionGroupExtends" type="string"/>
+        </sequence>
+      </extension>
+    </complexContent>
+  </complexType>
+  <element name="ElementSubstitutionGroupExtends" type="tns:ComplexTypeSubstitutionGroupExtendsType" substitutionGroup="tns:ElementSubstitutionGroupBase"/>
+
+</schema>
\ No newline at end of file

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/fidelity.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 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=auto&rev=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml Fri Jun 15 04:10:20 2007
@@ -0,0 +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>
+  </person>
+</BOGUS>

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira1112expected.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp?view=diff&rev=547619&r1=547618&r2=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Fri Jun 15 04:10:20 2007
@@ -186,11 +186,13 @@
     TEST (  sdotest::jira1174() );
     TEST (  sdotest::jira1238() );
     TEST ( sdotest::loadWithoutSchema() );
+    //TEST (  sdotest::jira445() );
+    TEST (  sdotest::jira1112() );
 
 
     } catch(...)
     {
-        cout << "unexpected exception caught" << endl;
+        cout << "unexpected exception caught" << endl; 
     }
 
     cout << "Total tests:" << totaltests << " Tests passed:" << testspassed << endl;

Added: incubator/tuscany/cpp/sdo/runtime/core/test/person.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/person.xsd?view=auto&rev=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/person.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/person.xsd Fri Jun 15 04:10:20 2007
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+     
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://www.test.com/info"
+    xmlns:info="http://www.test.com/info">
+    <complexType name="nameType">
+        <sequence>
+            <element name="first" type="string"></element>
+            <element name="last" type="string"></element>
+        </sequence>
+    </complexType>
+    <complexType name="personType">
+        <sequence>
+            <element name="name" type="info:nameType"></element>
+        </sequence>
+    </complexType>
+</schema>

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/person.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/person.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h?view=diff&rev=547619&r1=547618&r2=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Fri Jun 15 04:10:20 2007
@@ -210,4 +210,6 @@
         static int jira1174();
         static int jira1238();
         static int loadWithoutSchema();
+        static int jira445();
+        static int jira1112();
 };

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp?view=diff&rev=547619&r1=547618&r2=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Fri Jun 15 04:10:20 2007
@@ -1908,4 +1908,60 @@
         cout << "Exception in loadWithoutSchema" << e << endl;
         return 0;
     }
+}
+
+int sdotest::jira445()
+{
+
+    try {
+        XSDHelperPtr xsh = HelperProvider::getXSDHelper();
+        XMLHelperPtr xmh = HelperProvider::getXMLHelper(xsh->getDataFactory());
+        xsh->defineFile("fidelity.xsd");
+        XMLDocumentPtr doc = xmh->loadFile("fidelity.xml");
+        xmh->save(doc, "jira445out.xml");
+        return comparefiles("jira445out.xml" ,"jira445expected.xml");
+
+    }
+    catch (SDORuntimeException e)
+    {
+        cout << "Exception in jira445" << e << endl;
+        return 0;
+    }
+}
+
+int sdotest::jira1112()
+{
+
+    try {
+        XSDHelperPtr xsh = HelperProvider::getXSDHelper();
+        XMLHelperPtr xmh = HelperProvider::getXMLHelper(xsh->getDataFactory());
+        xsh->defineFile("types.xsd");
+        unsigned int i,j;
+        if ((i = xsh->getErrorCount()) > 0)
+        {
+            cout << "types.xsd reported some errors: " <<endl;
+            for (j=0;j<i;j++)
+            {
+                cout << xsh->getErrorMessage(j) <<endl;
+            }
+        }
+
+        DataObjectPtr person = xsh->getDataFactory()->create("http://www.test.com/info","personType");
+        DataObjectPtr name = person->createDataObject("name");
+        name->setCString("first", "Will");
+        name->setCString("last", "Shakespeare");
+
+        DataObjectPtr add = xsh->getDataFactory()->create("http://Component" , "add");
+        add->setDataObject("person", person);
+
+        XMLDocumentPtr doc = xmh->createDocument(add, "", "BOGUS");
+        xmh->save(doc, "jira1112out.xml", 2);
+        return comparefiles("jira1112out.xml" ,"jira1112expected.xml");
+
+    }
+    catch (SDORuntimeException e)
+    {
+        cout << "Exception in jira1112" << e << endl;
+        return 0;
+    }
 }

Added: incubator/tuscany/cpp/sdo/runtime/core/test/types.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/types.xsd?view=auto&rev=547619
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/types.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/types.xsd Fri Jun 15 04:10:20 2007
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+     
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:ns0="http://www.test.com/info"
+    targetNamespace="http://Component"
+    elementNameDefault="qualified">
+    <xs:import schemaLocation="person.xsd"
+namespace="http://www.test.com/info"/>
+    <xs:element name="add">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="person" type="ns0:personType"
+    nillable="true"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+</xs:schema>
+

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/types.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/types.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date



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