You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2005/08/02 21:12:44 UTC
svn commit: r227067 - in /xerces/c/trunk:
samples/src/PSVIWriter/PSVIWriterHandlers.cpp
src/xercesc/dom/DOMTypeInfo.hpp src/xercesc/dom/impl/DOMTypeInfoImpl.cpp
src/xercesc/dom/impl/DOMTypeInfoImpl.hpp tests/src/DOM/TypeInfo/TypeInfo.cpp
Author: amassari
Date: Tue Aug 2 12:11:12 2005
New Revision: 227067
URL: http://svn.apache.org/viewcvs?rev=227067&view=rev
Log:
DOM Level 3 Core: DOMTypeInfo
Modified:
xerces/c/trunk/samples/src/PSVIWriter/PSVIWriterHandlers.cpp
xerces/c/trunk/src/xercesc/dom/DOMTypeInfo.hpp
xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.cpp
xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.hpp
xerces/c/trunk/tests/src/DOM/TypeInfo/TypeInfo.cpp
Modified: xerces/c/trunk/samples/src/PSVIWriter/PSVIWriterHandlers.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/samples/src/PSVIWriter/PSVIWriterHandlers.cpp?rev=227067&r1=227066&r2=227067&view=diff
==============================================================================
--- xerces/c/trunk/samples/src/PSVIWriter/PSVIWriterHandlers.cpp (original)
+++ xerces/c/trunk/samples/src/PSVIWriter/PSVIWriterHandlers.cpp Tue Aug 2 12:11:12 2005
@@ -928,7 +928,7 @@
sendElementValue(PSVIUni::fgPrefix, attr->getPrefix());
sendElementValue(PSVIUni::fgNormalizedValue, attr->getValue());
sendElementValue(PSVIUni::fgSpecified, translateBool(attr->getSpecified()));
- sendElementValue(PSVIUni::fgAttributeType, attr->getTypeInfo()->getName());
+ sendElementValue(PSVIUni::fgAttributeType, attr->getTypeInfo()->getTypeName());
sendElementEmpty(PSVIUni::fgReferences);
sendUnindentedElement(PSVIUni::fgAttribute);
}
@@ -951,7 +951,7 @@
sendElementValue(PSVIUni::fgPrefix, attr->getPrefix());
sendElementValue(PSVIUni::fgNormalizedValue, attr->getValue());
sendElementValue(PSVIUni::fgSpecified, translateBool(attr->getSpecified()));
- sendElementValue(PSVIUni::fgAttributeType, attr->getTypeInfo()->getName());
+ sendElementValue(PSVIUni::fgAttributeType, attr->getTypeInfo()->getTypeName());
sendElementEmpty(PSVIUni::fgReferences);
sendUnindentedElement(PSVIUni::fgAttribute);
}
Modified: xerces/c/trunk/src/xercesc/dom/DOMTypeInfo.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/dom/DOMTypeInfo.hpp?rev=227067&r1=227066&r2=227067&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/DOMTypeInfo.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/DOMTypeInfo.hpp Tue Aug 2 12:11:12 2005
@@ -66,35 +66,121 @@
virtual ~DOMTypeInfo() {};
//@}
+ // -----------------------------------------------------------------------
+ // Class Types
+ // -----------------------------------------------------------------------
+ /** @name Public Contants */
+ //@{
+ /**
+ * These are the available values for the derivationMethod parameter used by the
+ * method <code>DOMTypeInfo::isDerivedFrom()</code>. It is a set of possible types
+ * of derivation, and the values represent bit positions. If a bit in the derivationMethod
+ * parameter is set to 1, the corresponding type of derivation will be taken into account
+ * when evaluating the derivation between the reference type definition and the other type
+ * definition. When using the isDerivedFrom method, combining all of them in the
+ * derivationMethod parameter is equivalent to invoking the method for each of them separately
+ * and combining the results with the OR boolean function. This specification only defines
+ * the type of derivation for XML Schema.
+ *
+ * In addition to the types of derivation listed below, please note that:
+ * - any type derives from xsd:anyType.
+ * - any simple type derives from xsd:anySimpleType by restriction.
+ * - any complex type does not derive from xsd:anySimpleType by restriction.
+ *
+ * <p><code>DERIVATION_EXTENSION:</code>
+ * If the document's schema is an XML Schema [XML Schema Part 1], this constant represents the
+ * derivation by extension. The reference type definition is derived by extension from the other
+ * type definition if the other type definition can be reached recursively following the
+ * {base type definition} property from the reference type definition, and at least one of the
+ * derivation methods involved is an extension.</p>
+ *
+ * <p><code>DERIVATION_LIST:</code>
+ * If the document's schema is an XML Schema [XML Schema Part 1], this constant represents the list.
+ * The reference type definition is derived by list from the other type definition if there exists
+ * two type definitions T1 and T2 such as the reference type definition is derived from T1 by
+ * DERIVATION_RESTRICTION or DERIVATION_EXTENSION, T2 is derived from the other type definition by
+ * DERIVATION_RESTRICTION, T1 has {variety} list, and T2 is the {item type definition}. Note that
+ * T1 could be the same as the reference type definition, and T2 could be the same as the other
+ * type definition.</p>
+ *
+ * <p><code>DERIVATION_RESTRICTION:</code>
+ * If the document's schema is an XML Schema [XML Schema Part 1], this constant represents the
+ * derivation by restriction if complex types are involved, or a restriction if simple types are
+ * involved.
+ * The reference type definition is derived by restriction from the other type definition if the
+ * other type definition is the same as the reference type definition, or if the other type definition
+ * can be reached recursively following the {base type definition} property from the reference type
+ * definition, and all the derivation methods involved are restriction.</p>
+ *
+ * <p><code>DERIVATION_UNION:</code>
+ * If the document's schema is an XML Schema [XML Schema Part 1], this constant represents the union
+ * if simple types are involved.
+ * The reference type definition is derived by union from the other type definition if there exists
+ * two type definitions T1 and T2 such as the reference type definition is derived from T1 by
+ * DERIVATION_RESTRICTION or DERIVATION_EXTENSION, T2 is derived from the other type definition by
+ * DERIVATION_RESTRICTION, T1 has {variety} union, and one of the {member type definitions} is T2.
+ * Note that T1 could be the same as the reference type definition, and T2 could be the same as the
+ * other type definition.</p>
+ *
+ * @since DOM Level 3
+ *
+ */
+ enum DerivationMethods {
+ DERIVATION_RESTRICTION = 0x001,
+ DERIVATION_EXTENSION = 0x002,
+ DERIVATION_UNION = 0x004,
+ DERIVATION_LIST = 0x008
+ };
+ //@}
+
//@{
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/**
* Returns The name of a type declared for the associated <code>DOMElement</code>
- * or <code>DOMAttr</code>, or null if undeclared.
- *
- * <p><b>"Experimental - subject to change"</b></p>
+ * or <code>DOMAttr</code>, or null if unknown.
*
* @return The name of a type declared for the associated <code>DOMElement</code>
- * or <code>DOMAttribute</code>, or null if undeclared.
+ * or <code>DOMAttribute</code>, or null if unknown.
* @since DOM level 3
*/
- virtual const XMLCh* getName() const = 0;
+ virtual const XMLCh* getTypeName() const = 0;
/**
* The namespace of the type declared for the associated <code>DOMElement</code>
* or <code>DOMAttr</code> or null if the <code>DOMElement</code> does not have
* declaration or if no namespace information is available.
*
- * <p><b>"Experimental - subject to change"</b></p>
- *
* @return The namespace of the type declared for the associated <code>DOMElement</code>
* or <code>DOMAttr</code> or null if the <code>DOMElement</code> does not have
* declaration or if no namespace information is available.
* @since DOM level 3
*/
- virtual const XMLCh* getNamespace() const = 0;
+ virtual const XMLCh* getTypeNamespace() const = 0;
+ //@}
+
+ //@{
+ /**
+ * This method returns if there is a derivation between the reference type definition,
+ * i.e. the DOMTypeInfo on which the method is being called, and the other type definition,
+ * i.e. the one passed as parameters.
+ *
+ * @param typeNamespaceArg The namespace of the other type definition.
+ * @param typeNameArg The name of the other type definition.
+ * @param derivationMethod The type of derivation and conditions applied between two types,
+ * as described in the list of constants provided in this interface.
+ * @return If the document's schema is a DTD or no schema is associated with the document,
+ * this method will always return false.
+ * If the document's schema is an XML Schema, the method will true if the reference
+ * type definition is derived from the other type definition according to the derivation
+ * parameter. If the value of the parameter is 0 (no bit is set to 1 for the
+ * derivationMethod parameter), the method will return true if the other type definition
+ * can be reached by recursing any combination of {base type definition},
+ * {item type definition}, or {member type definitions} from the reference type definition.
+ * @since DOM level 3
+ */
+ virtual bool isDerivedFrom(const XMLCh* typeNamespaceArg, const XMLCh* typeNameArg, unsigned long derivationMethod) const = 0;
//@}
};
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.cpp?rev=227067&r1=227066&r2=227067&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.cpp Tue Aug 2 12:11:12 2005
@@ -49,7 +49,7 @@
// - [schema specified]=false
}
-const XMLCh* DOMTypeInfoImpl::getName() const {
+const XMLCh* DOMTypeInfoImpl::getTypeName() const {
// if it's a DTD, return the data that was stored
if(!getNumericProperty(PSVI_Schema_Specified))
return fTypeName;
@@ -61,7 +61,7 @@
return fTypeName;
}
-const XMLCh* DOMTypeInfoImpl::getNamespace() const {
+const XMLCh* DOMTypeInfoImpl::getTypeNamespace() const {
// if it's a DTD, return the data that was stored
if(!getNumericProperty(PSVI_Schema_Specified))
return fTypeNamespace;
@@ -71,6 +71,17 @@
if(fMemberTypeName) // we check on the name, as the URI can be NULL
return fMemberTypeNamespace;
return fTypeNamespace;
+}
+
+bool DOMTypeInfoImpl::isDerivedFrom(const XMLCh* typeNamespaceArg, const XMLCh* typeNameArg, unsigned long derivationMethod) const
+{
+ // if it's a DTD, return false
+ if(!getNumericProperty(PSVI_Schema_Specified))
+ return false;
+ if(XMLString::equals(typeNamespaceArg, getTypeNamespace()) && XMLString::equals(typeNameArg, getTypeName()))
+ return true;
+ // TODO: need a pointer to the Grammar object
+ return false;
}
const XMLCh* DOMTypeInfoImpl::getStringProperty(PSVIProperty prop) const {
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.hpp?rev=227067&r1=227066&r2=227067&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMTypeInfoImpl.hpp Tue Aug 2 12:11:12 2005
@@ -59,82 +59,26 @@
static DOMTypeInfoImpl g_DtdValidatedNOTATIONAttribute;
static DOMTypeInfoImpl g_DtdValidatedENUMERATIONAttribute;
- //@{
// -----------------------------------------------------------------------
- // Getter methods
+ // DOMTypeInfo interface
// -----------------------------------------------------------------------
- /**
- * Returns The name of a type declared for the associated <code>DOMElement</code>
- * or <code>DOMAttr</code>, or null if undeclared.
- *
- * <p><b>"Experimental - subject to change"</b></p>
- *
- * @return The name of a type declared for the associated <code>DOMElement</code>
- * or <code>DOMAttribute</code>, or null if undeclared.
- * @since DOM level 3
- */
- virtual const XMLCh* getName() const;
+ virtual const XMLCh* getTypeName() const;
+ virtual const XMLCh* getTypeNamespace() const;
+ virtual bool isDerivedFrom(const XMLCh* typeNamespaceArg, const XMLCh* typeNameArg, unsigned long derivationMethod) const;
- /**
- * The namespace of the type declared for the associated <code>DOMElement</code>
- * or <code>DOMAttr</code> or null if the <code>DOMElement</code> does not have
- * declaration or if no namespace information is available.
- *
- * <p><b>"Experimental - subject to change"</b></p>
- *
- * @return The namespace of the type declared for the associated <code>DOMElement</code>
- * or <code>DOMAttr</code> or null if the <code>DOMElement</code> does not have
- * declaration or if no namespace information is available.
- * @since DOM level 3
- */
- virtual const XMLCh* getNamespace() const;
-
- /**
- * Returns the string value of the specified PSVI property associated to a
- * <code>DOMElement</code> or <code>DOMAttr</code>, or null if not available.
- *
- * <p><b>"Experimental - subject to change"</b></p>
- *
- * @return the string value of the specified PSVI property associated to a
- * <code>DOMElement</code> or <code>DOMAttr</code>, or null if not available.
- */
+ // -----------------------------------------------------------------------
+ // DOMPSVITypeInfo interface
+ // -----------------------------------------------------------------------
virtual const XMLCh* getStringProperty(PSVIProperty prop) const;
-
- /**
- * Returns the numeric value of the specified PSVI property associated to a
- * <code>DOMElement</code> or <code>DOMAttr</code>, or 0 if not available.
- *
- * <p><b>"Experimental - subject to change"</b></p>
- *
- * @return the numeric value of the specified PSVI property associated to a
- * <code>DOMElement</code> or <code>DOMAttr</code>, or 0 if not available.
- */
virtual int getNumericProperty(PSVIProperty prop) const;
- //@}
- //@{
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
-
- /**
- * Set the value for a string PSVI property.
- *
- * <p><b>"Experimental - subject to change"</b></p>
- *
- */
virtual void setStringProperty(PSVIProperty prop, const XMLCh* value);
-
- /**
- * Set the value for a numeric PSVI property.
- *
- * <p><b>"Experimental - subject to change"</b></p>
- *
- */
virtual void setNumericProperty(PSVIProperty prop, int value);
- //@}
- private:
+private:
int fBitFields;
const XMLCh* fTypeName;
const XMLCh* fTypeNamespace;
Modified: xerces/c/trunk/tests/src/DOM/TypeInfo/TypeInfo.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/tests/src/DOM/TypeInfo/TypeInfo.cpp?rev=227067&r1=227066&r2=227067&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/DOM/TypeInfo/TypeInfo.cpp (original)
+++ xerces/c/trunk/tests/src/DOM/TypeInfo/TypeInfo.cpp Tue Aug 2 12:11:12 2005
@@ -32,17 +32,17 @@
#define DOMTYPEINFOTEST(info, type, uri, line) \
- tmp = XMLString::equals(info->getName(), type) && XMLString::equals(info->getNamespace(), uri);\
+ tmp = XMLString::equals(info->getTypeName(), type) && XMLString::equals(info->getTypeNamespace(), uri);\
if(!tmp) { \
XERCES_STD_QUALIFIER cerr << "DOMTypeInfo test failed at line, " << line << "\nExpected values : typename '" << XMLString::transcode((XMLCh*)type) << "', uri '" << XMLString::transcode((XMLCh*)uri); \
XERCES_STD_QUALIFIER cerr << "'\nActual values : typename '"; \
- if(info->getName()) \
- XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getName()); \
+ if(info->getTypeName()) \
+ XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getTypeName()); \
else \
XERCES_STD_QUALIFIER cerr << "(null)"; \
XERCES_STD_QUALIFIER cerr << "', uri '"; \
- if(info->getNamespace()) \
- XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getNamespace()); \
+ if(info->getTypeNamespace()) \
+ XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getTypeNamespace()); \
else \
XERCES_STD_QUALIFIER cerr << "(null)"; \
XERCES_STD_QUALIFIER cerr << "'\n" << XERCES_STD_QUALIFIER endl; \
@@ -720,7 +720,7 @@
bool TypeInfo::compareDOMTypeInfo(const DOMTypeInfo *info, const XMLCh* type, const XMLCh* uri) {
- return XMLString::equals(info->getName(), type) && XMLString::equals(info->getNamespace(), uri);
+ return XMLString::equals(info->getTypeName(), type) && XMLString::equals(info->getTypeNamespace(), uri);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org