42 #include <QStringList> 76 , m_validationAlternatives(createValidationAlternatives())
104 ReservedForAttributes = 6
126 ReservedForElements = 40
128 result.
reserve(ReservedForElements);
519 message = QtXmlPatterns::tr(
"Element %1 is not allowed at this location.")
528 message = QtXmlPatterns::tr(
"Text nodes are not allowed at this location.");
541 error(message, effectiveCode);
594 const bool isXSLTElement,
596 const bool generateCode,
597 const bool setGlobalVersion)
608 if(number->hasError())
610 error(QtXmlPatterns::tr(
"The value of the XSL-T version attribute " 627 else if(version == 1.0)
630 warning(QtXmlPatterns::tr(
"Running an XSL-T 1.0 stylesheet with a 2.0 processor."));
639 else if(version > 2.0)
641 else if(version < 2.0)
651 const bool isInstruction,
694 for(
int i = 0; i < len; ++i)
738 error(QtXmlPatterns::tr(
"Unknown XSL-T attribute %1.")
756 if(!hasType && !hasValidation)
759 if(hasType && hasValidation)
761 error(QtXmlPatterns::tr(
"Attribute %1 and %2 are mutually exclusive.")
771 for(
int i = 0; i < len; ++i)
775 validationAttribute = at;
779 "We should always find the attribute.");
784 validationAttribute);
844 Q_FUNC_INFO,
"The current token state must be StartElement or EndElement.");
927 error(QtXmlPatterns::tr(
"In a simplified stylesheet module, attribute %1 must be present.")
999 error(QtXmlPatterns::tr(
"If element %1 has no attribute %2, it cannot have attribute %3 or %4.")
1006 else if(!hasMatch && !hasName)
1008 error(QtXmlPatterns::tr(
"Element %1 must have at least one of the attributes %2 or %3.")
1036 error(QtXmlPatterns::tr(
"At least one mode must be specified in the %1-attribute on element %2.")
1046 for(
int i = 0; i < modeList.count(); ++i)
1052 if(i < modeList.count() - 1)
1091 const bool wrapWithParantheses)
1095 if(wrapWithParantheses)
1100 if(wrapWithParantheses)
1123 if(hasWrittenExpression)
1126 hasWrittenExpression =
true;
1138 bool hasHandledOtherwise =
false;
1139 bool hasEncounteredAtLeastOneWhen =
false;
1157 if(hasHandledOtherwise)
1159 error(QtXmlPatterns::tr(
"Element %1 must come last.")
1175 hasEncounteredAtLeastOneWhen =
true;
1181 if(!hasEncounteredAtLeastOneWhen)
1183 error(QtXmlPatterns::tr(
"At least one %1-element must occur before %2.")
1188 else if(hasHandledOtherwise)
1190 error(QtXmlPatterns::tr(
"Only one %1-element can appear.")
1199 hasHandledOtherwise =
true;
1219 if(!hasEncounteredAtLeastOneWhen)
1221 error(QtXmlPatterns::tr(
"At least one %1-element must occur inside %2.")
1227 if(!hasHandledOtherwise)
1263 const bool emptynessAllowed,
1266 const bool queueEmptyOnEmpty)
1279 error(QtXmlPatterns::tr(
"When attribute %1 is present on %2, a sequence " 1292 error(QtXmlPatterns::tr(
"Element %1 must have either a %2-attribute " 1304 const bool emptynessAllowed,
1306 const bool selectOnlyFirst)
1404 const bool hasQueuedContent = !storage.
isEmpty();
1415 if(hasQueuedContent)
1417 error(QtXmlPatterns::tr(
"When a parameter is required, a default value " 1418 "cannot be supplied through a %1-attribute or " 1425 if(hasQueuedContent)
1429 if(!hasSelect && !hasAs && !hasQueuedContent)
1431 else if(hasAs || hasSelect)
1455 if(hasSelect | hasQueuedContent)
1458 if(hasQueuedContent)
1460 if(!hasSelect && !hasAs && !hasQueuedContent)
1462 else if(hasAs || hasSelect)
1488 const bool isDeclaration)
1493 "If isDeclaration is false, queueOnExit must be passed.");
1497 for(
int i = 0; i < nss.
count(); ++i)
1520 const bool initialAdvance,
1521 const bool queueEmptyOnEmpty)
1529 const bool initialAdvance,
1530 const bool queueEmptyOnEmpty)
1532 bool effectiveInitialAdvance = initialAdvance;
1541 if(effectiveInitialAdvance)
1544 effectiveInitialAdvance =
true;
1625 hasWrittenExpression =
false;
1902 effectiveInitialAdvance =
false;
1986 for(
int i = 0; i < len; ++i)
2018 if(!hasWrittenExpression && queueEmptyOnEmpty)
2042 hasWrittenExpression =
true;
2073 hasWrittenExpression =
true;
2121 error(QtXmlPatterns::tr(
"Element %1 cannot have a sequence constructor.")
2129 const bool initialAdvance)
2133 bool effectiveInitialAdvance = initialAdvance;
2134 bool hasQueuedParam =
false;
2138 if(effectiveInitialAdvance)
2141 effectiveInitialAdvance =
true;
2156 hasQueuedParam =
true;
2188 bool hasQueuedParam =
false;
2207 error(QtXmlPatterns::tr(
"The attribute %1 cannot appear on %2, when it is a child of %3.")
2216 error(QtXmlPatterns::tr(
"The attribute %1 cannot appear on %2, when it is a child of %3.")
2231 error(QtXmlPatterns::tr(
"A parameter in a function cannot be declared to be a tunnel."),
2238 hasQueuedParam =
true;
2261 bool hasContent =
false;
2380 error(QtXmlPatterns::tr(
"This processor is not Schema-aware and " 2437 error(QtXmlPatterns::tr(
"Top level stylesheet elements must be " 2481 else if(value == isFalse)
2485 error(QtXmlPatterns::tr(
"The value for attribute %1 on element %2 must either " 2503 return alternatives[value];
2505 error(QtXmlPatterns::tr(
"Attribute %1 cannot have the value %2.")
2519 const bool speciallyTreatWhitespace)
2524 bool hasQueuedOneSort =
false;
2555 if(hasQueuedOneSort)
2561 if(hasQueuedOneSort)
2563 error(QtXmlPatterns::tr(
"The attribute %1 can only appear on " 2573 if(!hasQueuedOneSort)
2583 const int before = to->
count();
2608 if(before == to->
count())
2635 hasQueuedOneSort =
true;
2660 if(oneSortRequired && !hasQueuedOneSort)
2662 error(QtXmlPatterns::tr(
"At least one %1 element must appear as child of %2.")
2691 if(!expectedType.
isNull())
Error error() const
Returns the type of the current error, or NoError if no error occurred.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void warning(const QString &message) const
Convenience function for calling ReportContext::warning().
QString toString() const
Returns a copy of the string reference as a QString object.
void queueOnExit(QStack< Token > &source, TokenSource::Queue *const destination)
Sends the tokens in source to destination.
virtual bool isAnyAttributeAllowed() const
Returns true, if any attribute is allowed on the element currently being validated.
bool insideSequenceConstructor(TokenSource::Queue *const to, const bool initialAdvance=true, const bool queueEmptyOnEmpty=true)
TokenSource::Queue m_tokenSource
void insideAttributeSet()
QString Q_AUTOTEST_EXPORT escape(const QString &input)
Similar to Qt::escape(), but also escapes apostrophes and quotes, such that the result is suitable as...
#define QT_END_NAMESPACE
This macro expands to.
Represents a declared variable. Only used at the compilation stage.
static AtomicValue::Ptr fromLexical(const QString &strNumeric)
const QChar at(int i) const
Returns the character at the given index position in the string.
qint64 lineNumber() const
Returns the current line number, starting with 1.
QString formatKeyword(const QString &keyword)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
virtual int commenceScanOnly()
void queueSimpleContentConstructor(const ReportContext::ErrorCode code, const bool emptynessAllowed, TokenSource::Queue *const to, const bool selectOnlyFirst=false)
QXmlStreamAttributes m_currentAttributes
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
#define at(className, varName)
const Tokenizer::Token m_token
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
virtual Tokenizer::Token nextToken(YYLTYPE *const sourceLocator)
QStringRef value() const
Returns the attribute's value.
bool isEndElement() const
Returns true if tokenType() equals EndElement ; otherwise returns false.
void queueWithParams(const NodeName parentName, TokenSource::Queue *const to, const bool initialAdvance=true)
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
void startStorageOfCurrent(TokenSource::Queue *const to)
void handleStandardAttributes(const bool isXSLTElement)
Handles xml:space and standard attributes.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QStringRef name() const
Returns the local name of a StartElement, EndElement, or an EntityReference.
int count(const T &t) const
Returns the number of occurrences of value in the list.
QStack< bool > m_stripWhitespace
const NamePool::Ptr m_namePool
static ElementDescription< XSLTTokenLookup >::Hash createElementDescriptions()
int readAlternativeAttribute(const QHash< QString, int > &alternatives, const QXmlStreamAttribute &attr) const
bool atEnd() const
Returns true if the reader has read until the end of the XML document, or if an error() has occurred ...
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
void handleXSLTVersion(TokenSource::Queue *const to, QStack< Token > *const queueOnExit, const bool isXSLTElement, const QXmlStreamAttributes *atts=0, const bool generateCode=true, const bool setGlobalVersion=false)
The QHash class is a template class that provides a hash-table-based dictionary.
XSLTTokenizer(QIODevice *const queryDevice, const QUrl &location, const ReportContext::Ptr &context, const NamePool::Ptr &np)
bool hasAttribute(const QString &namespaceURI, const QString &localName) const
Returns true if the current element has an attribute whose name is namespaceURI and local name is loc...
void outsideDocumentElement()
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
QStringRef qualifiedName() const
Returns the attribute's qualified name.
void validateElement() const
bool hasAttribute(const QString &qualifiedName) const
void endStorageOfCurrent(TokenSource::Queue *const to)
void reserve(int size)
Ensures that the QHash's internal hash table consists of at least size buckets.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
void queueParams(const NodeName parentName, TokenSource::Queue *const to)
QStringRef value(const QString &namespaceUri, const QString &name) const
Returns the value of the attribute name in the namespace described with namespaceUri, or an empty string reference if the attribute is not defined.
const QLatin1String XSLT("http://www.w3.org/1999/XSL/Transform")
T pop()
Removes the top item from the stack and returns it.
The QXmlStreamAttribute class represents a single XML attribute.
QStringRef namespaceUri() const
Returns the namespaceUri of a StartElement or EndElement.
void queueToken(const Token &token, TokenSource::Queue *const ts)
void insideStylesheetModule()
TokenType tokenType() const
Returns the type of the current token.
#define QT_BEGIN_NAMESPACE
This macro expands to.
A TokenSource which contains one Tokenizer::Token.
bool isStylesheetElement() const
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void queueSorting(const bool oneSortRequired, TokenSource::Queue *const to, const bool speciallyTreatWhitespace=false)
bool hasError() const
Returns true if an error has occurred, otherwise false.
void queueTextConstructor(QString &chars, bool &hasWrittenExpression, TokenSource::Queue *const to)
const QLatin1String XML("http://www.w3.org/XML/1998/namespace")
The QStringList class provides a list of strings.
void validateElement(const LookupKey name) const
The namespace for the internal API of QtXmlPatterns.
bool isEmpty() const
Returns true if the string reference has no characters; otherwise returns false.
void queueNamespaceDeclarations(TokenSource::Queue *const ts, QStack< Token > *const target, const bool isDeclaration=false)
const_iterator insert(const T &value)
virtual Token nextToken(YYLTYPE *const sourceLocator)
QStack< ProcessMode > m_processingMode
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
T & head()
Returns a reference to the queue's head item.
A hand-written tokenizer which tokenizes XQuery 1.0 & XPath 2.0, and delivers tokens to the Bison gen...
QStringRef namespaceUri() const
Returns the namespaceUri.
bool skipSubTree(const bool exitOnContent=false)
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
QStringRef prefix() const
Returns the prefix.
void queueSequenceType(const QString &expr)
bool queueSelectOrSequenceConstructor(const ReportContext::ErrorCode code, const bool emptynessAllowed, TokenSource::Queue *const to, const QXmlStreamAttributes *const atts=0, const bool queueEmptyOnEmpty=true)
void handleXMLBase(TokenSource::Queue *const to, QStack< Token > *const queueOnExit, const bool isInstruction=true, const QXmlStreamAttributes *atts=0)
Generates code for reflecting xml:base attributes.
void parseFallbacksOnly()
QStringRef name() const
Returns the attribute's local name.
YYLTYPE currentSourceLocator() const
The State element defines configurations of objects and properties.
static QString formatData(const QString &data)
void hasWrittenExpression(bool &beacon)
Base class for tokenizers that reads XML formats. This is XSLTTokenizer, and the W3C XML Schema parse...
void checkForParseError() const
const QHash< QString, int > m_validationAlternatives
void push(const T &t)
Adds element t to the top of the stack.
void queueVariableDeclaration(const VariableType variableType, TokenSource::Queue *const to)
void queueAVT(const QString &expr, TokenSource::Queue *const to)
void insideChoose(TokenSource::Queue *const to)
The QStringRef class provides a thin wrapper around QString substrings.
const T & at(int i) const
Returns the item at index position i in the vector.
QStringRef qualifiedName() const
Returns the qualified name of a StartElement or EndElement;.
The QXmlStreamNamespaceDeclaration class represents a namespace declaration.
bool isNull() const
Returns true if this string is null; otherwise returns false.
QString readElementText()
XSLTTokenLookup ::NodeName currentElementName() const
void enqueue(const T &t)
Adds value t to the tail of the queue.
#define Q_ASSERT_X(cond, where, what)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Contains functions used for formatting arguments, such as keywords and paths, in translated strings...
Contains data related to a template.
Base class for all numeric values.
void pushState(const State nextState)
virtual void setCompatModeEnabled(const bool newVal)=0
The QXmlStreamAttributes class represents a vector of QXmlStreamAttribute.
void clear()
Clears the contents of the string and makes it empty.
static QHash< QString, int > createValidationAlternatives()
bool m_hasHandledStandardAttributes
qint64 columnNumber() const
Returns the current column number, starting with 0.
static QTestResult::TestLocation location
void handleValidationAttributes(const bool isLRE) const
bool whitespaceToSkip() const
QStringRef prefix() const
Returns the attribute's namespace prefix.
QXmlStreamNamespaceDeclarations namespaceDeclarations() const
If the state() is StartElement , this function returns the element's namespace declarations.
const StaticContext::Ptr staticContext
virtual void resumeTokenizationFrom(const int position)
static QString toString(NodeName token)
QString readAttribute(const QString &localName, const QString &namespaceURI=QString()) const
Returns the value for attribute by name name.
static const AtomicType::Ptr xsDecimal
bool isWhitespace() const
QSet< typename TokenLookupClass::NodeName > requiredAttributes
int count(const Key &key) const
Returns the number of items associated with the key.
void queueExpression(const QString &expr, TokenSource::Queue *const to, const bool wrapWithParantheses=true)
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Carries meta data for xsl:with-param as encountered in template callsites such as xsl:call-template a...
QSet< typename TokenLookupClass::NodeName > optionalAttributes
A structure that lists the optional and required attributes of an element. Used with MaintainingReade...
void commencingExpression(bool &hasWrittenExpression, TokenSource::Queue *const to)
bool isNull() const
Returns true if string() returns a null pointer or a pointer to a null string; otherwise returns true...
T dequeue()
Removes the head item in the queue and returns it.
QStringRef text() const
Returns the text of Characters , Comment , DTD , or EntityReference.
QString errorString() const
Returns the error message that was set with raiseError().
Base class for all tokenizers.
The QIODevice class is the base interface class of all I/O devices in Qt.
bool readToggleAttribute(const QString &attributeName, const QString &isTrue, const QString &isFalse, const QXmlStreamAttributes *const atts=0) const
const QUrl & queryURI() const
void skipBodyOfParam(const ReportContext::ErrorCode code)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
ParserContext::Ptr m_parseInfo
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QXmlStreamAttributes attributes() const
Returns the attributes of a StartElement.
bool attributeYesNo(const QString &localName) const
static NodeName toToken(const QString &value)
virtual void setParserContext(const ParserContext::Ptr &parseInfo)
bool isElement(const NodeName &name) const
static QSet< NodeName > createStandardAttributes()
void queueEmptySequence(TokenSource::Queue *const to)
Implements xsl:call-template.
T & top()
Returns a reference to the stack's top item.
QStack< bool > isBackwardsCompat
void unexpectedContent(const ReportContext::ErrorCode code=ReportContext::XTSE0010) const
QStringRef namespaceUri() const
Returns the attribute's resolved namespaceUri, or an empty string reference if the attribute does not...