Qt 4.8
Public Functions | Static Private Functions | List of all members
QPatternist::XSLTSimpleContentConstructor Class Reference

Implements XSL-T's construction of simple content, which is different from XQuery's approach. More...

#include <qxsltsimplecontentconstructor_p.h>

Inheritance diagram for QPatternist::XSLTSimpleContentConstructor:
QPatternist::SimpleContentConstructor QPatternist::SingleContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual SequenceType::List expectedOperandTypes () const
 
virtual SequenceType::Ptr staticType () const
 
 XSLTSimpleContentConstructor (const Expression::Ptr &source)
 
- Public Functions inherited from QPatternist::SimpleContentConstructor
virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual Expression::Ptr compress (const StaticContext::Ptr &context)
 
 SimpleContentConstructor (const Expression::Ptr &operand)
 
- Public Functions inherited from QPatternist::SingleContainer
virtual bool compressOperands (const StaticContext::Ptr &)
 
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &operands)
 
- Public Functions inherited from QPatternist::Expression
virtual const SourceLocationReflectionactualReflection () const
 Returns this. More...
 
virtual void announceFocusType (const ItemType::Ptr &itemType)
 
Properties deepProperties () const
 Computes the union of properties for this Expression and all its descending children. More...
 
virtual Properties dependencies () const
 
virtual QString description () const
 
virtual bool evaluateEBV (const DynamicContext::Ptr &context) const
 
virtual Item::Iterator::Ptr evaluateSequence (const DynamicContext::Ptr &context) const
 
virtual void evaluateToSequenceReceiver (const DynamicContext::Ptr &context) const
 
virtual ItemType::Ptr expectedContextItemType () const
 
 Expression ()
 
bool has (const Property prop) const
 
bool hasDependency (const Property prop) const
 
virtual ID id () const
 
bool is (const ID id) const
 
bool isEvaluated () const
 
virtual ItemType::Ptr newFocusType () const
 
virtual QList< QExplicitlySharedDataPointer< OptimizationPass > > optimizationPasses () const
 
virtual PatternPriority patternPriority () const
 
virtual Properties properties () const
 
const Expression::Ptrrewrite (const Expression::Ptr &to, const StaticContext::Ptr &context) const
 Rewrites this Expression to to, and return to. More...
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
virtual ~Expression ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 
- Public Functions inherited from QPatternist::CppCastingHelper< Expression >
const TCastTarget * as () const
 
TCastTarget * as ()
 
- Public Functions inherited from QPatternist::SourceLocationReflection
virtual QSourceLocation sourceLocation () const
 
 SourceLocationReflection ()
 
virtual ~SourceLocationReflection ()
 

Static Private Functions

static QString processItem (const Item &item, bool &discard, bool &isText)
 

Additional Inherited Members

- Public Types inherited from QPatternist::Expression
typedef QExplicitlySharedDataPointer< const ExpressionConstPtr
 A smart pointer wrapping const Expression instances. More...
 
enum  ID {
  IDBooleanValue = 1, IDCountFN, IDEmptyFN, IDExistsFN,
  IDExpressionSequence, IDGeneralComparison, IDIfThenClause, IDIgnorableExpression,
  IDIntegerValue, IDPositionFN, IDStringValue, IDValueComparison,
  IDRangeVariableReference, IDContextItem, IDUserFunctionCallsite, IDExpressionVariableReference,
  IDAttributeConstructor, IDUpperCaseFN, IDLowerCaseFN, IDFirstItemPredicate,
  IDEmptySequence, IDReturnOrderBy, IDLetClause, IDForClause,
  IDPath, IDNamespaceConstructor, IDArgumentReference, IDGenericPredicate,
  IDAxisStep, IDFloat, IDCombineNodes, IDUnresolvedVariableReference,
  IDCardinalityVerifier
}
 
typedef QList< Expression::PtrList
 
typedef QFlags< PropertyProperties
 
enum  Property {
  UseContextItem = 1, DisableElimination = 1 << 1, IsEvaluated = 1 << 2, DisableTypingDeduction = 1 << 3,
  EmptynessFollowsChild = 1 << 4, RewriteToEmptyOnEmpty = 1 << 5, RequiresFocus = 1 << 6, AffectsOrderOnly = 1 << 7,
  RequiresContextItem = (1 << 8) | RequiresFocus, CreatesFocusForLast = 1 << 9, LastOperandIsCollation = 1 << 10, DependsOnLocalVariable = (1 << 11) | DisableElimination,
  EvaluationCacheRedundant = (1 << 12), IsNodeConstructor = 1 << 13, RequiresCurrentItem = 1 << 14
}
 
typedef QExplicitlySharedDataPointer< ExpressionPtr
 A smart pointer wrapping mutable Expression instances. More...
 
typedef ::QAbstractXmlForwardIterator< Expression::PtrQAbstractXmlForwardIterator
 
typedef QVector< Expression::PtrVector
 
- Static Public Functions inherited from QPatternist::Expression
static void rewrite (Expression::Ptr &old, const Expression::Ptr &New, const StaticContext::Ptr &context)
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QPatternist::SingleContainer
 SingleContainer (const Expression::Ptr &operand)
 
- Protected Functions inherited from QPatternist::Expression
void typeCheckOperands (const StaticContext::Ptr &context)
 
- Protected Functions inherited from QPatternist::CppCastingHelper< Expression >
 CppCastingHelper ()
 
