item_factory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2008 The FLWOR 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 
17 #ifndef ZORBA_ITEM_FACTORY_API_H
18 #define ZORBA_ITEM_FACTORY_API_H
19 
20 #include <iostream>
21 #include <vector>
22 
23 #include <zorba/config.h>
24 #include <zorba/api_shared_types.h>
25 #include <zorba/item.h>
26 #include <zorba/streams.h>
27 
28 namespace zorba {
29 
30  /** \brief ItemFactory to create Items.
31  *
32  * An instance of this class can be obtained by calling getItemFactory on the Zorba object.
33  *
34  * Each createXXX function of this class creates an Item of an XML Schema item.
35  * If an isNull() call on an Item created by one of these functions returns true the
36  * Item could not be created.
37  */
38  class ZORBA_DLL_PUBLIC ItemFactory
39  {
40  public:
41  /** \brief Destructor
42  */
43  virtual ~ItemFactory() {}
44 
45  /** \brief Creates a String Item
46  * see [http://www.w3.org/TR/xmlschema-2/#string]
47  *
48  * @param aString String representation of the String Item.
49  * @return The String Item
50  */
51  virtual Item
52  createString(const String& aString) = 0;
53 
54  /** \brief Creates a streamable String Item
55  * see [http://www.w3.org/TR/xmlschema-2/#string]
56  *
57  * @param stream An istream from where to read the string's content.
58  * @param streamReleaser A function pointer which is invoked once
59  * the StreamableStringItem is destroyed. Normally this function
60  * will delete the std::istream object passed to it.
61  * @param seekable
62  * @return The streamable String Item
63  */
64  virtual Item
65  createStreamableString( std::istream &stream,
66  StreamReleaser streamReleaser,
67  bool seekable = false ) = 0;
68 
69  /** \brief Creates a streamable String Item
70  * see [http://www.w3.org/TR/xmlschema-2/#string]
71  *
72  * @param stream An istream from where to read the string's content.
73  * @param streamReleaser A function pointer which is invoked once
74  * the StreamableStringItem is destroyed. Normally this function
75  * will delete the std::istream object passed to it.
76  * @param uri The URI is intended to be used to note the origination URI
77  * (e.g., file) that data is coming from.
78  * @param seekable
79  * @return The streamable String Item
80  */
81  virtual Item
82  createStreamableString( std::istream &stream,
83  StreamReleaser streamReleaser,
84  char const *uri,
85  bool seekable = false ) = 0;
86 
87  /** \brief Creates an AnyURI Item
88  * see [http://www.w3.org/TR/xmlschema-2/#anyURI]
89  *
90  * @param aURI String representation of the AnyURI.
91  * @return The AnyURI Item.
92  */
93  virtual Item
94  createAnyURI(const String& aURI) = 0;
95 
96  /** \brief Creates a QName Item
97  * see [http://www.w3.org/TR/xmlschema-2/#QName]
98  *
99  * @param aNamespace String representation of the namespace.
100  * @param aPrefix String representation of the prefix.
101  * @param aLocalname String representation of the localname.
102  *
103  * @return The QName Item.
104  */
105  virtual Item
106  createQName(const String& aNamespace, const String& aPrefix,
107  const String& aLocalname) = 0;
108 
109  /** \brief Creates a QName Item
110  * see [http://www.w3.org/TR/xmlschema-2/#QName]
111  *
112  * @param aNamespace String representation of the namespace.
113  * @param aLocalname String representation of the localname. *
114  * @return The QName Item.
115  */
116  virtual Item
117  createQName(const String& aNamespace, const String& aLocalname) = 0;
118 
119  /** \brief Creates a QName Item
120  * see [http://www.w3.org/TR/xmlschema-2/#QName]
121  *
122  * The QName is constructed by parsing the string using the notation
123  * invented by James Clark (i.e. {namespace}localname).
124  *
125  * @param aQNameString String in the QName notation by James Clark.
126  * @return The QName Item.
127  */
128  virtual Item
129  createQName(const String& aQNameString) = 0;
130 
131  /** \brief Creates a NCName Item
132  * see [http://www.w3.org/TR/xmlschema-2/#NCName]
133  *
134  * @param aValue String representation of the NCName.
135  * @return The NCName Item.
136  */
137  virtual Item
138  createNCName(const String& aValue) = 0;
139 
140 
141  /** \brief Creates a Base64Binary Item
142  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
143  *
144  * @param aBinData a pointer to the base64 encoded data. The data is copied from aBinData.
145  * @param aLength the length of the base64 encoded data.
146  * @return The Base64Binary Item.
147  */
148  virtual Item
149  createBase64Binary(const char* aBinData, size_t aLength) = 0;
150 
151  /** \brief Creates a Base64Binary Item
152  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
153  *
154  * @param aStream A stream containing the Base64 encoded data. The data is copied from aStream imediately.
155  * @return the Base64Binary Item.
156  */
157  virtual Item
158  createBase64Binary(std::istream& aStream) = 0;
159 
160  /** \brief Creates a Base64Binary Item
161  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
162  *
163  * @param aBinData the data in binary form (not encoded). The data is copied from aBinData.
164  * @param aLength the length of the binary data
165  * @return the Base64Binary Item.
166  */
167  virtual Item
168  createBase64Binary(const unsigned char* aBinData, size_t aLength) = 0;
169 
170  /** \brief Creates a streamable Base64Binary Item
171  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
172  *
173  * @param stream An istream from where to read the binary's content.
174  * @param streamReleaser A function pointer which is invoked once
175  * the StreamableBase64Binary is destroyed. Normally this function
176  * will delete the std::istream object passed to it.
177  * @param seekable is the given stream seekable
178  * @param encoded is the contents of the given stream already base64
179  * encoded
180  * @return The streamable String Item
181  */
182  virtual Item
183  createStreamableBase64Binary(
184  std::istream &stream,
185  StreamReleaser streamReleaser,
186  bool seekable = false,
187  bool encoded = false) = 0;
188 
189  /** \brief Creates a streamable Base64Binary Item
190  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
191  *
192  * @param stream An istream from where to read the binary's content.
193  * @param streamReleaser A function pointer which is invoked once
194  * the StreamableBase64Binary is destroyed. Normally this function
195  * will delete the std::istream object passed to it.
196  * @param uri The URI is intended to be used to note the origination URI
197  * (e.g., file) that data is coming from.
198  * @param seekable is the given stream seekable
199  * @param encoded is the contents of the given stream already base64
200  * encoded
201  * @return The streamable String Item
202  */
203  virtual Item
204  createStreamableBase64Binary(
205  std::istream &stream,
206  StreamReleaser streamReleaser,
207  char const *uri,
208  bool seekable = false,
209  bool encoded = false) = 0;
210 
211  /** \brief Creates a Boolean Item
212  * see [http://www.w3.org/TR/xmlschema-2/#bool]
213  *
214  * @param aValue bool representation of the Boolean.
215  * @return The Boolean Item.
216  */
217  virtual Item
218  createBoolean(bool aValue) = 0;
219 
220  /** \brief Creates a Decimal Item
221  * see [http://www.w3.org/TR/xmlschema-2/#decimal]
222  *
223  * @param aValue unsigned long representation of the Decimal.
224  * @return The Decimal Item.
225  */
226  virtual Item
227  createDecimalFromLong (unsigned long aValue) = 0;
228 
229  /** \brief Creates a Decimal Item
230  * see [http://www.w3.org/TR/xmlschema-2/#decimal]
231  *
232  * @param aValue double representation of the Decimal.
233  * @return The Decimal Item.
234  */
235  virtual Item
236  createDecimalFromDouble (double aValue) = 0;
237 
238  /** \brief Creates a Decimal Item
239  * see [http://www.w3.org/TR/xmlschema-2/#decimal]
240  *
241  * @param aValue String representation of the Decimal (e.g. 12678967.543233).
242  * @return The Decimal Item.
243  */
244  virtual Item
245  createDecimal (const String& aValue) = 0;
246 
247  /** \brief Creates an Integer Item
248  * see [http://www.w3.org/TR/xmlschema-2/#integer]
249  *
250  * @param aInteger unsigned long representation of the Integer.
251  * @return The Integer Item.
252  */
253  virtual Item
254  createInteger(long long aInteger) = 0;
255 
256  /** \brief Creates an Integer Item
257  * see [http://www.w3.org/TR/xmlschema-2/#integer]
258  *
259  * @param aInteger String representation of the Integer.
260  * @return The Integer Item.
261  */
262  virtual Item
263  createInteger(const String& aInteger) = 0;
264 
265  /** \brief Creates a Long Item
266  * see [http://www.w3.org/TR/xmlschema-2/#long]
267  *
268  * @param aLong long long representation of the Long.
269  * @return The Long Item.
270  */
271  virtual Item
272  createLong ( long long aLong ) = 0;
273 
274  /** \brief Creates a Int Item
275  * see [http://www.w3.org/TR/xmlschema-2/#int]
276  *
277  * @param aInt int representation of the Int.
278  * @return The NCName Item.
279  */
280  virtual Item
281  createInt ( int aInt ) = 0;
282 
283  /** \brief Creates a Short Item
284  * see [http://www.w3.org/TR/xmlschema-2/#short]
285  *
286  * @param aShort short representation of the Short.
287  * @return The Short Item.
288  */
289  virtual Item
290  createShort ( short aShort ) = 0;
291 
292  /** \brief Creates a Byte Item
293  * see [http://www.w3.org/TR/xmlschema-2/#byte]
294  *
295  * @param aByte char representation of the Byte.
296  * @return The Byte Item.
297  */
298  virtual Item
299  createByte ( char aByte ) = 0;
300 
301  /** \brief Creates a Date Item
302  * see [http://www.w3.org/TR/xmlschema-2/#date]
303  *
304  * @param aDate String representation of the Date (e.g. 2002-10-10).
305  * @return The Date Item.
306  */
307  virtual Item
308  createDate ( const String& aDate ) = 0;
309 
310  /** \brief Creates a Date Item
311  * see [http://www.w3.org/TR/xmlschema-2/#date]
312  *
313  * @param aYear short-valued representation of the year.
314  * @param aMonth short-valued representation of the month.
315  * @param aDay short-valued representation of the day.
316  * @return The Date Item.
317  */
318  virtual Item
319  createDate ( short aYear, short aMonth, short aDay ) = 0;
320 
321  /** \brief Creates a DateTime Item
322  * see [http://www.w3.org/TR/xmlschema-2/#dateTime]
323  *
324  * @param aYear short-valued representation of the year.
325  * @param aMonth short-valued representation of the month.
326  * @param aDay short-valued representation of the day.
327  * @param aHour short-valued representation of the hour.
328  * @param aMinute short-valued representation of the minute.
329  * @param aSecond double-valued representation of the seconds and fractional seconds.
330  * @param aTimeZone_hours short-valued representation of the difference in hours to UTC.
331  * @return The DateTime Item.
332  */
333  virtual Item
334  createDateTime(short aYear, short aMonth, short aDay,
335  short aHour, short aMinute, double aSecond,
336  short aTimeZone_hours) = 0;
337 
338  /** \brief Creates a DateTime Item without setting a time zone.
339  * see [http://www.w3.org/TR/xmlschema-2/#dateTime]
340  *
341  * @param aYear short-valued representation of the year.
342  * @param aMonth short-valued representation of the month.
343  * @param aDay short-valued representation of the day.
344  * @param aHour short-valued representation of the hour.
345  * @param aMinute short-valued representation of the minute.
346  * @param aSecond double-valued representation of the seconds and fractional seconds.
347  * @return The DateTime Item.
348  */
349  virtual Item
350  createDateTime(short aYear, short aMonth, short aDay,
351  short aHour, short aMinute, double aSecond) = 0;
352 
353  /** \brief Creates a DateTime Item
354  * see [http://www.w3.org/TR/xmlschema-2/#dateTime]
355  *
356  * @param aDateTimeValue String representation of the datetime value
357  * (for example, 2002-10-10T12:00:00-05:00).
358  * @return The DateTime Item.
359  */
360  virtual Item
361  createDateTime( const String& aDateTimeValue ) = 0;
362 
363  /** \brief Creates a Double Item
364  * see [http://www.w3.org/TR/xmlschema-2/#double]
365  *
366  * @param aValue double representation of the Double.
367  * @return The Double Item.
368  */
369  virtual Item
370  createDouble ( double aValue ) = 0;
371 
372  /** \brief Creates a Double Item
373  * see [http://www.w3.org/TR/xmlschema-2/#double]
374  *
375  * @param aValue String representation of the Double.
376  * @return The Double Item.
377  */
378  virtual Item
379  createDouble ( const String& aValue ) = 0;
380 
381  /** \brief Creates a Duration Item
382  * see [http://www.w3.org/TR/xmlschema-2/#duration]
383  *
384  * @param aValue String representation of the NCName.
385  * @return The Duration Item.
386  */
387  virtual Item
388  createDuration( const String& aValue ) = 0;
389 
390  /** \brief Creates a Duration Item
391  * see [http://www.w3.org/TR/xmlschema-2/#duration]
392  *
393  * @param aYear short-valued representation of the years.
394  * @param aMonths short-valued representation of the months.
395  * @param aDays short-valued representation of the days.
396  * @param aHours short-valued representation of the hours.
397  * @param aMinutes short-valued representation of the minutes.
398  * @param aSeconds double-valued representation of the seconds and fractional seconds.
399  * @return The Duration Item.
400  */
401  virtual Item
402  createDuration ( short aYear, short aMonths, short aDays,
403  short aHours, short aMinutes, double aSeconds ) = 0;
404 
405  /** \brief Creates a dayTimeDuration Item
406  * see [http://www.w3.org/TR/xpath-functions/#duration-subtypes]
407  *
408  * @param aValue String lexical representation of the duration.
409  * @return the dayTimeDuration Item.
410  */
411  virtual Item
412  createDayTimeDuration( const String& aValue ) = 0;
413 
414  /** \brief Creates a yearMonthDuration Item
415  * see [http://www.w3.org/TR/xpath-functions/#duration-subtypes]
416  *
417  * @param aValue String lexical representation of the duration.
418  * @return the yearMonthDuration Item.
419  */
420  virtual Item
421  createYearMonthDuration( const String& aValue ) = 0;
422 
423  /** \brief Creates a documentNode Item
424  * see [http://www.w3.org/TR/xpath-functions/#duration-subtypes]
425  *
426  * @param aBaseUri String representation of the Base URI.
427  * @param aDocUri String representation of the Document URI.
428  * @return the documentNode Item.
429  */
430  virtual Item
431  createDocumentNode( const String& aBaseUri, const String& aDocUri ) = 0;
432 
433  /** \brief creates a float item
434  * see [http://www.w3.org/tr/xmlschema-2/#float]
435  *
436  * @param aValue string representation of the float.
437  * @return the float item.
438  */
439  virtual Item
440  createFloat ( const String& aValue ) = 0;
441 
442  /** \brief creates a float item
443  * see [http://www.w3.org/tr/xmlschema-2/#float]
444  *
445  * @param aValue float representation of the float.
446  * @return the float item.
447  */
448  virtual Item
449  createFloat ( float aValue ) = 0;
450 
451  /** \brief Creates a gDay Item
452  * see [http://www.w3.org/TR/xmlschema-2/#gDay]
453  *
454  * @param aValue String representation of the gDay.
455  * @return The gDay Item.
456  */
457  virtual Item
458  createGDay ( const String& aValue ) = 0;
459 
460  /** \brief Creates a gDay Item
461  * see [http://www.w3.org/TR/xmlschema-2/#gDay]
462  *
463  * @param aDay short representation of the gDay.
464  * @return The gDay Item.
465  */
466  virtual Item
467  createGDay ( short aDay ) = 0;
468 
469  /** \brief Creates a gMonth Item
470  * see [http://www.w3.org/TR/xmlschema-2/#gMonth]
471  *
472  * @param aValue String representation of the gMonth.
473  * @return The gMonth Item.
474  */
475  virtual Item
476  createGMonth ( const String& aValue ) = 0;
477 
478  /** \brief Creates a gMonth Item
479  * see [http://www.w3.org/TR/xmlschema-2/#gMonth]
480  *
481  * @param aMonth short representation of the gMonth.
482  * @return The gMonth Item.
483  */
484  virtual Item
485  createGMonth ( short aMonth ) = 0;
486 
487  /** \brief Creates a gMonthDay Item
488  * see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
489  *
490  * @param aValue String representation of the gMonthDay.
491  * @return The gMonthDay Item.
492  */
493  virtual Item
494  createGMonthDay ( const String& aValue ) = 0;
495 
496  /** \brief Creates a gMonthDay Item
497  * see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
498  *
499  * @param aMonth short representation of the month.
500  * @param aDay short representation of the day.
501  * @return The gMonthDay Item.
502  */
503  virtual Item
504  createGMonthDay ( short aMonth, short aDay ) = 0;
505 
506  /** \brief Creates a gYear Item
507  * see [http://www.w3.org/TR/xmlschema-2/#gYear]
508  *
509  * @param aValue String representation of the gYear.
510  * @return The gYear Item.
511  */
512  virtual Item
513  createGYear ( const String& aValue ) = 0;
514 
515  /** \brief Creates a gYear Item
516  * see [http://www.w3.org/TR/xmlschema-2/#gYear]
517  *
518  * @param aYear short representation of the gYear.
519  * @return The gYear Item.
520  */
521  virtual Item
522  createGYear ( short aYear ) = 0;
523 
524  /** \brief Creates a gYearMonth Item
525  * see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
526  *
527  * @param aValue String representation of the gYearMonth.
528  * @return The gYearMonth Item.
529  */
530  virtual Item
531  createGYearMonth ( const String& aValue ) = 0;
532 
533  /** \brief Creates a gYearMonth Item
534  * see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
535  *
536  * @param aYear short representation of the year.
537  * @param aMonth short representation of the month.
538  * @return The gYearMonth Item.
539  */
540  virtual Item
541  createGYearMonth ( short aYear, short aMonth ) = 0;
542 
543  /** \brief Creates a HexBinary Item
544  * see [http://www.w3.org/TR/xmlschema-2/#hexBinary]
545  *
546  * @param aData pointer to the data.
547  * @param aSize size of the data in bytes.
548  * @param aIsEncoded if \c true, the \a aData is already HexBinary
549  * encoded.
550  * @return The HexBinary Item.
551  */
552  virtual Item
553  createHexBinary( const char* aData, size_t aSize,
554  bool aIsEncoded = true ) = 0;
555 
556  /** \brief Creates a negativeInteger Item
557  * see [http://www.w3.org/TR/xmlschema-2/#negativeInteger]
558  *
559  * @param aValue long long representation of the negativeInteger.
560  * @return The negativeInteger Item.
561  */
562  virtual Item
563  createNegativeInteger ( long long aValue ) = 0;
564 
565  /** \brief Creates a nonNegativeInteger Item
566  * see [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]
567  *
568  * @param aValue unsigned long representation of the nonNegativeInteger.
569  * @return The nonNegativeInteger Item.
570  */
571  virtual Item
572  createNonNegativeInteger ( unsigned long long aValue ) = 0;
573 
574  /** \brief Creates a nonPositiveInteger Item
575  * see [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
576  *
577  * @param aValue long long representation of the NCName.
578  * @return The nonPositiveInteger Item.
579  */
580  virtual Item
581  createNonPositiveInteger ( long long aValue ) = 0;
582 
583  /** \brief Creates a positiveInteger\ Item
584  * see [http://www.w3.org/TR/xmlschema-2/#positiveInteger]
585  *
586  * @param aValue unsigned long representation of the positiveInteger.
587  * @return The positiveInteger Item.
588  */
589  virtual Item
590  createPositiveInteger ( unsigned long long aValue ) = 0;
591 
592  /** \brief Creates a Time Item
593  * see [http://www.w3.org/TR/xmlschema-2/#time]
594  *
595  * @param aValue String representation of the Time.
596  * @return The Time Item
597  */
598  virtual Item
599  createTime ( const String& aValue ) = 0;
600 
601  /** \brief Creates a Time Item
602  * see [http://www.w3.org/TR/xmlschema-2/#time]
603  *
604  * @param aHour short representation of the hour.
605  * @param aMinute short representation of the minute.
606  * @param aSecond double representation of the seconds and fractional seconds.
607  * @return The Time Item.
608  */
609  virtual Item
610  createTime ( short aHour, short aMinute, double aSecond ) = 0;
611 
612  /** \brief Creates a Time Item
613  * see [http://www.w3.org/TR/xmlschema-2/#time]
614  *
615  * @param aHour short representation of the hour.
616  * @param aMinute short representation of the minute.
617  * @param aSecond double representation of the seconds and fractional seconds.
618  * @param aTimeZone_hours short representation of the timezone difference in hours to UTC.
619  * @return The Time Item.
620  */
621  virtual Item
622  createTime ( short aHour, short aMinute, double aSecond, short aTimeZone_hours ) = 0;
623 
624  /** \brief Creates an Unsigned Byte Item
625  * see [http://www.w3.org/TR/xmlschema-2/#unsignedByte]
626  *
627  * @param aValue unsignedByte unsigned char representation of the unsigned byte.
628  * @return The Unsigned Byte Item.
629  */
630  virtual Item
631  createUnsignedByte(const unsigned char aValue) = 0;
632 
633  /** \brief Creates an unsigned int Item
634  * see [http://www.w3.org/TR/xmlschema-2/#unsignedInt]
635  *
636  * @param aValue unsigned int representation of the unsignedInt.
637  * @return The unsignedInt Item.
638  */
639  virtual Item
640  createUnsignedInt(unsigned int aValue) = 0;
641 
642  /** \brief Creates an unsignedLong Item
643  * see [http://www.w3.org/TR/xmlschema-2/#unsignedLong]
644  *
645  * @param aValue unsignedLong long long representation of the unsignedLong.
646  * @return The unsignedLong Item.
647  */
648  virtual Item
649  createUnsignedLong(unsigned long long aValue) = 0;
650 
651  /** \brief Creates a unsignedShort Item
652  * see [http://www.w3.org/TR/xmlschema-2/#unsignedShort]
653  *
654  * @param aValue unsigned short representation of the unsignedShort.
655  * @return The unsignedShort Item.
656  */
657  virtual Item
658  createUnsignedShort(unsigned short aValue) = 0;
659 
660  /**
661  * @brief Creates a new element node.
662  *
663  * Create a new element node N and place it at the end among the
664  * children of a given parent node. If no parent is given, N becomes the
665  * root (and single node) of a new XML tree.
666  *
667  * @param aParent The parent P of the new node; may be NULL.
668  * @param aNodeName The fully qualified name of the new node.
669  * @param aTypeName The fully qualified name of the new node's type.
670  * Not allowed to be NULL, use xsd:untyped instead.
671  * @param aHasTypedValue Whether the node has a typed value or not (element
672  * nodes with complex type and element-only content do
673  * not have typed value).
674  * @param aHasEmptyValue True if the typed value of the node is the empty
675  * sequence. This is the case if the element has a
676  * complex type with empty content.
677  * @param aNsBindings A set of namespace bindings. The namespaces property
678  * of N will be the union of this set and the namespaces
679  * property of P.
680  * @return The new node N created by this method
681  */
682  virtual Item
683  createElementNode(Item& aParent,
684  Item aNodeName,
685  Item aTypeName,
686  bool aHasTypedValue,
687  bool aHasEmptyValue,
688  NsBindings aNsBindings) = 0;
689  /**
690  * Create a new attribute node N and place it among the
691  * attributes of a given parent node. If no parent is given, N becomes the
692  * root (and single node) of a new XML tree.
693  *
694  * @param aParent The parent P of the new node; may be NULL.
695  * @param aNodeName The fully qualified name of the new node. The nemaspace
696  * binding implied by this name will be added to the namespaces
697  * of P. If the name prefix is "xml" and the local name is
698  * "base", then the base-uri property of P will be set or
699  * updated accordingly.
700  * @param aTypeName The fully qualified name of the new node's type.
701  * @param aTypedValue The typed value of the new node.
702  * @return The new node N created by this method
703  */
704  virtual Item
705  createAttributeNode(Item aParent,
706  Item aNodeName,
707  Item aTypeName,
708  Item aTypedValue) = 0;
709 
710  virtual Item
711  createAttributeNode(Item aParent,
712  Item aNodeName,
713  Item aTypeName,
714  std::vector<Item> aTypedValue) = 0;
715 
716  /**
717  * Create a new comment node N and place it as the last child of a given
718  * parent node. If no parent is given, N becomes the root (and single node)
719  * of a new XML tree.
720  *
721  * @param aParent The parent P of the new node; may be NULL.
722  * @param aContent The content of the new node.
723  * @return The new node N created by this method
724  */
725  virtual Item createCommentNode (
726  Item aParent,
727  String &aContent) = 0;
728 
729  /**
730  * Create a new Processing Instruction node N and place it among the
731  * children of a given parent node. If no parent is given, N becomes the
732  * root (and single node) of a new XML tree.
733  *
734  * @param aParent The parent P of the new node; may be NULL.
735  * @param aTarget The Target of the new node.
736  * @param aContent The Content of the new node.
737  * @param aBaseUri The Base URI of the new node, may be NULL.
738  * @return The new node N created by this method
739  */
740  virtual Item createPiNode (
741  Item aParent,
742  String &aTarget,
743  String &aContent,
744  String &aBaseUri)=0;
745 
746  /**
747  * Create a new text node N and place it among the
748  * children of a given parent node. If no parent is given, N becomes the
749  * root (and single node) of a new XML tree.
750  *
751  * @param parent The parent P of the new node; may be NULL.
752  * @param content The content of the new node.
753  * @return The new node N created by this method
754  */
755  virtual Item createTextNode(
756  Item parent,
757  String content) = 0;
758 
759  /** \brief Creates a UntypedAtomic Item
760  *
761  * @param value String representation of the UntypedAtomic Item.
762  * @return The UntypedAtomic Item
763  */
764  virtual Item createUntypedAtomic(const String& value) = 0;
765 
766 #ifdef ZORBA_WITH_JSON
767 
768  /**
769  * Create a JSON null item.
770  */
771  virtual Item createJSONNull() = 0;
772 
773  /**
774  * Create a JSON Number item from a string. This will actually be
775  * an xs:integer, xs:double, or xs:decimal, depending on the content
776  * of the string.
777  *
778  * @param aString The input string.
779  */
780  virtual Item createJSONNumber(String aString) = 0;
781 
782  /**
783  * Create a JSON Object containing the specified JSON Pairs.
784  *
785  * @param aNames A vector containing the name and value of each pair.
786  */
787  virtual Item createJSONObject(std::vector<std::pair<Item, Item> >& aNames) = 0;
788 
789  /**
790  * Create a JSON Array containing the specified items.
791  *
792  * @param aItems A std::vector<Item> containing Items which may
793  * be stored in a JSON Array (namely JSON Arrays, JSON Objects,
794  * JSON nulls, valid JSON numeric types, or xs:strings).
795  */
796  virtual Item createJSONArray(std::vector<Item>& aItems) = 0;
797 
798 #endif /* ZORBA_WITH_JSON */
799 
800  /**
801  * @brief Assigns a simple typed value to an element node.
802  *
803  * Creates a simple typed value for an element. Note that this may only
804  * be done once per element. This method should only be used during
805  * creation of a new tree. Using this method to modify elements after
806  * processing has begun has undefined results.
807  *
808  *
809  * @param aElement The element for the typed value; may not be NULL.
810  * @param aTypedValue The typed value for the element.
811  */
812  virtual void
813  assignElementTypedValue(Item& aElement,
814  Item aTypedValue) = 0;
815  /**
816  * @brief Assigns a simple typed value to an element node.
817  *
818  * Creates a simple typed value for an element. Note that this may only
819  * be done once per element. This method should only be used during
820  * creation of a new tree. Using this method to modify elements after
821  * processing has begun has undefined results.
822  *
823  *
824  * @param aElement The element for the typed value; may not be NULL.
825  * @param aTypedValue The typed value for the element.
826  */
827  virtual void
828  assignElementTypedValue(Item& aElement,
829  std::vector<Item>& aTypedValue) = 0;
830 
831  /**
832  * Create an atomic item having a user-defined atomic type.
833  *
834  * @param aBaseItem the base item of the item to create.
835  * @param aTypeName the name of the type of the item to create.
836  *
837  * @return a new atomic item having the given user-defined atomic type.
838  */
839  virtual Item
840  createUserTypedAtomicItem(Item& aBaseItem, Item& aTypeName) = 0;
841 
842  /** \brief Creates a DateTimeStamp Item
843  * see [www.w3.org/TR/xmlschema11-2/#dateTimeStamp]
844  *
845  * @param aYear short-valued representation of the year.
846  * @param aMonth short-valued representation of the month.
847  * @param aDay short-valued representation of the day.
848  * @param aHour short-valued representation of the hour.
849  * @param aMinute short-valued representation of the minute.
850  * @param aSecond double-valued representation of the seconds and fractional seconds.
851  * @param aTimeZone_hours short-valued representation of the difference in hours to UTC.
852  * @return The DateTimeStamp Item.
853  */
854  virtual Item
855  createDateTimeStamp(short aYear, short aMonth, short aDay,
856  short aHour, short aMinute, double aSecond,
857  short aTimeZone_hours) = 0;
858 
859  /** \brief Creates a DateTimeStamp Item
860  * see [www.w3.org/TR/xmlschema11-2/#dateTimeStamp]
861  *
862  * @param aDateTimeStampValue String representation of the datetimeStamp value
863  * (for example, 2002-10-10T12:00:00-05:00).
864  * @return The DateTimeStamp Item.
865  */
866  virtual Item
867  createDateTimeStamp( const String& aDateTimeStampValue ) = 0;
868 
869  }; // class ItemFactory
870 
871 } // namespace zorba
872 #endif
873 /* vim:set et sw=2 ts=2: */
virtual ~ItemFactory()
Destructor.
Definition: item_factory.h:43
void(* StreamReleaser)(std::istream *)
Definition: streams.h:21
std::vector< std::pair< String, String > > NsBindings
Used for Item::getNamespaceBindings() and ItemFactory::createElementNode().
Definition: item.h:39
The Zorba Item interface.
Definition: item.h:60
The Zorba string class.
Definition: zorba_string.h:33
ItemFactory to create Items.
Definition: item_factory.h:38