|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __XMLVALID_H__ |
|
17 #define __XMLVALID_H__ |
|
18 |
|
19 // System includes |
|
20 // |
|
21 #include <e32base.h> |
|
22 #include <cstack.h> |
|
23 |
|
24 // Forward class declarations |
|
25 // |
|
26 class CAttributeLookupTable; |
|
27 class CBNFNode; |
|
28 class CXmlElement; |
|
29 |
|
30 // CLASS DEFINITION |
|
31 // |
|
32 //##ModelId=3B6679A20284 |
|
33 class CXmlValidator : public CBase |
|
34 { |
|
35 protected: // Data types |
|
36 enum TDTDNodeMatch |
|
37 { |
|
38 EMiss, |
|
39 EConditionalMiss, |
|
40 EMatch |
|
41 }; |
|
42 |
|
43 typedef CStack<CBNFNode, EFalse> CDTDNodeStack; |
|
44 typedef CStack<CXmlElement, EFalse> CChildMarkStack; |
|
45 |
|
46 public: // Methods |
|
47 //##ModelId=3B6679A300A6 |
|
48 static CXmlValidator* NewL(CBNFNode& aDTD, CAttributeLookupTable& aALUT); |
|
49 //##ModelId=3B6679A300A5 |
|
50 virtual ~CXmlValidator(); |
|
51 //##ModelId=3B6679A30091 |
|
52 TInt ValidateTreeL(CXmlElement* aRootNode); |
|
53 |
|
54 protected: // Methods |
|
55 //##ModelId=3B6679A3007D |
|
56 CXmlValidator(CBNFNode& aDTD, CAttributeLookupTable& aALUT); |
|
57 //##ModelId=3B6679A30072 |
|
58 void ConstructL(); |
|
59 |
|
60 //##ModelId=3B6679A3005E |
|
61 TInt ValidateNodeAttributesL(CXmlElement* aDocumentNode, CBNFNode* aDTDNode); |
|
62 //##ModelId=3B6679A3004A |
|
63 TInt ValidateNodeChildrenL(CXmlElement* aDocumentNode, CBNFNode* aDTDNode); |
|
64 //##ModelId=3B6679A30040 |
|
65 TInt ValidateNodeL(CXmlElement* aNode); |
|
66 //##ModelId=3B6679A30022 |
|
67 TInt NormalizeAndCheckAttributeValueL(TPtr& aAttributeValue, CBNFNode* aAttributeValueType); |
|
68 |
|
69 private: // Methods |
|
70 //##ModelId=3B6679A3000E |
|
71 TInt HandleReferenceL(CBNFNode* aDTDNode, TBool& aNodeFinished); |
|
72 //##ModelId=3B6679A203E2 |
|
73 TInt HandleAndL(CBNFNode* aDTDNode, TBool& aNodeFinished); |
|
74 //##ModelId=3B6679A203CE |
|
75 TInt HandleOrL(CBNFNode* aDTDNode, TBool& aNodeFinished); |
|
76 //##ModelId=3B6679A203BA |
|
77 TInt HandleOptionalL(CBNFNode* aDTDNode, TBool& aNodeFinished); |
|
78 //##ModelId=3B6679A2039C |
|
79 TInt HandleNMoreL(CBNFNode* aDTDNode, TBool& aNodeFinished); |
|
80 |
|
81 //##ModelId=3B6679A20388 |
|
82 TInt HandleReferenceInAttributeValueTypeL(CBNFNode* aDTDNode, TBool& aNodeFinished); |
|
83 //##ModelId=3B6679A20374 |
|
84 TInt HandleAttributeValueCheckAndNormalize(TPtr& aAttributeValue, const TDesC* aAttributeValueType); |
|
85 |
|
86 //##ModelId=3B6679A20360 |
|
87 const TDesC* NodeName(CBNFNode* aNode); |
|
88 //##ModelId=3B6679A20356 |
|
89 void NormalizeAttributeValueWhiteSpaces(TPtr& aAttributeValue); |
|
90 |
|
91 protected: // Attributes |
|
92 //##ModelId=3B6679A2034C |
|
93 CBNFNode& iDTD; |
|
94 //##ModelId=3B6679A20338 |
|
95 CAttributeLookupTable& iALUT; |
|
96 |
|
97 // These are pointers and variables for the validation DTD tree traversing |
|
98 // They are used to temporarily store pointers to data structures while traversing |
|
99 // the tree and hence, data is not owned by these! |
|
100 //##ModelId=3B6679A20324 |
|
101 CXmlElement* iCurrentDocumentChild; |
|
102 //##ModelId=3B6679A20310 |
|
103 CBNFNode* iDTDChildNode; |
|
104 //##ModelId=3B6679A202FE |
|
105 TBool iNodeMatched; |
|
106 //##ModelId=3B6679A202F4 |
|
107 TDTDNodeMatch iSubNodeMatch; |
|
108 //##ModelId=3B6679A202E0 |
|
109 CArrayFixFlat<TInt>* iCounterArray; // ...except for the counter stack, that owns the TInts |
|
110 //##ModelId=3B6679A202B8 |
|
111 CDTDNodeStack iDTDNodeStack; |
|
112 //##ModelId=3B6679A202AF |
|
113 CChildMarkStack iDocumentChildMarkStack; |
|
114 |
|
115 }; |
|
116 |
|
117 #endif // __XMLVALID_H__ |