Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

ElemTemplateElement.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD)
17 #define XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
28 
29 
30 
34 
35 
36 
38 
39 
40 
42 
43 
44 
45 #include "LocalMsgIndex.hpp"
46 
47 
48 
49 XALAN_DECLARE_XERCES_CLASS(AttributeList)
50 XALAN_DECLARE_XERCES_CLASS(Locator)
51 
52 
53 
54 XALAN_CPP_NAMESPACE_BEGIN
55 
56 
57 
58 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType;
59 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType;
60 
61 
62 XALAN_USING_XERCES(AttributeList)
63 XALAN_USING_XERCES(Locator)
64 class ElemTemplate;
65 class ElemTextLiteral;
66 class NamespacesHandler;
67 class Stylesheet;
70 class XPath;
71 
72 
73 
75 {
76 
77 public:
78 
90  StylesheetConstructionContext& constructionContext,
91  Stylesheet& stylesheetTree,
92  int lineNumber,
93  int columnNumber,
94  int xslToken);
95 
109  StylesheetConstructionContext& constructionContext,
110  Stylesheet& stylesheetTree,
111  int xslToken,
113  int lineNumber = XalanLocator::getUnknownValue(),
114  int columnNumber = XalanLocator::getUnknownValue());
115 
116  virtual
118 
124  virtual const LocatorType*
125  getLocator() const;
126 
137  virtual bool
138  isAttrOK(
139  const XalanDOMChar* attrName,
140  const AttributeListType& atts,
141  int which,
142  StylesheetConstructionContext& constructionContext) const;
143 
154  bool
155  processSpaceAttr(
156  const XalanDOMChar* elementName,
157  const XalanDOMChar* aname,
158  const AttributeListType& atts,
159  int which,
160  StylesheetConstructionContext& constructionContext);
161 
169  static bool
170  isValidNCName(const XalanDOMString& s);
171 
172 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
173 
181  virtual const ElemTemplateElement*
182  startElement(StylesheetExecutionContext& executionContext) const;
183 
191  virtual void
192  endElement(StylesheetExecutionContext& executionContext) const;
193 
199  virtual void
200  execute(StylesheetExecutionContext& executionContext) const;
201 
207  virtual void
208  executeChildren(StylesheetExecutionContext& executionContext) const;
209 
214  virtual const ElemTemplateElement*
215  getInvoker(StylesheetExecutionContext& executionContext) const;
216 
217 #else
218 
225  virtual void
226  execute(StylesheetExecutionContext& executionContext) const;
227 
233  virtual void
234  executeChildren(StylesheetExecutionContext& executionContext) const;
235 
242  virtual void
243  executeChildren(
244  StylesheetExecutionContext& executionContext,
245  XalanNode* sourceNode) const;
246 
258  const XalanDOMString&
259  childrenToString(
260  StylesheetExecutionContext& executionContext,
261  XalanDOMString& result) const;
262 
271  void
272  childrenToResultAttribute(
273  StylesheetExecutionContext& executionContext,
274  const XalanDOMString& theName) const;
275 
283  void
284  childrenToResultComment(StylesheetExecutionContext& executionContext) const;
285 
295  void
296  childrenToResultPI(
297  StylesheetExecutionContext& executionContext,
298  const XalanDOMString& theTarget) const;
299 
307 #endif
308 
309  int
310  getXSLToken() const
311  {
312  return m_xslToken;
313  }
314 
320  virtual bool
321  isWhitespace() const;
322 
329  virtual const XalanDOMString&
330  getElementName() const = 0;
331 
338  virtual const XalanQName&
339  getNameAttribute() const;
340 
349  virtual void
350  addToStylesheet(
351  StylesheetConstructionContext& constructionContext,
352  Stylesheet& theStylesheet);
353 
365  virtual void
366  processSortElement(
367  StylesheetConstructionContext& constructionContext,
368  Stylesheet& theStylesheet,
369  const AttributeListType& atts,
370  const LocatorType* locator = 0);
371 
377  virtual void
378  setDefaultTemplate(bool value);
379 
385  const NamespacesHandler&
387  {
388  return m_namespacesHandler;
389  }
390 
396  const Stylesheet&
398  {
399  return m_stylesheet;
400  }
401 
407  void
409  {
410  setFlag(eFinishedConstruction, fValue);
411  }
412 
416  bool
418  {
419  return getFlag(eFinishedConstruction);
420  }
421 
425  virtual void
426  postConstruction(
427  StylesheetConstructionContext& constructionContext,
428  const NamespacesHandler& theParentHandler);
429 
430  // Type-safe getters/setters...
431 
437  virtual ElemTemplateElement*
438  getFirstChildElem() const;
439 
440 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
441 
447  virtual const ElemTemplateElement*
448  beginExecuteChildren(
449  StylesheetExecutionContext& executionContext) const;
450 
451 
458  virtual void
459  endExecuteChildren(
460  StylesheetExecutionContext& executionContext) const;
461 
470  const ElemTemplateElement*
471  beginChildrenToString(
472  StylesheetExecutionContext& executionContext,
473  XalanDOMString& result) const;
474 
475 
482  void
483  endChildrenToString(
484  StylesheetExecutionContext& executionContext) const;
485 #endif
486 
487 
495  virtual void
496  setFirstChildElem(ElemTemplateElement* theChild);
497 
503  virtual ElemTemplateElement*
504  getLastChildElem() const;
505 
511  virtual ElemTemplateElement*
512  getNextSiblingElem() const;
513 
514 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
515 
524  virtual const ElemTemplateElement*
525  getNextChildElemToExecute(
526  StylesheetExecutionContext& executionContext,
527  const ElemTemplateElement* currentElem) const;
528 
536  virtual const ElemTemplateElement*
537  getFirstChildElemToExecute(
538  StylesheetExecutionContext& executionContext) const;
539 
547  virtual bool executeChildElement(
548  StylesheetExecutionContext& executionContext,
549  const ElemTemplateElement* element) const;
550 #endif
551 
559  virtual void
560  setNextSiblingElem(ElemTemplateElement* theSibling);
561 
567  virtual ElemTemplateElement*
568  getPreviousSiblingElem() const;
569 
577  virtual void
578  setPreviousSiblingElem(ElemTemplateElement* theSibling);
579 
585  virtual ElemTemplateElement*
586  getParentNodeElem() const;
587 
595  virtual void
596  setParentNodeElem(ElemTemplateElement* theParent);
597 
605  virtual ElemTemplateElement*
606  appendChildElem(ElemTemplateElement* newChild);
607 
617  virtual const XPath*
618  getXPath(unsigned int index = 0) const;
619 
620  // These interfaces are inherited from PrefixResolver...
621 
622  virtual const XalanDOMString*
623  getNamespaceForPrefix(const XalanDOMString& prefix) const;
624 
625  virtual const XalanDOMString&
626  getURI() const;
627 
628  // A class that implements the XalanLocator
629  // abstract base class. ElemTemplateElement
630  // uses this class to provide locator information.
631  class LocatorProxy : public XalanLocator
632  {
633  public:
634 
635  LocatorProxy(
636  size_type theLineNumber,
637  size_type theColumnNumber,
638  const XalanDOMString& theURI);
639 
640  virtual
641  ~LocatorProxy();
642 
643  virtual const XMLCh*
644  getPublicId() const;
645 
646  virtual const XMLCh*
647  getSystemId() const;
648 
649  virtual size_type
650  getLineNumber() const;
651 
652  virtual size_type
653  getColumnNumber() const;
654 
655  const XalanDOMString&
656  getURI() const
657  {
658  return m_uri;
659  }
660 
661  private:
662 
663  // Not implemented...
664  LocatorProxy(const LocatorProxy&);
665 
666  LocatorProxy&
667  operator=(const LocatorProxy&);
668 
669  bool
670  operator==(const LocatorProxy&) const;
671 
672  // data members...
673  const size_type m_lineNumber;
674 
675  const size_type m_columnNumber;
676 
677  const XalanDOMString& m_uri;
678  };
679 
680 
683  {
684  return m_locatorProxy.getLineNumber();
685  }
686 
689  {
690  return m_locatorProxy.getColumnNumber();
691  }
692 
693  bool
694  hasParams() const
695  {
696  return getFlag(eHasParams);
697  }
698 
699  bool
700  hasVariables() const
701  {
702  return getFlag(eHasVariables);
703  }
704 
705  bool
707  {
708  return getFlag(eHasSingleTextChild);
709  }
710 
711  bool
712  hasChildren() const
713  {
714  return m_firstChild != 0 ? true : false;
715  }
716 
717  bool
719  {
720  return getFlag(eHasDirectTemplate);
721  }
722 
723  bool
725  {
726  return getFlag(eCanGenerateAttributes);
727  }
728 
729  bool
731  {
732  return getFlag(eDefaultTemplate);
733  }
734 
735 protected:
736 
737  void
739  {
740  setFlag(eCanGenerateAttributes, value);
741  }
742 
743  void
744  hasPrefix(bool value)
745  {
746  setFlag(eHasPrefix, value);
747  }
748 
749  bool
750  hasPrefix() const
751  {
752  return getFlag(eHasPrefix);
753  }
754 
755  void
756  preserveSpace(bool value)
757  {
758  setFlag(eSpacePreserve, value);
759  }
760 
761  bool
763  {
764  return getFlag(eSpacePreserve);
765  }
766 
767  void
769  {
770  setFlag(eDisableOutputEscaping, value);
771  }
772 
773  bool
775  {
776  return getFlag(eDisableOutputEscaping);
777  }
778 
788  bool
789  processPrefixControl(
790  StylesheetConstructionContext& constructionContext,
791  const Stylesheet& stylesheetTree,
792  const XalanDOMString& localName,
793  const XalanDOMChar* attrValue);
794 
802  const XalanDOMString*
803  getNamespaceForPrefixInternal(const XalanDOMString& prefix) const;
804 
805 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
806 
816  virtual const ElemTemplateElement*
817  findTemplateToTransformChild(
818  StylesheetExecutionContext& executionContext,
819  const ElemTemplateElement& xslInstruction,
820  const ElemTemplateElement* theTemplate,
821  XalanNode* child) const;
822 
834  virtual const ElemTemplateElement*
835  findTemplateToTransformChild(
836  StylesheetExecutionContext& executionContext,
837  const ElemTemplateElement& xslInstruction,
838  const ElemTemplateElement* theTemplate,
839  XalanNode* child,
840  XalanNode::NodeType nodeType) const;
841 #else
842 
851  virtual void
852  transformChild(
853  StylesheetExecutionContext& executionContext,
854  const ElemTemplateElement& xslInstruction,
855  const ElemTemplateElement* theTemplate,
856  XalanNode* child) const;
857 
868  virtual void
869  transformChild(
870  StylesheetExecutionContext& executionContext,
871  const ElemTemplateElement& xslInstruction,
872  const ElemTemplateElement* theTemplate,
873  XalanNode* child,
874  XalanNode::NodeType nodeType) const;
875 #endif
876 
889  virtual bool
890  childTypeAllowed(int xslToken) const;
891 
898  virtual void
899  namespacesPostConstruction(
900  StylesheetConstructionContext& constructionContext,
901  const NamespacesHandler& theParentHandler,
902  NamespacesHandler& theHandler);
903 
904  const NamespacesHandler&
906  {
907  return m_namespacesHandler;
908  }
909 
918  void
919  error(
920  StylesheetExecutionContext& theContext,
921  XalanMessages::Codes theCode) const;
922 
932  void
933  error(
934  StylesheetExecutionContext& theContext,
935  XalanMessages::Codes theCode,
936  const XalanDOMString& theToken) const;
937 
947  void
948  error(
949  StylesheetExecutionContext& theContext,
950  XalanMessages::Codes theCode,
951  const Locator* theLocator) const;
952 
961  void
962  warn(
963  StylesheetExecutionContext& theContext,
964  XalanMessages::Codes theCode) const;
965 
975  void
976  warn(
977  StylesheetExecutionContext& theContext,
978  XalanMessages::Codes theCode,
979  const XalanDOMString& theToken) const;
980 
990  void
991  warn(
992  StylesheetExecutionContext& theContext,
993  XalanMessages::Codes theCode,
994  const Locator* theLocator) const;
995 
1004  void
1005  error(
1006  StylesheetConstructionContext& theContext,
1007  XalanMessages::Codes theCode);
1008 
1019  void
1020  error(
1021  StylesheetConstructionContext& theContext,
1022  XalanMessages::Codes theCode,
1023  const XalanDOMString& theToken);
1024 
1035  void
1036  error(
1037  StylesheetConstructionContext& theContext,
1038  XalanMessages::Codes theCode,
1039  const XalanDOMString& theToken,
1040  const Locator* theLocator);
1041 
1052  void
1053  error(
1054  StylesheetConstructionContext& theContext,
1055  XalanMessages::Codes theCode,
1056  const XalanDOMString& theToken1,
1057  const XalanDOMString& theToken2);
1058 
1069  void
1070  error(
1071  StylesheetConstructionContext& theContext,
1072  XalanMessages::Codes theCode,
1073  const XalanDOMChar* theToken1,
1074  const XalanDOMChar* theToken2);
1075 
1087  void
1088  error(
1089  StylesheetConstructionContext& theContext,
1090  XalanMessages::Codes theCode,
1091  const XalanDOMChar* theToken1,
1092  const XalanDOMChar* theToken2,
1093  const XalanDOMChar* theToken3);
1094 
1106  void
1107  warn(
1108  StylesheetConstructionContext& theContext,
1109  XalanMessages::Codes theCode,
1110  const XalanDOMChar* theToken1,
1111  const XalanDOMChar* theToken2,
1112  const XalanDOMChar* theToken3);
1113 
1114  // A handy empty XalanDOMString instance for
1115  // derived classes to use.
1117 
1118 private:
1119 
1120  enum eFlags
1121  {
1122  eHasParams = 1,
1123  eHasSingleTextChild = 2,
1124  eHasVariables = 4,
1125  eHasDirectTemplate = 8,
1126  eCanGenerateAttributes = 16,
1127  eDefaultTemplate = 32,
1128  eSpacePreserve = 64,
1129  eFinishedConstruction = 128,
1130  eHasPrefix = 256,
1131  eDisableOutputEscaping = 512
1132  };
1133 
1134  bool
1135  getFlag(eFlags theFlag) const
1136  {
1137  return m_flags & theFlag ? true : false;
1138  }
1139 
1140  void
1141  setFlag(
1142  eFlags theFlag,
1143  bool theValue)
1144  {
1145  if (theValue == true)
1146  {
1147  m_flags |= theFlag;
1148  }
1149  else
1150  {
1151  m_flags &= ~theFlag;
1152  }
1153  }
1154 
1155 
1156 #if defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
1157 
1166  doChildrenToString(
1167  StylesheetExecutionContext& executionContext,
1168  XalanDOMString& result) const;
1169 #endif
1170 
1171  Stylesheet& m_stylesheet;
1172 
1173  /*
1174  * This object handles all result tree namespace processing.
1175  */
1176  NamespacesHandler m_namespacesHandler;
1177 
1178  const int m_xslToken;
1179 
1180  ElemTemplateElement* m_parentNode;
1181  ElemTemplateElement* m_nextSibling;
1182  ElemTemplateElement* m_previousSibling;
1183 
1184  union
1185  {
1187  const ElemTemplate* m_directTemplate;
1188  const ElemTextLiteral* m_textLiteralChild;
1189  };
1190 
1191  LocatorProxy m_locatorProxy;
1192 
1193  unsigned short m_flags;
1194 
1195  static const XalanQNameByReference s_emptyQName;
1196 
1197  // Not implemented...
1199 
1201  operator=(const ElemTemplateElement&);
1202 
1203  bool
1204  operator==(const ElemTemplateElement&) const;
1205 };
1206 
1207 
1208 
1209 XALAN_CPP_NAMESPACE_END
1210 
1211 
1212 
1213 #endif // XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1111
Definition: XalanNode.hpp:44
bool hasPrefix() const
Definition: ElemTemplateElement.hpp:750
Definition: ElemTemplate.hpp:41
XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType
Definition: AttributeListImpl.hpp:39
void hasPrefix(bool value)
Definition: ElemTemplateElement.hpp:744
LocatorProxy::size_type getLineNumber() const
Definition: ElemTemplateElement.hpp:682
Definition: ElemTemplateElement.hpp:74
bool getFinishedConstruction() const
Get the flag indicating construction of the element is completed.
Definition: ElemTemplateElement.hpp:417
Definition: NamespacesHandler.hpp:50
This class defines a base class for Locator derivations in Xalan.
Definition: XalanLocator.hpp:42
const ElemTextLiteral * m_textLiteralChild
Definition: ElemTemplateElement.hpp:1188
bool preserveSpace() const
Definition: ElemTemplateElement.hpp:762
NodeType
Definition: XalanNode.hpp:53
bool hasDirectTemplate() const
Definition: ElemTemplateElement.hpp:718
Definition: StylesheetExecutionContext.hpp:104
const XalanDOMString & getURI() const
Definition: ElemTemplateElement.hpp:656
const Stylesheet & getStylesheet() const
Retrieve the stylesheet from which this element comes.
Definition: ElemTemplateElement.hpp:397
ElemTemplateElement * m_firstChild
Definition: ElemTemplateElement.hpp:1186
static size_type getUnknownValue()
Definition: XalanLocator.hpp:80
static const XalanDOMString s_emptyString
Definition: ElemTemplateElement.hpp:1116
int getXSLToken() const
Definition: ElemTemplateElement.hpp:310
Definition: XPath.hpp:62
bool isDefaultTemplate() const
Definition: ElemTemplateElement.hpp:730
bool hasSingleTextChild() const
Definition: ElemTemplateElement.hpp:706
Definition: XalanQNameByReference.hpp:35
LocatorProxy::size_type getColumnNumber() const
Definition: ElemTemplateElement.hpp:688
void setFinishedConstruction(bool fValue)
Set the flag indicating construction of the element is completed.
Definition: ElemTemplateElement.hpp:408
bool hasParams() const
Definition: ElemTemplateElement.hpp:694
Definition: ElemTemplateElement.hpp:631
static MemoryManager & getDummyMemMgr()
Definition: ElemTextLiteral.hpp:38
XALAN_CPP_NAMESPACE_BEGIN typedef size_t size_type
Definition: XalanMap.hpp:44
This class defines an interface for classes that resolve namespace prefixes to their URIs...
Definition: PrefixResolver.hpp:37
XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType
Definition: FormatterListener.hpp:47
const NamespacesHandler & getNamespacesHandler() const
Get the namespaces handler for this element.
Definition: ElemTemplateElement.hpp:386
bool hasVariables() const
Definition: ElemTemplateElement.hpp:700
const NamespacesHandler & getNamespaces() const
Definition: ElemTemplateElement.hpp:905
#define XALAN_XSLT_EXPORT
Definition: XSLTDefinitions.hpp:25
void canGenerateAttributes(bool value)
Definition: ElemTemplateElement.hpp:738
Definition: XalanDOMString.hpp:42
bool canGenerateAttributes() const
Definition: ElemTemplateElement.hpp:724
Definition: StylesheetConstructionContext.hpp:73
This class represents the base stylesheet or an "import" stylesheet.
Definition: Stylesheet.hpp:84
bool disableOutputEscaping() const
Definition: ElemTemplateElement.hpp:774
void disableOutputEscaping(bool value)
Definition: ElemTemplateElement.hpp:768
void preserveSpace(bool value)
Definition: ElemTemplateElement.hpp:756
Class to represent a qualified name: "The name of an internal XSLT object, specifically a named templ...
Definition: XalanQName.hpp:68
const ElemTemplate * m_directTemplate
Definition: ElemTemplateElement.hpp:1187
bool hasChildren() const
Definition: ElemTemplateElement.hpp:712

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo