Author: robbinspg
Date: Tue Aug 21 12:24:24 2007
New Revision: 568241
URL: http://svn.apache.org/viewvc?rev=568241&view=rev
Log:
TUSCANY-1566 Correctly write namespace for primatices in sequenced DO
Added:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq.xsd
(with props)
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq_expected.xml
(with props)
Modified:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOXMLWriter.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/SDOXMLWriter.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp?rev=568241&r1=568240&r2=568241&view=diff
==============================================================================
---
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
(original)
+++
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
Tue Aug 21 12:24:24 2007
@@ -989,8 +989,25 @@
// many-valued.
if (!pi &&
!seqProp.isMany()) continue;
+ // Write the startElement for non-root object
+ SDOXMLString theName=seqPropName;
+
+ if (!seqPropURI.isNull()
+ && !seqPropURI.equals("")
+ && !seqPropURI.equals(s_commonjsdo))
+ {
+ // Locate the namespace prefix
+ std::map<SDOXMLString,SDOXMLString>::iterator
it = namespaceMap.find(seqPropURI);
+ if (it != namespaceMap.end())
+ {
+ theName = (*it).second;
+ theName += ":";
+ theName += seqPropName;
+ }
+ }
+ xmlTextWriterStartElement(writer, theName);
+
/* Use our wrapper function just in case the
element has CDATA in it */
- xmlTextWriterStartElement(writer, seqPropName);
writeXMLElement(writer,
seqPropName,
sequence->getCStringValue(i));
Added:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq.xsd?rev=568241&view=auto
==============================================================================
---
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq.xsd
(added)
+++
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq.xsd
Tue Aug 21 12:24:24 2007
@@ -0,0 +1,40 @@
+<?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 targetNamespace="test"
+ xmlns="test" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
+
+ <xs:element name="x" type="xT"/>
+
+ <xs:complexType name="xT">
+ <xs:choice maxOccurs="unbounded">
+ <xs:element name="a" type="aT" minOccurs="0"
maxOccurs="unbounded" />
+ <xs:element name="b" type="xs:string" />
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="aT">
+ <xs:choice maxOccurs="unbounded">
+ <xs:element name="a1" type="xs:string" minOccurs="0"
maxOccurs="unbounded" />
+ <xs:element name="a2" type="xs:string" minOccurs="0"
maxOccurs="unbounded" />
+ </xs:choice>
+ </xs:complexType>
+
+</xs:schema>
\ No newline at end of file
Propchange:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq_expected.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq_expected.xml?rev=568241&view=auto
==============================================================================
---
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq_expected.xml
(added)
+++
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq_expected.xml
Tue Aug 21 12:24:24 2007
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<a xsi:type="tns2:aT" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns2="test">
+ <tns2:a1>test data</tns2:a1>
+</a>
Propchange:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq_expected.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/elementFormDefaultQualifiedSeq_expected.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
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=568241&r1=568240&r2=568241&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 Tue
Aug 21 12:24:24 2007
@@ -189,6 +189,7 @@
//TEST ( sdotest::jira445() );
TEST ( sdotest::jira1112() );
TEST ( sdotest::elementFormDefaultQualified() );
+ TEST ( sdotest::elementFormDefaultQualifiedSequence() );
} catch(...)
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=568241&r1=568240&r2=568241&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 Tue
Aug 21 12:24:24 2007
@@ -213,4 +213,5 @@
static int jira445();
static int jira1112();
static int elementFormDefaultQualified();
+ static int elementFormDefaultQualifiedSequence();
};
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=568241&r1=568240&r2=568241&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
Tue Aug 21 12:24:24 2007
@@ -1964,4 +1964,36 @@
cout << "Exception in jira1112" << e << endl;
return 0;
}
+}
+int sdotest::elementFormDefaultQualifiedSequence()
+{
+
+ try {
+ XSDHelperPtr xsh = HelperProvider::getXSDHelper();
+ XMLHelperPtr xmh = HelperProvider::getXMLHelper(xsh->getDataFactory());
+ xsh->defineFile("elementFormDefaultQualifiedSeq.xsd");
+ unsigned int i,j;
+ if ((i = xsh->getErrorCount()) > 0)
+ {
+ cout << "elementFormDefaultQualifiedSeq.xsd reported some errors:
" <<endl;
+ for (j=0;j<i;j++)
+ {
+ cout << xsh->getErrorMessage(j) <<endl;
+ }
+ }
+
+
+ DataObjectPtr x = xsh->getDataFactory()->create("test","xT");
+ DataObjectPtr a = x->createDataObject("a");
+ a->setCString("a1.1", "test data");
+
+ XMLDocumentPtr doc = xmh->createDocument(a, "", "a");
+ xmh->save(doc, "elementFormDefaultQualifiedSeq_out.xml", 2);
+ return comparefiles("elementFormDefaultQualifiedSeq_out.xml"
,"elementFormDefaultQualifiedSeq_expected.xml");
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in elementFormDefaultQualifiedSequence: " << e <<
endl;
+ return 0;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]