src/xmlpatterns/schema/qxsdschemahelper_p.h
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 //
       
    43 //  W A R N I N G
       
    44 //  -------------
       
    45 //
       
    46 // This file is not part of the Qt API.  It exists purely as an
       
    47 // implementation detail.  This header file may change from version to
       
    48 // version without notice, or even be removed.
       
    49 //
       
    50 // We mean it.
       
    51 
       
    52 #ifndef Patternist_XsdSchemaHelper_H
       
    53 #define Patternist_XsdSchemaHelper_H
       
    54 
       
    55 #include "qcomparisonfactory_p.h"
       
    56 #include "qschematype_p.h"
       
    57 #include "qxsdattributegroup_p.h"
       
    58 #include "qxsdelement_p.h"
       
    59 #include "qxsdparticle_p.h"
       
    60 #include "qxsdschemacontext_p.h"
       
    61 #include "qxsdwildcard_p.h"
       
    62 
       
    63 QT_BEGIN_HEADER
       
    64 
       
    65 QT_BEGIN_NAMESPACE
       
    66 
       
    67 namespace QPatternist
       
    68 {
       
    69 
       
    70     /**
       
    71      * @short Contains helper methods that are used by XsdSchemaParser, XsdSchemaResolver and XsdSchemaChecker.
       
    72      *
       
    73      * @ingroup Patternist_schema
       
    74      * @author Tobias Koenig <tobias.koenig@nokia.com>
       
    75      */
       
    76     class XsdSchemaHelper
       
    77     {
       
    78         public:
       
    79             /**
       
    80              * Checks whether the given @p particle is emptiable as defined by the
       
    81              * algorithm in the schema spec.
       
    82              */
       
    83             static bool isParticleEmptiable(const XsdParticle::Ptr &particle);
       
    84 
       
    85             /**
       
    86              * Checks whether the given @p nameSpace is allowed by the given namespace @p constraint.
       
    87              */
       
    88             static bool wildcardAllowsNamespaceName(const QString &nameSpace,
       
    89                                                     const XsdWildcard::NamespaceConstraint::Ptr &constraint);
       
    90 
       
    91             /**
       
    92              * Checks whether the given @p name is allowed by the namespace constraint of the given @p wildcard.
       
    93              */
       
    94             static bool wildcardAllowsExpandedName(const QXmlName &name,
       
    95                                                    const XsdWildcard::Ptr &wildcard,
       
    96                                                    const NamePool::Ptr &namePool);
       
    97 
       
    98             /**
       
    99              * Checks whether the @p wildcard is a subset of @p otherWildcard.
       
   100              */
       
   101             static bool isWildcardSubset(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &otherWildcard);
       
   102 
       
   103             /**
       
   104              * Returns the union of the given @p wildcard and @p otherWildcard.
       
   105              */
       
   106             static XsdWildcard::Ptr wildcardUnion(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &otherWildcard);
       
   107 
       
   108             /**
       
   109              * Returns the intersection of the given @p wildcard and @p otherWildcard.
       
   110              */
       
   111             static XsdWildcard::Ptr wildcardIntersection(const XsdWildcard::Ptr &wildcard,
       
   112                                                          const XsdWildcard::Ptr &otherWildcard);
       
   113 
       
   114             /**
       
   115              * Returns whether the given @p type is validly substitutable for an @p otherType
       
   116              * under the given @p constraints.
       
   117              */
       
   118             static bool isValidlySubstitutable(const SchemaType::Ptr &type,
       
   119                                                const SchemaType::Ptr &otherType,
       
   120                                                const SchemaType::DerivationConstraints &constraints);
       
   121 
       
   122             /**
       
   123              * Returns whether the simple @p derivedType can be derived from the simple @p baseType
       
   124              * under the given @p constraints.
       
   125              */
       
   126             static bool isSimpleDerivationOk(const SchemaType::Ptr &derivedType,
       
   127                                              const SchemaType::Ptr &baseType,
       
   128                                              const SchemaType::DerivationConstraints &constraints);
       
   129 
       
   130             /**
       
   131              * Returns whether the complex @p derivedType can be derived from the complex @p baseType
       
   132              * under the given @p constraints.
       
   133              */
       
   134             static bool isComplexDerivationOk(const SchemaType::Ptr &derivedType,
       
   135                                               const SchemaType::Ptr &baseType,
       
   136                                               const SchemaType::DerivationConstraints &constraints);
       
   137 
       
   138             /**
       
   139              * This method takes the two string based operands @p operand1 and @p operand2 and converts them to instances of type @p type.
       
   140              * If the conversion fails, @c false is returned, otherwise the instances are compared by the given operator @p op and the
       
   141              * result of the comparison is returned.
       
   142              */
       
   143             static bool constructAndCompare(const DerivedString<TypeString>::Ptr &operand1,
       
   144                                             const AtomicComparator::Operator op,
       
   145                                             const DerivedString<TypeString>::Ptr &operand2,
       
   146                                             const SchemaType::Ptr &type,
       
   147                                             const ReportContext::Ptr &context,
       
   148                                             const SourceLocationReflection *const sourceLocationReflection);
       
   149 
       
   150             /**
       
   151              * Returns whether the process content property of the @p derivedWildcard is valid
       
   152              * according to the process content property of its @p baseWildcard.
       
   153              */
       
   154             static bool checkWildcardProcessContents(const XsdWildcard::Ptr &baseWildcard,
       
   155                                                      const XsdWildcard::Ptr &derivedWildcard);
       
   156 
       
   157             /**
       
   158              * Checks whether @[ member is a member of the substitution group with the given @p head.
       
   159              */
       
   160             static bool foundSubstitutionGroupTransitive(const XsdElement::Ptr &head,
       
   161                                                          const XsdElement::Ptr &member,
       
   162                                                          QSet<XsdElement::Ptr> &visitedElements);
       
   163 
       
   164             /**
       
   165              * A helper method that iterates over the type hierarchy from @p memberType up to @p headType and collects all
       
   166              * @p derivationSet and @p blockSet constraints that exists on the way there.
       
   167              */
       
   168             static void foundSubstitutionGroupTypeInheritance(const SchemaType::Ptr &headType,
       
   169                                                               const SchemaType::Ptr &memberType,
       
   170                                                               QSet<SchemaType::DerivationMethod> &derivationSet,
       
   171                                                               NamedSchemaComponent::BlockingConstraints &blockSet);
       
   172 
       
   173             /**
       
   174              * Checks if the @p member is transitive to @p head.
       
   175              */
       
   176             static bool substitutionGroupOkTransitive(const XsdElement::Ptr &head,
       
   177                                                       const XsdElement::Ptr &member,
       
   178                                                       const NamePool::Ptr &namePool);
       
   179 
       
   180             /**
       
   181              * Checks if @p derivedAttributeGroup is a valid restriction for @p attributeGroup.
       
   182              */
       
   183             static bool isValidAttributeGroupRestriction(const XsdAttributeGroup::Ptr &derivedAttributeGroup,
       
   184                                                          const XsdAttributeGroup::Ptr &attributeGroup,
       
   185                                                          const XsdSchemaContext::Ptr &context,
       
   186                                                          QString &errorMsg);
       
   187 
       
   188             /**
       
   189              * Checks if @p derivedAttributeUses are a valid restriction for @p attributeUses.
       
   190              */
       
   191             static bool isValidAttributeUsesRestriction(const XsdAttributeUse::List &derivedAttributeUses,
       
   192                                                         const XsdAttributeUse::List &attributeUses,
       
   193                                                         const XsdWildcard::Ptr &derivedWildcard,
       
   194                                                         const XsdWildcard::Ptr &wildcard,
       
   195                                                         const XsdSchemaContext::Ptr &context,
       
   196                                                         QString &errorMsg);
       
   197 
       
   198             /**
       
   199              * Checks if @p derivedAttributeUses are a valid extension for @p attributeUses.
       
   200              */
       
   201             static bool isValidAttributeUsesExtension(const XsdAttributeUse::List &derivedAttributeUses,
       
   202                                                       const XsdAttributeUse::List &attributeUses,
       
   203                                                       const XsdWildcard::Ptr &derivedWildcard,
       
   204                                                       const XsdWildcard::Ptr &wildcard,
       
   205                                                       const XsdSchemaContext::Ptr &context,
       
   206                                                       QString &errorMsg);
       
   207 
       
   208         private:
       
   209             Q_DISABLE_COPY(XsdSchemaHelper)
       
   210     };
       
   211 }
       
   212 
       
   213 QT_END_NAMESPACE
       
   214 
       
   215 QT_END_HEADER
       
   216 
       
   217 #endif