Author: robbinspg
Date: Mon Feb 11 07:13:59 2008
New Revision: 620502
URL: http://svn.apache.org/viewvc?rev=620502&view=rev
Log:
TUSCANY-2041 null extended primitive types cause parsing failure
The logic in SDOSAX2Parser when encountering an end element tag is incorrect.
In the case of an extended primitive type a new DO is created but this is not
popped off the stack when we hit the end element tag.
Added:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xml
(with props)
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xsd
(with props)
Modified:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOUtils.cpp
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/main.cpp
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest.h
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest2.cpp
Modified:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp?rev=620502&r1=620501&r2=620502&view=diff
==============================================================================
---
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
(original)
+++
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
Mon Feb 11 07:13:59 2008
@@ -1173,16 +1173,29 @@
return;
}
+ bool popDO = false; // Indicate if we need to pop DO from stack
+
// If currentPropertySetting is set (name is not null)
// then we need to set the property now
if (!currentPropertySetting.name.isNull())
{
- if (currentPropertySetting.isNULL)
+ // Determine if this is an extended primitive
+ bool isExtendedPrimitive = false;
+ const Type& tp = currentPropertySetting.dataObject->getType();
+ XSDTypeInfo* typeInfo = (XSDTypeInfo*)
+ ((DASType*)&tp)->getDASValue("XMLDAS::TypeInfo");
+ if (typeInfo &&
typeInfo->getTypeDefinition().isExtendedPrimitive)
{
+ isExtendedPrimitive = true;
+ // If this setting was for an extended primitive we need
to remove the
+ // DO from the stack
+ popDO = true;
+ }
+ if (currentPropertySetting.isNULL)
+ {
currentPropertySetting.dataObject->
setNull((const char*)currentPropertySetting.name);
-
}
else
{
@@ -1192,10 +1205,7 @@
}
try
{
- const Type& tp =
currentPropertySetting.dataObject->getType();
- XSDTypeInfo* typeInfo = (XSDTypeInfo*)
- ((DASType*)&tp)->getDASValue("XMLDAS::TypeInfo");
- if (typeInfo &&
typeInfo->getTypeDefinition().isExtendedPrimitive)
+ if (isExtendedPrimitive)
{
const Property& p =
currentPropertySetting.dataObject->getProperty(
"value");
@@ -1230,18 +1240,7 @@
setCString((const char*)"value",
currentPropertySetting.getStringWithCDataMarkers().c_str() );
}
}
- if (dataObjectStack.size() == 0 || rootDataObject
== dataObjectStack.top())
- {
- currentDataObject = 0;
- currentDataObjectType = 0;
- }
- else
- {
- dataObjectStack.pop();
- currentDataObject = dataObjectStack.top();
- currentDataObjectType =
&(currentDataObject->getType());
- }
-
+ popDO = true;
}
else
{
@@ -1309,7 +1308,12 @@
}
changeSummary = false;
}
-
+
+ popDO = true;
+ }
+
+ if (popDO)
+ {
if (dataObjectStack.size() == 0 || rootDataObject ==
dataObjectStack.top())
{
currentDataObject = 0;
@@ -1322,6 +1326,7 @@
currentDataObjectType = &(currentDataObject->getType());
}
}
+
LOGEXIT(INFO,"SDOSAX2Parser: endElementNs - exit4");
}
Modified:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOUtils.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOUtils.cpp?rev=620502&r1=620501&r2=620502&view=diff
==============================================================================
---
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOUtils.cpp
(original)
+++
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOUtils.cpp
Mon Feb 11 07:13:59 2008
@@ -223,8 +223,11 @@
else if (propertyType.isDataType())
{
printTabs(out, incr);
- out<< "Property Value: "
- << dataObject->getCString(pl[i]) <<endl ;
+ out<< "Property Value: " ;
+ if (dataObject->isNull(pl[i]))
+ out << "NULL" << endl;
+ else
+ out << dataObject->getCString(pl[i]) <<endl ;
}
//////////////////////////////////////////////////////////////////////
Modified: incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/main.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/main.cpp?rev=620502&r1=620501&r2=620502&view=diff
==============================================================================
--- incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/main.cpp
(original)
+++ incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/main.cpp Mon
Feb 11 07:13:59 2008
@@ -46,6 +46,7 @@
int totaltests=0;
int value = 0;
try {
+
//TEST ( sdotest::eBayTest() );
// TEST ( sdotest::xhtml1() );
TEST ( sdotest::scopetest() );
@@ -191,6 +192,7 @@
TEST ( sdotest::elementFormDefaultQualified() );
TEST ( sdotest::elementFormDefaultQualifiedSequence() );
TEST ( sdotest::xsiTypeAbstract() );
+ TEST ( sdotest::nullExtendedPrimitive() );
} catch(...)
Added:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xml?rev=620502&view=auto
==============================================================================
---
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xml
(added)
+++
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xml
Mon Feb 11 07:13:59 2008
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<tns:Top xmlns:tns="http://www.example.org/AnnonTypes"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.example.org/AnnonTypes AnnonTypes2.xsd
">
+ <tns:attribute name="ETH_GW" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+ <tns:attribute name="ETH_IP" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+ <tns:attribute name="ETH_MASK" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+ <tns:attribute name="SN" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+
+
+</tns:Top>
Propchange:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xsd?rev=620502&view=auto
==============================================================================
---
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xsd
(added)
+++
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xsd
Mon Feb 11 07:13:59 2008
@@ -0,0 +1,43 @@
+<?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.example.org/AnnonTypes"
+ xmlns:tns="http://www.example.org/AnnonTypes"
elementFormDefault="qualified">
+
+
+
+ <element name="Top">
+ <complexType>
+ <sequence>
+ <element name="attribute" nillable="true" minOccurs="0"
maxOccurs="unbounded">
+ <complexType>
+ <simpleContent>
+ <extension base="string">
+ <attribute name="name" type="string"
use="required"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+
+</schema>
\ No newline at end of file
Propchange:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/nullExtendedPrimitive.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest.h
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest.h?rev=620502&r1=620501&r2=620502&view=diff
==============================================================================
--- incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest.h
(original)
+++ incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest.h Mon
Feb 11 07:13:59 2008
@@ -215,4 +215,5 @@
static int elementFormDefaultQualified();
static int elementFormDefaultQualifiedSequence();
static int xsiTypeAbstract();
+ static int nullExtendedPrimitive();
};
Modified:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest2.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest2.cpp?rev=620502&r1=620501&r2=620502&view=diff
==============================================================================
--- incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest2.cpp
(original)
+++ incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest2.cpp
Mon Feb 11 07:13:59 2008
@@ -2029,4 +2029,36 @@
cout << "Exception in xsiTypeAbstract: " << e << endl;
return 0;
}
+}
+
+int sdotest::nullExtendedPrimitive()
+{
+
+ try {
+ XSDHelperPtr xsh = HelperProvider::getXSDHelper();
+ XMLHelperPtr xmh = HelperProvider::getXMLHelper(xsh->getDataFactory());
+ xsh->defineFile("nullExtendedPrimitive.xsd");
+ unsigned int i,j;
+ if ((i = xsh->getErrorCount()) > 0)
+ {
+ cout << "nullExtendedPrimitive.xsd reported some errors: " <<endl;
+ for (j=0;j<i;j++)
+ {
+ cout << xsh->getErrorMessage(j) <<endl;
+ }
+ }
+ // SDOUtils::printTypes(cout, xsh->getDataFactory());
+
+ XMLDocumentPtr doc = xmh->loadFile("nullExtendedPrimitive.xml");
+
+ //cout << doc->getRootDataObject() <<endl;
+
+
+ return 1;
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in nullExtendedPrimitive: " << e << endl;
+ return 0;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]