Qt 4.8
Protected Functions | List of all members
QPatternist::XSLT20CoreFunctions Class Reference

Handles the functions defines in XSL-T 2.0, except those also available in XPath 2.0. More...

#include <qxslt20corefunctions_p.h>

Inheritance diagram for QPatternist::XSLT20CoreFunctions:
QPatternist::AbstractFunctionFactory QPatternist::FunctionFactory QSharedData

Protected Functions

virtual Expression::Ptr retrieveExpression (const QXmlName name, const Expression::List &args, const FunctionSignature::Ptr &sign) const
 
virtual FunctionSignature::Ptr retrieveFunctionSignature (const NamePool::Ptr &np, const QXmlName name)
 
- Protected Functions inherited from QPatternist::AbstractFunctionFactory
FunctionSignature::Ptr addFunction (const QXmlName::LocalNameCode localName, const FunctionSignature::Arity minArgs, const FunctionSignature::Arity maxArgs, const SequenceType::Ptr &returnType, const Expression::Properties props)
 
FunctionSignature::Ptr addFunction (const QXmlName::LocalNameCode &localName, const FunctionSignature::Arity minArgs, const FunctionSignature::Arity maxArgs, const SequenceType::Ptr &returnType, const Expression::ID id=Expression::IDIgnorableExpression, const Expression::Properties props=Expression::Properties(), const StandardNamespaces::ID ns=StandardNamespaces::fn)
 
- Protected Functions inherited from QPatternist::FunctionFactory
 FunctionFactory ()
 This constructor cannot be removed, because it can't be synthesized, for some reason. More...
 

Additional Inherited Members

- Public Types inherited from QPatternist::FunctionFactory
typedef QList< FunctionFactory::PtrList
 
typedef QExplicitlySharedDataPointer< FunctionFactoryPtr
 
- Public Functions inherited from QPatternist::AbstractFunctionFactory
virtual Expression::Ptr createFunctionCall (const QXmlName name, const Expression::List &arguments, const StaticContext::Ptr &context, const SourceLocationReflection *const r)
 
virtual FunctionSignature::Hash functionSignatures () const
 
- Public Functions inherited from QPatternist::FunctionFactory
bool hasSignature (const FunctionSignature::Ptr &signature) const
 
virtual bool isAvailable (const NamePool::Ptr &np, const QXmlName name, const xsInteger arity)
 
virtual ~FunctionFactory ()
 
- 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 Variables inherited from QSharedData
QAtomicInt ref
 
- Static Protected Functions inherited from QPatternist::AbstractFunctionFactory
static QXmlName::LocalNameCode argument (const NamePool::Ptr &np, const char *const name)
 
- Protected Variables inherited from QPatternist::AbstractFunctionFactory
FunctionSignature::Hash m_signatures
 

Detailed Description

Handles the functions defines in XSL-T 2.0, except those also available in XPath 2.0.

Note
XPath20CoreFunctions inherits from XPath10CoreFunctions only for implementation reasons, it does not supply the functions in the XPath10CoreFunctions factory.
See also
XQuery 1.0 and XPath 2.0 Functions and Operators
XML Path Language (XPath) Version 1.0, 4 Core Function Library
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com
Since
4.5

Definition at line 78 of file qxslt20corefunctions_p.h.

Functions

◆ retrieveExpression()

Expression::Ptr XSLT20CoreFunctions::retrieveExpression ( const QXmlName  name,
const Expression::List args,
const FunctionSignature::Ptr sign 
) const
protectedvirtual

This function is responsible for creating the actual Expression, corresponding to localName and the function signature sign. It is called by createFunctionCall(), once it have been determined the function actually exists and have the correct arity.

This function will only be called for names in the fn namespace.

Implements QPatternist::AbstractFunctionFactory.

Definition at line 63 of file qxslt20corefunctions.cpp.

66 {
67  Q_ASSERT(sign);
68 
69  Expression::Ptr fn;
70 #define testXSLTFN(ln, cname) else if(lname.localName() == StandardLocalNames::ln) fn = Expression::Ptr(new cname())
71 
72  if(false) /* Dummy for the macro handling. Will be optimized away anyway. */
73  return Expression::Ptr();
74  /* Alphabetic order. */
75  testXSLTFN(current, CurrentFN);
76  testXSLTFN(document, DocumentFN);
77  testXSLTFN(element_available, ElementAvailableFN);
78  testXSLTFN(function_available, FunctionAvailableFN);
79  testXSLTFN(generate_id, GenerateIDFN);
80  testXSLTFN(system_property, SystemPropertyFN);
81  testXSLTFN(type_available, TypeAvailableFN);
82  testXSLTFN(unparsed_entity_public_id, UnparsedEntityPublicIDFN);
83  testXSLTFN(unparsed_entity_uri, UnparsedEntityURIFN);
84  testXSLTFN(unparsed_text_available, UnparsedTextAvailableFN);
85  testXSLTFN(unparsed_text, UnparsedTextFN);
86 #undef testXSLTFN
87 
88  Q_ASSERT(fn);
89  fn->setOperands(args);
90  fn->as<FunctionCall>()->setSignature(sign);
91 
92  return fn;
93 }
Base class for implementations of builtin functions.
Implements XSL-T&#39;s function fn:current().
Definition: qcurrentfn_p.h:71
virtual void setOperands(const Expression::List &operands)=0
Implements XSL-T 2.0&#39;s XPath function fn:unparsed-entity-uri().
Implements the function fn:generate-id().
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Implements the function fn:unparsed-text().
const TCastTarget * as() const
Implements XSL-T 2.0&#39;s XPath function fn:system-property().
Implements XSL-T 2.0&#39;s XPath function fn:type-available().
Implements XSL-T 2.0&#39;s XPath function fn:function-available().
Implements XSL-T&#39;s function fn:document().
Implements XSL-T 2.0&#39;s XPath function fn:unparsed-entity-public-id().
#define testXSLTFN(ln, cname)
QExplicitlySharedDataPointer< Expression > Ptr
A smart pointer wrapping mutable Expression instances.
Implements the function fn:unparsed-text().
Implements the function fn:unparsed-text-available().

◆ retrieveFunctionSignature()

FunctionSignature::Ptr XSLT20CoreFunctions::retrieveFunctionSignature ( const NamePool::Ptr np,
const QXmlName  name 
)
protectedvirtual

This is a convenience function for sub-classes. It retrieves the function signature for function with name name.

According to the specifications are function signatures identified by their name and arity, but currently is the arity not part of the signature.

If no function could be found for the given name, null is returned.

Implements QPatternist::FunctionFactory.

Definition at line 95 of file qxslt20corefunctions.cpp.

96 {
98  return FunctionSignature::Ptr();
99 
101 
102  if(!s)
103  {
104  /* Alphabetic order. */
106  {
108  s->appendArgument(argument(np, "element-name"), CommonSequenceTypes::ExactlyOneString);
109  }
111  {
113  s->appendArgument(argument(np, "function_name"), CommonSequenceTypes::ExactlyOneString);
114  s->appendArgument(argument(np, "arity"), CommonSequenceTypes::ExactlyOneInteger);
115  }
117  {
119  s->appendArgument(argument(np, "type_name"), CommonSequenceTypes::ExactlyOneString);
120  }
122  {
124  s->appendArgument(argument(np, "property_name"), CommonSequenceTypes::ExactlyOneString);
125  }
126  else if(name.localName() == StandardLocalNames::generate_id)
127  {
130  s->appendArgument(argument(np, "node"), CommonSequenceTypes::ZeroOrOneNode);
131  }
133  {
136  s->appendArgument(argument(np, "href"), CommonSequenceTypes::ZeroOrOneString);
137  s->appendArgument(argument(np, "encoding"), CommonSequenceTypes::ExactlyOneString);
138  }
140  {
143  s->appendArgument(argument(np, "href"), CommonSequenceTypes::ZeroOrOneString);
144  s->appendArgument(argument(np, "encoding"), CommonSequenceTypes::ZeroOrOneString);
145  }
146  else if(name.localName() == StandardLocalNames::current)
147  {
150  }
151  else if(name.localName() == StandardLocalNames::document)
152  {
155  s->appendArgument(argument(np, "uri-sequence"), CommonSequenceTypes::ZeroOrMoreStrings);
156  s->appendArgument(argument(np, "base-uri-node"), CommonSequenceTypes::ExactlyOneNode);
157  }
159  {
162  s->appendArgument(argument(np, "entity-name"), CommonSequenceTypes::ExactlyOneString);
163  }
165  {
168  s->appendArgument(argument(np, "entity-name"), CommonSequenceTypes::ExactlyOneString);
169  }
170  }
171 
172  return s;
173 }
static const SequenceType::Ptr ZeroOrOneNode
static QXmlName::LocalNameCode argument(const NamePool::Ptr &np, const char *const name)
static const SequenceType::Ptr ExactlyOneString
FunctionSignature::Ptr addFunction(const QXmlName::LocalNameCode localName, const FunctionSignature::Arity minArgs, const FunctionSignature::Arity maxArgs, const SequenceType::Ptr &returnType, const Expression::Properties props)
static const SequenceType::Ptr ZeroOrOneString
static const SequenceType::Ptr OneOrMoreDocumentNodes
static const SequenceType::Ptr ExactlyOneInteger
virtual FunctionSignature::Hash functionSignatures() const
static const SequenceType::Ptr ExactlyOneAnyURI
QString localName(const QXmlNamePool &query) const
Returns the local name.
Definition: qxmlname.cpp:387
static const SequenceType::Ptr ExactlyOneBoolean
NamespaceCode namespaceURI() const
Definition: qnamepool_p.h:503
static const SequenceType::Ptr ExactlyOneItem
static const SequenceType::Ptr ZeroOrMoreStrings
static const SequenceType::Ptr ExactlyOneNode

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