- Protected Variables inherited from QPatternist::SingleContainer
Expression::Ptr m_operand
 

Detailed Description

Implements XSL-T's construction of simple content, which is different from XQuery's approach.

See also
XSL Transformations (XSLT) Version 2.0, 5.7.2 Constructing Simple Content
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 71 of file qxsltsimplecontentconstructor_p.h.

Constructors and Destructors

◆ XSLTSimpleContentConstructor()

XSLTSimpleContentConstructor::XSLTSimpleContentConstructor ( const Expression::Ptr source)

Definition at line 51 of file qxsltsimplecontentconstructor.cpp.

51  : SimpleContentConstructor(source)
52 {
53 }
SimpleContentConstructor(const Expression::Ptr &operand)

Functions

◆ evaluateSingleton()

Item XSLTSimpleContentConstructor::evaluateSingleton ( const DynamicContext::Ptr context) const
virtual

Reimplemented from QPatternist::SimpleContentConstructor.

Definition at line 100 of file qxsltsimplecontentconstructor.cpp.

101 {
103 
104  Item next(it->next());
105  QString result;
106 
107  bool previousIsText = false;
108  bool discard = false;
109 
110  if(next)
111  {
112  const QString unit(processItem(next, discard, previousIsText));
113 
114  if(!discard)
115  result = unit;
116 
117  next = it->next();
118  }
119  else
120  return Item();
121 
122  while(next)
123  {
124  bool currentIsText = false;
125  const QString unit(processItem(next, discard, currentIsText));
126 
127  if(!discard)
128  {
129  /* "Adjacent text nodes in the sequence are merged into a single text
130  * node." */
131  if(previousIsText && currentIsText)
132  ;
133  else
134  result += QLatin1Char(' ');
135 
136  result += unit;
137  }
138 
139  next = it->next();
140  previousIsText = currentIsText;
141  }
142 
143  return AtomicString::fromValue(result);
144 }
#define it(className, varName)
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
The QString class provides a Unicode character string.
Definition: qstring.h:83
static AtomicString::Ptr fromValue(const QString &value)
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
static QString processItem(const Item &item, bool &discard, bool &isText)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

SequenceType::List XSLTSimpleContentConstructor::expectedOperandTypes ( ) const
virtual

Returns a list of Sequence Types, describing the type of each of the expression's operands. Hence, this function has a relationship to the operands() function:

- The lengths of the lists returned by expectedOperandTypes()
and operands() should always be equal in length, since one
cannot describe the type of a non-existent operand(and all
operands must have type information).
- A significant difference between the two functions is that while
the type of objects in the list returned by operands() may vary
between compilations/static context, simply because the particular
Expression is part of different XPath expressions, the
types in the list returned by expectedOperandTypes is always the same
since the function/operator signature never changes.

This function should not be confused with staticType(), which returns the static type of the expression itself, not its operands. The function call is an expression where this is clear: the type of the return value is not the same as the arguments' types. The static type of the operands supplied to the expression can be determined via the staticType() function of the instances returned by operands().

If the expression has no operands, an empty list should be returned.

Reimplemented from QPatternist::SimpleContentConstructor.

Definition at line 146 of file qxsltsimplecontentconstructor.cpp.

147 {
148  SequenceType::List result;
150  return result;
151 }
static const SequenceType::Ptr ZeroOrMoreItems
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ processItem()

QString XSLTSimpleContentConstructor::processItem ( const Item item,
bool &  discard,
bool &  isText 
)
inlinestaticprivate

Definition at line 55 of file qxsltsimplecontentconstructor.cpp.

Referenced by evaluateSingleton().

58 {
59  if(item.isNode())
60  {
61  isText = (item.asNode().kind() == QXmlNodeModelIndex::Text);
62 
63  if(isText)
64  {
65  const QString value(item.stringValue());
66 
67  /* "1. Zero-length text nodes in the sequence are discarded." */
68  discard = value.isEmpty();
69  return value;
70  }
71  else
72  {
73  Item::Iterator::Ptr it(item.sequencedTypedValue()); /* Atomic values. */
74  Item next(it->next());
75  QString result;
76 
77  if(next)
78  result = next.stringValue();
79 
80  next = it->next();
81 
82  while(next)
83  {
84  result += next.stringValue();
85  result += QLatin1Char(' ');
86  next = it->next();
87  }
88 
89  return result;
90  }
91  }
92  else
93  {
94  discard = false;
95  isText = false;
96  return item.stringValue();
97  }
98 }
#define it(className, varName)
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isNode() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:349
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString stringValue() const
Returns the string value of this Item.
Definition: qitem_p.h:302
const QXmlNodeModelIndex & asNode() const
Definition: qitem_p.h:379
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
Item::Iterator::Ptr sequencedTypedValue() const
Returns the typed value of this item.
Definition: qitem.cpp:50
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
NodeKind kind() const
Definition: qitem_p.h:471

◆ staticType()

SequenceType::Ptr XSLTSimpleContentConstructor::staticType ( ) const
virtual
Returns
the static type of this Expression. For example, an 'and' expression have as static type xs:boolean

Reimplemented from QPatternist::SimpleContentConstructor.

Definition at line 153 of file qxsltsimplecontentconstructor.cpp.

154 {
156 }
static const SequenceType::Ptr ZeroOrOneString

The documentation for this class was generated from the following files: