diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-08-27 18:45:04 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-08-27 18:45:04 +0000 |
commit | 3b32844a0dc964db8b8fc1461d7b0ba9fda3acc0 (patch) | |
tree | b19a4327999825ef69305aaba8d914a6e1289d58 /cpp/include/XMLTransform/XMLTransform.h | |
parent | Added slice dependencies. (diff) | |
download | ice-3b32844a0dc964db8b8fc1461d7b0ba9fda3acc0.tar.bz2 ice-3b32844a0dc964db8b8fc1461d7b0ba9fda3acc0.tar.xz ice-3b32844a0dc964db8b8fc1461d7b0ba9fda3acc0.zip |
initial check-in
Diffstat (limited to 'cpp/include/XMLTransform/XMLTransform.h')
-rw-r--r-- | cpp/include/XMLTransform/XMLTransform.h | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/cpp/include/XMLTransform/XMLTransform.h b/cpp/include/XMLTransform/XMLTransform.h new file mode 100644 index 00000000000..7df034e7249 --- /dev/null +++ b/cpp/include/XMLTransform/XMLTransform.h @@ -0,0 +1,207 @@ +// ********************************************************************** +// +// Copyright (c) 2002 +// Mutable Realms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#ifndef XML_TRANSFORM_H +#define XML_TRANSFORM_H + +#include <Freeze/DB.h> +#include <IceUtil/OutputUtil.h> + +#include <dom/DOM.hpp> + +#ifdef WIN32 +# ifdef XML_TRANSFORM_API_EXPORTS +# define XML_TRANSFORM_API __declspec(dllexport) +# else +# define XML_TRANSFORM_API __declspec(dllimport) +# endif +#else +# define XML_TRANSFORM_API /**/ +#endif + +namespace XMLTransform +{ + +// +// Raised in the case that the transform is illegal. +// +class XML_TRANSFORM_API IllegalTransform : public ::IceUtil::Exception +{ +public: + + IllegalTransform(const char*, int); + + virtual ::std::string ice_name() const; + virtual void ice_print(::std::ostream&) const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + ::std::string reason; +}; + +// +// Raised in the case that the given schema is incompatible with the old schema. +// +class XML_TRANSFORM_API IncompatibleSchema : public ::IceUtil::Exception +{ +public: + + IncompatibleSchema(const char*, int); + + virtual ::std::string ice_name() const; + virtual void ice_print(::std::ostream&) const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + ::std::string reason; +}; + +// +// Raised in the case that the given schema is not an XML schema. +// +class XML_TRANSFORM_API InvalidSchema : public ::IceUtil::Exception +{ +public: + + InvalidSchema(const char*, int); + + virtual ::std::string ice_name() const; + virtual void ice_print(::std::ostream&) const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + ::std::string reason; +}; + +// +// Raised in the case that the given XML instance document violates the associated schema. +// +class XML_TRANSFORM_API SchemaViolation : public ::IceUtil::Exception +{ +public: + + SchemaViolation(const char*, int); + + virtual ::std::string ice_name() const; + virtual void ice_print(::std::ostream&) const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + ::std::string reason; +}; + +// +// Raised in the case of a general transformation failure. +// +class XML_TRANSFORM_API TransformException : public ::IceUtil::Exception +{ +public: + + TransformException(const char*, int); + + virtual ::std::string ice_name() const; + virtual void ice_print(::std::ostream&) const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + ::std::string reason; +}; + +// +// Map from namespace prefix to namespace URI. +// +typedef ::std::map< ::std::string, ::std::string> PrefixURIMap; + +// +// This represents the information associated with an XML document. Note that the namespace information is +// only retrieved from the top-level node (which matches the layout of XML schema documents). +// +class XML_TRANSFORM_API DocumentInfo : public ::IceUtil::Shared +{ +public: + + DocumentInfo(const DOM_Document& document, const DOM_Node& root, const ::std::string& targetNamespace = ""); + + DOM_Document getDocument() const; + ::std::string findURI(const ::std::string& prefix) const; + ::std::string getTargetNamespace() const; + +private: + + DOM_Document _document; + PrefixURIMap _nsMap; + ::std::string _targetNamespace; +}; + +typedef ::IceUtil::Handle<DocumentInfo> DocumentInfoPtr; + +// +// Transform interface. +// +class XML_TRANSFORM_API Transform : public ::IceUtil::Shared +{ +public: + + Transform(); + virtual ~Transform(); + + virtual void transform(::IceUtil::XMLOutput&, const DocumentInfoPtr&, const ::std::string&, const DOM_Node&) = 0; + virtual ::std::ostream& print(::std::ostream&) = 0; +}; + +typedef ::IceUtil::Handle<Transform> TransformPtr; + +// +// Map of string to transform type. +// +typedef ::std::map< ::std::string, TransformPtr> TransformMap; + +// +// Given an old and new XML schema, this class will transform an instance document that corresponds to the old +// schema formation into a document that matches the new schema. +// +class XML_TRANSFORM_API Transformer +{ +public: + + Transformer(const Ice::StringSeq&, const DOM_Document&, const DOM_Document&); + ~Transformer(); + + void transform(::IceUtil::XMLOutput&, const DOM_Document&, bool = true); + +private: + + // + // Map of local@uri element names to transforms. Needed for actual + // transform. + // + TransformMap _elements; + + // + // Map of local@uri class transforms (based on static type). This + // information cached for creation of the transform. + // + TransformMap _staticClassTransforms; +}; + +class XML_TRANSFORM_API DBTransformer +{ +public: + + DBTransformer(); + ~DBTransformer(); + + void transform(const Freeze::DBEnvironmentPtr&, const Freeze::DBPtr&, const Ice::StringSeq&, const std::string&, + const std::string&); +}; + +} // End namespace XMLTransform + +#endif |