summaryrefslogtreecommitdiff
path: root/cpp/src/XMLTransform/XMLTransform.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-11-20 00:10:34 +0000
committerMark Spruiell <mes@zeroc.com>2002-11-20 00:10:34 +0000
commit54b6d771110797f499611b4daedfb9672fa089b7 (patch)
tree909f297901000477b64df615414eab847c0f9bff /cpp/src/XMLTransform/XMLTransform.cpp
parentfixing usage (diff)
downloadice-54b6d771110797f499611b4daedfb9672fa089b7.tar.bz2
ice-54b6d771110797f499611b4daedfb9672fa089b7.tar.xz
ice-54b6d771110797f499611b4daedfb9672fa089b7.zip
cleaning up exception transform; adding support for xs:include
Diffstat (limited to 'cpp/src/XMLTransform/XMLTransform.cpp')
-rw-r--r--cpp/src/XMLTransform/XMLTransform.cpp55
1 files changed, 45 insertions, 10 deletions
diff --git a/cpp/src/XMLTransform/XMLTransform.cpp b/cpp/src/XMLTransform/XMLTransform.cpp
index 5eef0c79cd7..37f9916f060 100644
--- a/cpp/src/XMLTransform/XMLTransform.cpp
+++ b/cpp/src/XMLTransform/XMLTransform.cpp
@@ -433,6 +433,7 @@ static const string sequenceElementName = "xs:sequence";
static const string annotationElementName = "xs:annotation";
static const string appinfoElementName = "xs:appinfo";
static const string importElementName = "xs:import";
+static const string includeElementName = "xs:include";
static const string elementElementName = "xs:element";
static const string complexContentElementName = "xs:complexContent";
static const string extensionElementName = "xs:extension";
@@ -525,6 +526,37 @@ public:
}
};
+//
+// Exception transform - this transform should never be invoked,
+// since exceptions cannot be members of another type.
+//
+class ExceptionTransform : public Transform
+{
+public:
+
+ ExceptionTransform(const string& type) :
+ _type(type)
+ {
+ }
+
+ virtual void
+ transform(::IceUtil::XMLOutput&, const DocumentInfoPtr&, const string&, DOMNode*)
+ {
+ throw SchemaViolation(__FILE__, __LINE__);
+ }
+
+ virtual ostream&
+ print(ostream& os)
+ {
+ os << "[exception transform: " << _type << "]\n";
+ return os;
+ }
+
+private:
+
+ string _type;
+};
+
typedef ::IceUtil::Handle<NilTransform> NilTransformPtr;
//
@@ -1128,7 +1160,7 @@ private:
void load(DocumentMap&, const string&, const Ice::StringSeq&);
//
- // Schema import handling.
+ // Schema import/include handling.
//
void import(DocumentMap&, const string&, const string&, const Ice::StringSeq&);
void processImport(DOMDocument*, DocumentMap&, const Ice::StringSeq&);
@@ -1337,7 +1369,7 @@ XMLTransform::TransformFactory::create(DOMDocument* fromDoc, DOMDocument* toDoc,
_toDocs.insert(make_pair(toInfo->getTargetNamespace(), toInfo));
//
- // Process the import declarations for the source schema documents.
+ // Process the import/include declarations for the source schema documents.
//
processImport(fromDoc, _fromDocs, pathFrom);
processImport(toDoc, _toDocs, pathTo);
@@ -1523,7 +1555,7 @@ XMLTransform::TransformFactory::import(DocumentMap& documents, const string& ns,
documents.insert(make_pair(info->getTargetNamespace(), info));
//
- // Process any imports in the imported document.
+ // Process any imports or includes in the imported document.
//
processImport(document, documents, paths);
}
@@ -1545,6 +1577,12 @@ XMLTransform::TransformFactory::processImport(DOMDocument* parent, DocumentMap&
import(documents, ns, loc, paths);
}
+ else if(nodeName == includeElementName)
+ {
+ string loc = getAttributeByName(child, "schemaLocation");
+
+ import(documents, "", loc, paths);
+ }
child = child->getNextSibling();
}
}
@@ -2009,13 +2047,10 @@ XMLTransform::TransformFactory::createTransform(const DocumentInfoPtr& fromTypeI
case TypeException:
{
- //
- // TODO: BENOIT: Is this correct? We can't throw an IllegalTransform here because it's possible
- // that the schema have exception elements, even if these elements don't take part in any
- // transformations. Maybe we could return a null transformation here since this transformation
- // will never be used anyway.
- //
- transform = new NilTransform();
+ //
+ // Return a transform which should never be invoked.
+ //
+ transform = new ExceptionTransform(fromTypeName);
break;
}