source: icXML/icXML-devel/src/xercesc/framework/psvi/XSAttributeDeclaration.cpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 4.1 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: XSAttributeDeclaration.cpp 471747 2006-11-06 14:31:56Z amassari $
20 */
21
22#include <xercesc/framework/psvi/XSAttributeDeclaration.hpp>
23#include <xercesc/framework/psvi/XSModel.hpp>
24#include <xercesc/framework/psvi/XSNamespaceItem.hpp>
25#include <xercesc/framework/psvi/XSAnnotation.hpp>
26#include <xercesc/util/StringPool.hpp>
27#include <xercesc/validators/schema/SchemaGrammar.hpp>
28#include <xercesc/validators/schema/SchemaAttDef.hpp>
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32// ---------------------------------------------------------------------------
33//  XSAttributeDeclaration: Constructors and Destructor
34// ---------------------------------------------------------------------------
35XSAttributeDeclaration::XSAttributeDeclaration(SchemaAttDef* const           attDef,
36                                               XSSimpleTypeDefinition* const typeDef,
37                                               XSAnnotation* const           annot,
38                                               XSModel* const                xsModel,
39                                               XSConstants::SCOPE            scope,
40                                               XSComplexTypeDefinition*      enclosingCTDefinition,
41                                               MemoryManager * const         manager)
42    : XSObject(XSConstants::ATTRIBUTE_DECLARATION, xsModel, manager)
43    , fAttDef(attDef)
44    , fTypeDefinition(typeDef)
45    , fAnnotation(annot) 
46    , fScope(scope)
47    , fEnclosingCTDefinition(enclosingCTDefinition)       
48{
49}
50
51XSAttributeDeclaration::~XSAttributeDeclaration() 
52{
53    // don't delete fTypeDefinition - deleted by XSModel
54}
55
56// ---------------------------------------------------------------------------
57//  XSAttributeDeclaration: XSObject virtual methods
58// ---------------------------------------------------------------------------
59const XMLCh *XSAttributeDeclaration::getName() const
60{
61    return fAttDef->getAttName()->getLocalPart();
62}
63
64const XMLCh *XSAttributeDeclaration::getNamespace() 
65{
66    return fXSModel->getURIStringPool()->getValueForId(fAttDef->getAttName()->getURI());
67}
68
69XSNamespaceItem *XSAttributeDeclaration::getNamespaceItem() 
70{
71    return fXSModel->getNamespaceItem(getNamespace());
72}
73
74// ---------------------------------------------------------------------------
75//  XSAttributeDeclaration: access methods
76// ---------------------------------------------------------------------------
77
78XSConstants::VALUE_CONSTRAINT XSAttributeDeclaration::getConstraintType() const
79{
80    if (fScope != XSConstants::SCOPE_GLOBAL)
81        return XSConstants::VALUE_CONSTRAINT_NONE;
82
83    if (fAttDef->getDefaultType() == XMLAttDef::Default)
84        return XSConstants::VALUE_CONSTRAINT_DEFAULT;
85
86    if ((fAttDef->getDefaultType() == XMLAttDef::Fixed) ||
87        (fAttDef->getDefaultType() == XMLAttDef::Required_And_Fixed))
88        return XSConstants::VALUE_CONSTRAINT_FIXED;
89
90    return XSConstants::VALUE_CONSTRAINT_NONE;
91}
92
93const XMLCh *XSAttributeDeclaration::getConstraintValue()
94{
95    if (fScope == XSConstants::SCOPE_GLOBAL)
96        return fAttDef->getValue();
97
98    return 0;
99}
100
101bool XSAttributeDeclaration::getRequired() const
102{
103    if (fAttDef->getDefaultType() == XMLAttDef::Required ||
104        fAttDef->getDefaultType() == XMLAttDef::Required_And_Fixed)
105        return true;
106
107    return false;
108}
109
110XERCES_CPP_NAMESPACE_END
111
112
Note: See TracBrowser for help on using the repository browser.