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/08/23 00:14:07 UTC
svn commit: r568759 - in /incubator/tuscany/cpp/sdo/runtime/core:
src/commonj/sdo/SDOXMLWriter.cpp test/main.cpp test/sdotest.h
test/sdotest2.cpp test/xsiTypeAbstract.xsd test/xsiTypeAbstract_expected.xml
Author: robbinspg
Date: Wed Aug 22 15:14:07 2007
New Revision: 568759
URL: http://svn.apache.org/viewvc?rev=568759&view=rev
Log:
TUSCANY-1564 Always write xsi:type for a property that is an abstract Type
Added:
incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd (with props)
incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml (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?rev=568759&r1=568758&r2=568759&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp Wed Aug 22 15:14:07 2007
@@ -1326,6 +1326,8 @@
{
bool xsiTypeNeeded = false;
+ const Type& propertyType = prop.getType();
+
// If this is a defined property with property information
// we use the uri and name from the definition
XSDPropertyInfo* pi = getPropertyInfo(prop);
@@ -1340,7 +1342,6 @@
{
elementName = prop.getName();
- const Type& propertyType = prop.getType();
SDOXMLString propTypeName = propertyType.getName();
SDOXMLString propTypeURI = propertyType.getURI();
DataObjectImpl* dataObjectImpl = (DataObjectImpl*)getRawPointer(dataObject);
@@ -1399,6 +1400,11 @@
elementURI = "";
}
+ }
+
+ if (propertyType.isAbstractType())
+ {
+ xsiTypeNeeded = true;
}
return xsiTypeNeeded;
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?rev=568759&r1=568758&r2=568759&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Wed Aug 22 15:14:07 2007
@@ -190,6 +190,7 @@
TEST ( sdotest::jira1112() );
TEST ( sdotest::elementFormDefaultQualified() );
TEST ( sdotest::elementFormDefaultQualifiedSequence() );
+ TEST ( sdotest::xsiTypeAbstract() );
TEST ( sdotest::refCount() );
} catch(...)
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?rev=568759&r1=568758&r2=568759&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Wed Aug 22 15:14:07 2007
@@ -214,4 +214,5 @@
static int refCount();
static int elementFormDefaultQualified();
static int elementFormDefaultQualifiedSequence();
+ static int xsiTypeAbstract();
};
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?rev=568759&r1=568758&r2=568759&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Wed Aug 22 15:14:07 2007
@@ -1942,4 +1942,37 @@
cout << "Exception in elementFormDefaultQualifiedSequence: " << e << endl;
return 0;
}
+}
+
+int sdotest::xsiTypeAbstract()
+{
+
+ try {
+ XSDHelperPtr xsh = HelperProvider::getXSDHelper();
+ XMLHelperPtr xmh = HelperProvider::getXMLHelper(xsh->getDataFactory());
+ xsh->defineFile("xsiTypeAbstract.xsd");
+ unsigned int i,j;
+ if ((i = xsh->getErrorCount()) > 0)
+ {
+ cout << "xsiTypeAbstract.xsd reported some errors: " <<endl;
+ for (j=0;j<i;j++)
+ {
+ cout << xsh->getErrorMessage(j) <<endl;
+ }
+ }
+
+
+ DataObjectPtr x = xsh->getDataFactory()->create("","X");
+ DataObjectPtr concrete = xsh->getDataFactory()->create("","concreteType");
+ x->setDataObject("abstract", concrete);
+
+ XMLDocumentPtr doc = xmh->createDocument(x, "", "X");
+ xmh->save(doc, "xsiTypeAbstract_out.xml", 2);
+ return comparefiles("xsiTypeAbstract_out.xml" ,"xsiTypeAbstract_expected.xml");
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in xsiTypeAbstract: " << e << endl;
+ return 0;
+ }
}
Added: incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd?rev=568759&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd Wed Aug 22 15:14:07 2007
@@ -0,0 +1,44 @@
+<?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.
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="abstract" type="abstractType"/>
+
+ <xsd:complexType name="abstractType" abstract="true"/>
+
+ <xsd:complexType name="concreteType">
+ <xsd:complexContent>
+ <xsd:extension base="abstractType">
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="prop1" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:element name="X">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="abstract"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
\ No newline at end of file
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml?rev=568759&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml Wed Aug 22 15:14:07 2007
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<X xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <abstract xsi:type="concreteType"/>
+</X>
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml
------------------------------------------------------------------------------
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