Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


StylesheetConstructionContext.hpp
Go to the documentation of this file.
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 #if !defined(STYLESHEETCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680)
19 #define STYLESHEETCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
33 
34 
35 
37 #include <xalanc/XPath/XPath.hpp>
39 
40 
41 
42 XALAN_DECLARE_XERCES_CLASS(AttributeList)
43 XALAN_DECLARE_XERCES_CLASS(DocumentHandler)
44 XALAN_DECLARE_XERCES_CLASS(Locator)
45 
46 
47 
48 XALAN_CPP_NAMESPACE_BEGIN
49 
50 
51 
52 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType;
53 typedef XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler DocumentHandlerType;
54 
55 XALAN_USING_XERCES(AttributeList)
56 XALAN_USING_XERCES(DocumentHandler)
57 XALAN_USING_XERCES(Locator)
58 
59 
60 
61 class AVT;
62 class AVTPart;
63 class ElemTemplate;
65 class ExtensionNSHandler;
66 class PrefixResolver;
67 class Stylesheet;
68 class StylesheetRoot;
69 class XalanDocument;
71 class XalanNode;
72 class XSLTInputSource;
73 
74 
75 
76 //
77 // An abstract class which provides support for constructing the internal
78 // representation of a stylesheet.
79 //
81 {
82 public:
83 
85 
86  /**
87  * IDs for XSL element types. These are the values
88  * that must be returned by getElementToken().
89  */
91  {
92  ELEMNAME_UNDEFINED = -2,
93  ELEMNAME_EMPTY = -1,
123 
125 
128 
132 
133  // This one doesn't really have a name.
134  // It's used for any literal result
135  // element.
137 
138  // This one doesn't really have a name.
139  // It's used for any literal text in
140  // the content of a literal result
141  // element.
143 
144  // This one doesn't really have a name.
145  // It's used for forward-compatible
146  // processing.
148 
149  // Extension handling.
151  ELEMNAME_EXTENSION_HANDLER
152  };
153 
155 
156  explicit
157  StylesheetConstructionContext(MemoryManager& theManager);
158 
159  virtual
161 
162 
163  // These are inherited from XPathConstructionContext...
164  virtual void
165  problem(
166  eSource source,
167  eClassification classification,
168  const XalanDOMString& msg,
169  const Locator* locator,
170  const XalanNode* sourceNode) = 0;
171 
172  virtual void
173  problem(
174  eSource source,
175  eClassification classification,
176  const XalanDOMString& msg,
177  const XalanNode* sourceNode) = 0;
178 
179  virtual void
180  reset() = 0;
181 
182  virtual const XalanDOMString&
183  getPooledString(const XalanDOMString& theString) = 0;
184 
185  virtual const XalanDOMString&
187  const XalanDOMChar* theString,
189 
190  virtual XalanDOMString&
191  getCachedString() = 0;
192 
193  virtual bool
194  releaseCachedString(XalanDOMString& theString) = 0;
195 
196  /**
197  * Create a new StylesheetRoot instance. The StylesheetConstructionContext
198  * instance owns the StylesheetRoot instance, and will delete it when asked
199  * or when the StylesheetConstructionContext instance is destroyed.
200  *
201  * @param theBaseIdentifier A URI to the stylesheet file.
202  * @return A pointer to a new StylesheetRoot instance.
203  */
204  virtual StylesheetRoot*
205  create(const XalanDOMString& theBaseIdentifier) = 0;
206 
207  /**
208  * Create a new StylesheetRoot instance. The StylesheetConstructionContext
209  * instance owns the StylesheetRoot instance, and will delete it when asked
210  * or when the StylesheetConstructionContext instance is destroyed.
211  *
212  * @param theInputSource A reference to the input source.
213  * @return A pointer to a new StylesheetRoot instance.
214  */
215  virtual StylesheetRoot*
216  create(const XSLTInputSource& theInputSource) = 0;
217 
218  /**
219  * Create a new Stylesheet instance. The StylesheetConstructionContext
220  * instance owns the Stylesheet instance, and will delete it when asked
221  * or when the StylesheetConstructionContext instance is destroyed.
222  *
223  * @param A reference to the StylesheetRoot instance.
224  * @param theBaseIdentifier A URI to the stylesheet file.
225  * @return A pointer to a new StylesheetRoot instance.
226  */
227  virtual Stylesheet*
228  create(
229  StylesheetRoot& theStylesheetRoot,
230  const XalanDOMString& theBaseIdentifier) = 0;
231 
232  /**
233  * Destroy a StylesheetRoot instance. If this StylesheetConstructionContext
234  * instance does not own the StylesheetRoot, it will not delete it
235  *
236  * @param theStylesheet A pointer to the StylesheetRoot instance to delete.
237  */
238  virtual void
239  destroy(StylesheetRoot* theStylesheetRoot) = 0;
240 
241  /**
242  * Determine the fully qualified URI for a string.
243  *
244  * @param urlString string to qualify
245  * @return auto pointer to fully qualified URI
246  */
247  virtual URLAutoPtrType
248  getURLFromString(const XalanDOMString& urlString) = 0;
249 
250  /**
251  * Determine the fully qualified URI for a string.
252  *
253  * @param urlString string to qualify
254  * @return string to fully qualified URI
255  */
256  virtual XalanDOMString&
257  getURLStringFromString(
258  const XalanDOMString& urlString,
259  XalanDOMString& theResult) = 0;
260 
261  /**
262  * Determine the fully qualified URI for a string.
263  *
264  * @param urlString string to qualify
265  * @param base base location for URI
266  * @return auto pointer to fully qualified URI
267  */
268  virtual URLAutoPtrType
269  getURLFromString(
270  const XalanDOMString& urlString,
271  const XalanDOMString& base) = 0;
272 
273  /**
274  * Determine the fully qualified URI for a string.
275  *
276  * @param urlString string to qualify
277  * @param base base location for URI
278  * @return string to fully qualified URI
279  */
280  virtual XalanDOMString&
281  getURLStringFromString(
282  const XalanDOMString& urlString,
283  const XalanDOMString& base,
284  XalanDOMString& theResult) = 0;
285 
286  /**
287  * Retrieve the URI for the current XSLT namespace, for example,
288  * "http://www.w3.org/1999/XSL/Transform"
289  *
290  * @return URI string
291  */
292  virtual const XalanDOMString&
293  getXSLTNamespaceURI() const = 0;
294 
295  /**
296  * Create and initialize an xpath for a match pattern and return it. This
297  * is to be used by stylesheet elements that need an XPath that is
298  * guaranteed to persist while it lives.
299  *
300  * @param locator the locator for the XPath. May be null.
301  * @param str string to match
302  * @param resolver resolver for namespace resolution
303  * @param allowVariableReferences If true, variable references are allowed.
304  * @param allowKeyFunction If true, calls to the key() function are allowed.
305  * @return XPath for match pattern
306  */
307  virtual XPath*
308  createMatchPattern(
309  const Locator* locator,
310  const XalanDOMString& str,
311  const PrefixResolver& resolver,
312  bool allowVariableReferences = true,
313  bool allowKeyFunction = true) = 0;
314 
315  /**
316  * Create and initialize an xpath for a match pattern and return it. This
317  * is to be used by stylesheet elements that need an XPath that is
318  * guaranteed to persist while it lives.
319  *
320  * @param locator the locator for the XPath. May be null.
321  * @param str string to match
322  * @param resolver resolver for namespace resolution
323  * @param allowVariableReferences If true, variable references are allowed.
324  * @param allowKeyFunction If true, calls to the key() function are allowed.
325  * @return XPath for match pattern
326  */
327  virtual XPath*
328  createMatchPattern(
329  const Locator* locator,
330  const XalanDOMChar* str,
331  const PrefixResolver& resolver,
332  bool allowVariableReferences = true,
333  bool allowKeyFunction = true) = 0;
334 
335  /**
336  * Create and initialize an xpath and return it. This is to be used by
337  * stylesheet elements that need an XPath that is guaranteed to persist
338  * while it lives.
339  *
340  * @param locator the locator for the XPath. May be null.
341  * @param str string to match
342  * @param resolver resolver for namespace resolution
343  * @return XPath for string matched
344  */
345  virtual XPath*
346  createXPath(
347  const Locator* locator,
348  const XalanDOMString& str,
349  const PrefixResolver& resolver,
350  bool allowVariableReferences = true,
351  bool allowKeyFunction = true) = 0;
352 
353  /**
354  * Create and initialize an xpath and return it. This is to be used by
355  * stylesheet elements that need an XPath that is guaranteed to persist
356  * while it lives.
357  *
358  * @param locator the locator for the XPath. May be null.
359  * @param str string to match
360  * @param resolver resolver for namespace resolution
361  * @return XPath for string matched
362  */
363  virtual XPath*
364  createXPath(
365  const Locator* locator,
366  const XalanDOMChar* str,
367  const PrefixResolver& resolver,
368  bool allowVariableReferences = true,
369  bool allowKeyFunction = true) = 0;
370 
371  /**
372  * Create and initialize an xpath and return it. This is to be used by
373  * stylesheet elements that need an XPath that is guaranteed to persist
374  * while it lives.
375  *
376  * @param locator the locator for the XPath. May be null.
377  * @param str string to match
378  * @param resolver resolver for namespace resolution
379  * @return XPath for string matched
380  */
381  virtual XPath*
382  createXPath(
383  const Locator* locator,
384  const XalanDOMChar* str,
386  const PrefixResolver& resolver,
387  bool allowVariableReferences = true,
388  bool allowKeyFunction = true) = 0;
389 
390  /**
391  * Get the locator from the top of the locator stack.
392  *
393  * @return A pointer to the Locator, or 0 if there is nothing on the stack.
394  */
395  virtual const Locator*
396  getLocatorFromStack() const = 0;
397 
398  /**
399  * Push a locator on to the locator stack.
400  *
401  * @param A pointer to the Locator to push.
402  */
403  virtual void
404  pushLocatorOnStack(const Locator* locator) = 0;
405 
406  /**
407  * Pop the locator from the top of the locator stack.
408  */
409  virtual void
410  popLocatorStack() = 0;
411 
412  /**
413  * Get the Xalan namespace for built-in extensions.
414  *
415  * @return Xalan namespace for extensions
416  */
417  virtual const XalanDOMString&
418  getXalanXSLNameSpaceURL() const = 0;
419 
420  /**
421  * Read in the XML file, either producing a Document or calling SAX events,
422  * and register the document in a table. If the document has already been
423  * read in, it will not be reparsed.
424  *
425  * @param urlString location of the XML
426  * @param docHandler pointer to SAX event handler
427  * @param docToRegister if using a SAX event handler, the object to register in the source docs table.
428  * @return document object, which represents the parsed XML
429  * @exception SAXException
430  */
431  virtual XalanDocument*
432  parseXML(
433  const XalanDOMString& urlString,
434  DocumentHandler* docHandler,
435  XalanDocument* docToRegister,
436  ErrorHandler* theErrorHandler = 0) = 0;
437 
438  /**
439  * Given an name, determine if it is the xml:space attribute
440  *
441  * @param theAttributeName The name to check
442  * @param theStylesheet The current Stylesheet instance
443  * @param theLocator The Locator for error reporting. May be 0.
444  *
445  * @return true if the string is the xml:space attribute name
446  */
447  virtual bool
448  isXMLSpaceAttribute(
449  const XalanDOMChar* theAttributeName,
450  const Stylesheet& theStylesheet,
451  const Locator* theLocator = 0) = 0;
452 
453  /**
454  * Given an name, determine if it is the xsl:use-attribute-sets attribute
455  *
456  * @param theAttributeName The name to check
457  * @param theStylesheet The current Stylesheet instance
458  * @param theLocator The Locator for error reporting. May be 0.
459  *
460  * @return true if the string is the xsl:use-attribute-sets attribute name
461  */
462  virtual bool
463  isXSLUseAttributeSetsAttribute(
464  const XalanDOMChar* theAttributeName,
465  const Stylesheet& theStylesheet,
466  const Locator* theLocator = 0) = 0;
467 
468  /**
469  * Given an name, determine if it is a valid QName
470  *
471  * @param theName The name to check
472  * @param theStylesheet The current Stylesheet instance
473  * @param theLocator The Locator for error reporting. May be 0.
474  *
475  * @return true if the string is a valid QName.
476  */
477  virtual bool
478  isValidQName(
479  const XalanDOMChar* theName,
480  const Stylesheet& theStylesheet,
481  const Locator* theLocator = 0) = 0;
482 
483  /**
484  * Given an XSL tag name, return an integer token that corresponds to
485  * the enums defined above.
486  *
487  * @param name a probable xsl:xxx element
488  * @return The enum value for that token, or ELEMNAME_UNDEFINED
489  */
490  virtual eElementToken
491  getElementToken(const XalanDOMString& name) const = 0;
492 
493  /**
494  * Get the latest XSLT version currently supported.
495  *
496  * @return XSLT version number
497  */
498  virtual double
499  getXSLTVersionSupported() const = 0;
500 
501  /**
502  * Allocate a vector of XalanDOMChar of the specified
503  * size.
504  *
505  * @param theLength The length of the character vector
506  * @return A pointer to the vector.
507  */
508  virtual XalanDOMChar*
509  allocateXalanDOMCharVector(XalanDOMString::size_type theLength) = 0;
510 
511  /**
512  * Allocate a vector of XalanDOMChar of the specified
513  * size.
514  *
515  * @param theString The source character array
516  * @param theLength The length of the character vector
517  * @param fTerminate If true, terminate the new vector with 0
518  * @return A pointer to the array.
519  */
520  virtual XalanDOMChar*
521  allocateXalanDOMCharVector(
522  const XalanDOMChar* theString,
524  bool fTerminate = true) = 0;
525 
526  /**
527  * Create an AVT instance.
528  *
529  * @param locator the Locator for the instance. May be null.
530  * @param name name of AVT
531  * @param stringedValue string value to parse
532  * @param resolver resolver for namespace resolution
533  * @return A pointer to the instance.
534  */
535  virtual const AVT*
536  createAVT(
537  const Locator* locator,
538  const XalanDOMChar* name,
539  const XalanDOMChar* stringedValue,
540  const PrefixResolver& resolver) = 0;
541 
542  /**
543  * Create an AVTPart instance.
544  *
545  * @param theString The source character array
546  * @param theLength The length of the character vector
547  * @param fTerminate If true, terminate the new vector with 0
548  * @return A pointer to the instance.
549  */
550  virtual const AVTPart*
551  createAVTPart(
552  const XalanDOMChar* theString,
554 
555  /**
556  * Create an AVTPart instance.
557  *
558  * @param locator the Locator for the instance. May be null.
559  * @param str The XPath expression for the instance
560  * @param len The length of the expression
561  * @param resolver resolver for namespace resolution
562  * @return A pointer to the instance.
563  */
564  virtual const AVTPart*
565  createAVTPart(
566  const Locator* locator,
567  const XalanDOMChar* str,
569  const PrefixResolver& resolver) = 0;
570 
571  /**
572  * Allocate a vector of const AVT* of the specified
573  * length.
574  *
575  * @param theLength The length of the vector
576  * @return A pointer to the vector.
577  */
578  virtual const AVT**
579  allocateAVTPointerVector(size_type theLength) = 0;
580 
581  /**
582  * Allocate a vector of const AVTPart* of the specified
583  * length.
584  *
585  * @param theLength The length of the vector
586  * @return A pointer to the vector.
587  */
588  virtual const AVTPart**
589  allocateAVTPartPointerVector(size_type theLength) = 0;
590 
591  /**
592  * Create a XalanQName-derived instance.
593  *
594  * @param qname The qname string
595  * @param namespaces The stack of namespaces
596  * @param Locator The current Locator, if any
597  * @param fUseDefault If true, a qname without a prefix will use the default namespace
598  * @return A pointer to the new instance
599  */
600  virtual const XalanQName*
601  createXalanQName(
602  const XalanDOMString& qname,
603  const NamespacesStackType& namespaces,
604  const Locator* locator = 0,
605  bool fUseDefault = false) = 0;
606 
607  /**
608  * Create a XalanQName-derived instance.
609  *
610  * @param qname The qname string
611  * @param namespaces The stack of namespaces
612  * @param Locator The current Locator, if any
613  * @param fUseDefault If true, a qname without a prefix will use the default namespace
614  * @return A pointer to the new instance
615  */
616  virtual const XalanQName*
617  createXalanQName(
618  const XalanDOMChar* qname,
619  const NamespacesStackType& namespaces,
620  const Locator* locator = 0,
621  bool fUseDefault = false) = 0;
622 
623  /**
624  * Tokenize a string and return the QNames corresponding to
625  * those tokens.
626  *
627  * @param count The number of namespaces in the vector returned
628  * @param qnameTokens The string to tokenize
629  * @param namespaces The stack of namespaces
630  * @param Locator The current Locator, if any
631  * @param fUseDefault If true, qnames without prefixes will use the default namespace
632  * @return The resulting vector of XalanQName instances.
633  */
634  virtual const XalanQName**
635  tokenizeQNames(
636  size_type& count,
637  const XalanDOMChar* qnameTokens,
638  const NamespacesStackType& namespaces,
639  const Locator* locator = 0,
640  bool fUseDefault = false) = 0;
641 
642  /**
643  * Create a stylesheet element for the provided type. The
644  * instance owns the memory and will delete the element when
645  * it goes out of scope and the containing stylesheet is
646  * destroyed.
647  *
648  * @param token The enum value of the element to create.
649  * @param stylesheetTree The stylesheet containing the element
650  * @param atts The list of attributes for the element
651  * @param locator The Locator instance for error reporting. May be 0.
652  *
653  * @return A pointer to the new instance.
654  */
655  virtual ElemTemplateElement*
656  createElement(
657  int token,
658  Stylesheet& stylesheetTree,
659  const AttributeList& atts,
660  const Locator* locator = 0) = 0;
661 
662  /**
663  * Create a elements which have specific names. The instance
664  * owns the memory and will delete the element when it goes
665  * out of scope and the containing stylesheet is destroyed.
666  *
667  * @param token The enum value of the element to create.
668  * @param stylesheetTree The stylesheet containing the element
669  * @param name The name of the element
670  * @param atts The list of attributes for the element
671  * @param locator The Locator instance for error reporting. May be 0.
672  *
673  * @return A pointer to the new instance.
674  */
675  virtual ElemTemplateElement*
676  createElement(
677  int token,
678  Stylesheet& stylesheetTree,
679  const XalanDOMChar* name,
680  const AttributeList& atts,
681  const Locator* locator = 0) = 0;
682 
683  /**
684  * Create a an element for literal text. The instance owns the
685  * memory and will delete the element when it goes out of
686  * scope and the containing stylesheet is destroyed.
687  *
688  * @param stylesheetTree The stylesheet containing the element
689  * @param chars The pointer to character string for element
690  * @param length length of the chars parameter.
691  * @param preserveSpace true is space should be preserved
692  * @param disableOutputEscaping true if output escaping should be disabled
693  * @param locator The Locator instance for error reporting. May be 0.
694  *
695  * @return A pointer to the new instance.
696  */
697  virtual ElemTemplateElement*
698  createElement(
699  Stylesheet& stylesheetTree,
700  const XalanDOMChar* chars,
702  bool preserveSpace,
703  bool disableOutputEscaping,
704  const Locator* locator = 0) = 0;
705 
706  /**
707  * Create an element to handle an extension element. The
708  * instance owns the memory and will delete the element when
709  * it goes out of scope and the containing stylesheet is
710  * destroyed.
711  *
712  * @param stylesheetTree The stylesheet containing the element
713  * @param name The name of the element
714  * @param atts The list of attributes for the element
715  * @param handler The handler for elements in the extension namespace
716  * @param locator The Locator instance for error reporting. May be 0.
717  *
718  * @return A pointer to the new instance.
719  */
720  virtual ElemTemplateElement*
721  createElement(
722  Stylesheet& stylesheetTree,
723  const XalanDOMChar* name,
724  const AttributeList& atts,
725  ExtensionNSHandler& handler,
726  const Locator* locator = 0) = 0;
727 
728  /**
729  * Create an instance of XalanMatchPatternData, which describes
730  * data related to a match pattern and template in stylesheet.
731  * The instance owns the memory and will delete the element when
732  * it goes out of scope and the containing stylesheet is
733  * destroyed.
734  *
735  * @param theTemplate The ElemTemplate node that contains the template for this pattern
736  * @param thePosition The position in the stylesheet
737  * @param theTargetString The target string for match pattern
738  * @param TheMatchPattern The match pattern
739  * @param thePatternString the pattern string
740  * @param thePriority The priority for the match pattern.
741  *
742  * @return A pointer to the new instance.
743  */
744  virtual const XalanMatchPatternData*
745  createXalanMatchPatternData(
746  const ElemTemplate& theTemplate,
747  size_type thePosition,
748  const XalanDOMString& theTargetString,
749  const XPath& theMatchPattern,
750  const XalanDOMString& thePatternString,
751  XPath::eMatchScore thePriority) = 0;
752 };
753 
754 
755 
756 XALAN_CPP_NAMESPACE_END
757 
758 
759 
760 #endif // STYLESHEETCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680
This class contains information concerning a match pattern in a stylesheet.
virtual bool releaseCachedString(XalanDOMString &theString)=0
Return a cached string.
eMatchScore
Definition: XPath.hpp:86
This acts as the stylesheet root of the stylesheet tree, and holds values that are shared by all styl...
virtual const XalanDOMString & getPooledString(const XalanDOMString &theString)=0
Get a pooled string given the source string.
virtual void reset()=0
Reset the instance.
Definition: XPath.hpp:64
XalanSize_t size_type
Class to hold a part, either a string or XPath, of an Attribute Value Template.
Definition: AVTPart.hpp:43
Class to hold an Attribute Value Template.
Definition: AVT.hpp:55
XALAN_CPP_NAMESPACE_BEGIN typedef size_t size_type
Definition: XalanMap.hpp:46
virtual void problem(eSource source, eClassification classification, const XalanDOMString &msg, const Locator *locator, const XalanNode *sourceNode)=0
Function that is called when a problem event occurs.
XalanQName::NamespacesStackType NamespacesStackType
This class defines an interface for classes that resolve namespace prefixes to their URIs...
XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler DocumentHandlerType
virtual XalanDOMString & getCachedString()=0
Get a cached string for temporary use.
#define XALAN_XSLT_EXPORT
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType
This class represents the base stylesheet or an "import" stylesheet.
Definition: Stylesheet.hpp:86
XALAN_CPP_NAMESPACE_BEGIN XALAN_USING_XERCES(Locator)
Class to represent a qualified name.
Definition: XalanQName.hpp:70
Xalan implementation of deque.
Definition: XalanDeque.hpp:200

Interpreting class diagrams

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

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

Apache Logo