1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 #include "ElemForwardCompatible.hpp"
19
20
21
22 #include <cassert>
23
24
25
26 #include <xercesc/sax/AttributeList.hpp>
27
28
29
30 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
31 #include <xalanc/PlatformSupport/XalanMessageLoader.hpp>
32
33
34
35 #include "Constants.hpp"
36 #include "StylesheetConstructionContext.hpp"
37 #include "StylesheetExecutionContext.hpp"
38
39
40
41 namespace XALAN_CPP_NAMESPACE {
42
43
44
ElemForwardCompatible(StylesheetConstructionContext & constructionContext,Stylesheet & stylesheetTree,const XalanDOMChar * name,const AttributeListType & atts,XalanFileLoc lineNumber,XalanFileLoc columnNumber)45 ElemForwardCompatible::ElemForwardCompatible(
46 StylesheetConstructionContext& constructionContext,
47 Stylesheet& stylesheetTree,
48 const XalanDOMChar* name,
49 const AttributeListType& atts,
50 XalanFileLoc lineNumber,
51 XalanFileLoc columnNumber) :
52 ElemTemplateElement(
53 constructionContext,
54 stylesheetTree,
55 lineNumber,
56 columnNumber,
57 StylesheetConstructionContext::ELEMNAME_FORWARD_COMPATIBLE),
58 m_elementName(constructionContext.getPooledString(name))
59 {
60 const XalanSize_t nAttrs = atts.getLength();
61
62 for (XalanSize_t i = 0; i < nAttrs; i++)
63 {
64 const XalanDOMChar* const aname = atts.getName(i);
65
66 if (isAttrOK(
67 aname,
68 atts,
69 i,
70 constructionContext) == false &&
71 processSpaceAttr(
72 m_elementName.c_str(),
73 aname,
74 atts,
75 i,
76 constructionContext) == false)
77 {
78 error(
79 constructionContext,
80 XalanMessages::ElementHasIllegalAttribute_2Param,
81 m_elementName.c_str(),
82 aname);
83 }
84 }
85 }
86
87
88
89 ElemForwardCompatible*
create(MemoryManager & theManager,StylesheetConstructionContext & constructionContext,Stylesheet & stylesheetTree,const XalanDOMChar * name,const AttributeListType & atts,XalanFileLoc lineNumber,XalanFileLoc columnNumber)90 ElemForwardCompatible::create(
91 MemoryManager& theManager,
92 StylesheetConstructionContext& constructionContext,
93 Stylesheet& stylesheetTree,
94 const XalanDOMChar* name,
95 const AttributeListType& atts,
96 XalanFileLoc lineNumber,
97 XalanFileLoc columnNumber)
98 {
99 typedef ElemForwardCompatible ThisType;
100
101 XalanAllocationGuard theGuard(theManager, theManager.allocate(sizeof(ThisType)));
102
103 ThisType* const theResult =
104 new (theGuard.get()) ThisType(
105 constructionContext,
106 stylesheetTree,
107 name,
108 atts,
109 lineNumber,
110 columnNumber);
111
112 theGuard.release();
113
114 return theResult;
115 }
116
117
118
119 const XalanDOMString&
getElementName() const120 ElemForwardCompatible::getElementName() const
121 {
122 return m_elementName;
123 }
124
125
126
~ElemForwardCompatible()127 ElemForwardCompatible::~ElemForwardCompatible()
128 {
129 }
130
131
132 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
133 const ElemTemplateElement*
startElement(StylesheetExecutionContext & executionContext) const134 ElemForwardCompatible::startElement(StylesheetExecutionContext& executionContext) const
135 {
136 return getFirstChildElemToExecute(executionContext);
137
138 }
139
140
141
142 bool
executeChildElement(StylesheetExecutionContext &,const ElemTemplateElement * element) const143 ElemForwardCompatible::executeChildElement(
144 StylesheetExecutionContext& /*executionContext*/,
145 const ElemTemplateElement* element) const
146 {
147 return element->getXSLToken() == StylesheetConstructionContext::ELEMNAME_FALLBACK;
148 }
149 #endif
150
151
152
153 #if defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
154 void
execute(StylesheetExecutionContext & executionContext) const155 ElemForwardCompatible::execute(StylesheetExecutionContext& executionContext) const
156 {
157 ElemTemplateElement::execute(executionContext);
158
159 for (const ElemTemplateElement* child = getFirstChildElem(); child != 0; child = child->getNextSiblingElem())
160 {
161 if(child->getXSLToken() == StylesheetConstructionContext::ELEMNAME_FALLBACK)
162 {
163 child->execute(executionContext);
164 }
165 }
166 }
167 #endif
168
169
170
171 }
172