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/05/01 18:42:52 UTC
svn commit: r534152 - in /incubator/tuscany/cpp/sdo/runtime/core:
src/commonj/sdo/SDOSchemaSAX2Parser.cpp test/main.cpp
test/overlappingtypes.xsd test/sdotest.h test/sdotest2.cpp
Author: robbinspg
Date: Tue May 1 09:42:51 2007
New Revision: 534152
URL: http://svn.apache.org/viewvc?view=rev&rev=534152
Log:
TUSCANY-12238 - avoid anonymous type name clashes
Added:
incubator/tuscany/cpp/sdo/runtime/core/test/overlappingtypes.xsd (with props)
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.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/SDOSchemaSAX2Parser.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp?view=diff&rev=534152&r1=534151&r2=534152
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp Tue May 1 09:42:51 2007
@@ -1247,14 +1247,27 @@
const SAX2Attributes& attributes,
const SAX2Namespaces& namespaces)
{
- std::map<SDOXMLString,SDOXMLString>::iterator it;
setName(attributes, type.name, type.localname);
- // If localname is not set it is anonymous so use the enclosing element name
+ // If localname is not set it is anonymous so use the enclosing element name
if (type.localname.isNull())
{
type.localname = currentProperty.name;
+
+ // ensure anonymous type name does not clash with existing type
+ for (int suffix = 1; ; suffix++)
+ {
+ SDOXMLString typeUri = TypeDefinitionsImpl::getTypeQName(type.uri, type.localname);
+ XMLDAS_TypeDefs::iterator it = typeDefinitions.types.find(typeUri);
+ if(it == typeDefinitions.types.end())
+ {
+ break;
+ }
+ char buff[32];
+ sprintf(buff, "%d", suffix);
+ type.localname += buff;
+ }
}
else
{
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=534152&r1=534151&r2=534152
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Tue May 1 09:42:51 2007
@@ -184,6 +184,7 @@
TEST ( sdotest::typedefinitionstest() );
TEST ( sdotest::jira1174() );
+ TEST ( sdotest::jira1238() );
} catch(...)
{
Added: incubator/tuscany/cpp/sdo/runtime/core/test/overlappingtypes.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/overlappingtypes.xsd?view=auto&rev=534152
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/overlappingtypes.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/overlappingtypes.xsd Tue May 1 09:42:51 2007
@@ -0,0 +1,57 @@
+<?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="ElementA">
+ <complexType>
+ <sequence>
+ <element name="Overlapping">
+ <complexType>
+ <sequence>
+ <element name="ValueA" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="ElementB">
+ <complexType>
+ <sequence>
+ <element name="Overlapping">
+ <complexType>
+ <sequence>
+ <element name="ValueB" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+</schema>
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/overlappingtypes.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/overlappingtypes.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=534152&r1=534151&r2=534152
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Tue May 1 09:42:51 2007
@@ -208,4 +208,5 @@
static int typedefinitionstest();
static int eBayTest();
static int jira1174();
+ static int jira1238();
};
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=534152&r1=534151&r2=534152
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Tue May 1 09:42:51 2007
@@ -1869,3 +1869,25 @@
}
}
+int sdotest::jira1238()
+{
+
+ try {
+
+
+ DataFactoryPtr mdg = DataFactory::getDataFactory();
+
+ XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg);
+
+ xsh->defineFile("overlappingtypes.xsd");
+
+ mdg->getType("http://www.example.org/AnnonTypes", "Overlapping");
+ mdg->getType("http://www.example.org/AnnonTypes", "Overlapping1");
+ return 1;
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in jira1238" << e << endl;
+ return 0;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org