Project

Profile

Help

How to connect?
Download (50.1 KB) Statistics
| Branch: | Tag: | Revision:

he / latest10 / hen / csource / api / Destination.cs @ 0fe3e66d

1
using System;
2
using System.IO;
3
using System.Xml;
4
using JConfiguration = net.sf.saxon.Configuration;
5
using JAttributeMap = net.sf.saxon.om.AttributeMap; 
6
using JPipelineConfiguration = net.sf.saxon.@event.PipelineConfiguration;
7
using JReceiver = net.sf.saxon.@event.Receiver;
8
using JProperties = java.util.Properties;
9
using JCharSequence = java.lang.CharSequence;
10
using JXPathException = net.sf.saxon.trans.XPathException;
11
using JCharacterMapIndex = net.sf.saxon.serialize.CharacterMapIndex;
12
using JSchemaType = net.sf.saxon.type.SchemaType;
13
using JLocation = net.sf.saxon.s9api.Location;
14
using JProxyReceiver = net.sf.saxon.@event.ProxyReceiver;
15
using JNodeName = net.sf.saxon.om.NodeName;
16
using JNamespaceMap = net.sf.saxon.om.NamespaceMap;
17
using JItem = net.sf.saxon.om.Item;
18
using JNodeInfo = net.sf.saxon.om.NodeInfo;
19
using JDotNetDomBuilder = net.sf.saxon.dotnet.DotNetDomBuilder;
20
using JDotNetOutputStream = net.sf.saxon.dotnet.DotNetOutputStream;
21
using JDotNetWriter = net.sf.saxon.dotnet.DotNetWriter;
22
using JDotNetReceiver = net.sf.saxon.dotnet.DotNetReceiver;
23
using JSerializationProperties = net.sf.saxon.serialize.SerializationProperties;
24
using JDestination = net.sf.saxon.s9api.Destination;
25
using JAbstractDestination = net.sf.saxon.s9api.AbstractDestination;
26
using JAction = net.sf.saxon.s9api.Action;
27
using java.net;
28
using net.sf.saxon.@event;
29
using net.sf.saxon.s9api;
30
using net.sf.saxon.serialize;
31

    
32
namespace Saxon.Api
33
{
34

    
35

    
36

    
37
    /// <summary>
38
    /// An abstract destination for the results of a query or transformation
39
    /// </summary>
40
    /// <remarks>
41
    /// </remarks>
42

    
43

    
44
    public interface XmlDestination
45
    {
46

    
47
        /// <summary>
48
        /// The underlying <c>Destination</c> object in the Saxon implementation
49
        /// </summary>
50
        /// <remarks>
51
        /// <para>This property provides access to internal methods in the Saxon engine that are
52
        /// not specifically exposed in the .NET API. In general these methods should be
53
        /// considered to be less stable than the classes in the Saxon.Api namespace.</para> 
54
        /// <para>The internal methods follow
55
        /// Java naming conventions rather than .NET conventions.</para>
56
		/// <para>Information about the returned <see cref="net.sf.saxon.Configuration"/> object 
57
		/// (and the objects it provides access to) is included in the Saxon JavaDoc docmentation.
58
        /// </para>
59
        /// </remarks>
60
        /// <returns>returns the underlying Destination object</returns>
61
		/**public**/ JDestination GetUnderlyingDestination();
62

    
63
    }
64

    
65
  
66

    
67
    /// <summary>
68
    /// A <c>Serializer</c> takes a tree representation of XML and turns
69
    /// it into lexical XML markup.
70
    /// </summary>
71
    /// <remarks>
72
    /// Note that this is serialization in the sense of the W3C XSLT and XQuery specifications.
73
    /// Unlike the class <c>System.Xml.Serialization.XmlSerializer</c>, this object does not
74
    /// serialize arbitrary CLI objects.
75
    /// </remarks>
76

    
77
    public class Serializer : XmlDestination
78
    {
79

    
80
        private net.sf.saxon.s9api.Serializer serializer;
81
        private JProperties props = new JProperties();
82
		private JCharacterMapIndex characterMap;
83
		private JProperties defaultOutputProperties = null;
84
        private Processor processor = null;
85
        private JConfiguration config = null; // Beware: this will often be null
86

    
87
        /// <summary>QName identifying the serialization parameter "method". If the method
88
        /// is a user-defined method, then it is given as a QName in Clark notation, that is
89
        /// "{uri}local".</summary>
90

    
91
        public static readonly QName METHOD =
92
            new QName("", "method");
93

    
94
        /// <summary>QName identifying the serialization parameter "byte-order-mark"</summary>
95

    
96
        public static readonly QName BYTE_ORDER_MARK =
97
            new QName("", "byte-order-mark");
98

    
99
        /// <summary>QName identifying the serialization parameter "cdata-section-elements".
100
        /// The value of this parameter is given as a space-separated list of expanded QNames in
101
        /// Clark notation, that is "{uri}local".</summary>
102

    
103
        public static readonly QName CDATA_SECTION_ELEMENTS =
104
            new QName("", "cdata-section-elements");
105

    
106
        /// <summary>QName identifying the serialization parameter "doctype-public"</summary>
107

    
108
        public static readonly QName DOCTYPE_PUBLIC =
109
            new QName("", "doctype-public");
110

    
111
        /// <summary>QName identifying the serialization parameter "doctype-system"</summary>
112

    
113
        public static readonly QName DOCTYPE_SYSTEM =
114
            new QName("", "doctype-system");
115

    
116
        /// <summary>QName identifying the serialization parameter "encoding"</summary>
117

    
118
        public static readonly QName ENCODING =
119
            new QName("", "encoding");
120

    
121
        /// <summary>QName identifying the serialization parameter "escape-uri-attributes".
122
        /// The value is the string "yes" or "no".</summary>
123

    
124
        public static readonly QName ESCAPE_URI_ATTRIBUTES =
125
            new QName("", "escape-uri-attributes");
126

    
127

    
128
        /// <summary>QName identifying the serialization parameter "include-content-type".
129
        /// The value is the string "yes" or "no".</summary>
130

    
131
        public static readonly QName INCLUDE_CONTENT_TYPE =
132
            new QName("", "include-content-type");
133

    
134
        /// <summary>QName identifying the serialization parameter "indent".
135
        /// The value is the string "yes" or "no".</summary>
136

    
137
        public static readonly QName INDENT =
138
            new QName("", "indent");
139

    
140
        /// <summary>QName identifying the serialization parameter "media-type".</summary>
141

    
142
        public static readonly QName MEDIA_TYPE =
143
            new QName("", "media-type");
144

    
145
        /// <summary>QName identifying the serialization parameter "normalization-form"</summary>
146

    
147
        public static readonly QName NORMALIZATION_FORM =
148
            new QName("", "normalization-form");
149

    
150
        /// <summary>
151
        /// Set to a string used to separate adjacent items in an XQuery result sequence
152
        /// </summary>
153
        public static readonly QName ITEM_SEPARATOR =
154
            new QName("", "item-separator");
155

    
156

    
157
        /// <summary>
158
        /// HTML version number
159
        /// </summary>
160
        public static readonly QName HTML_VERSION =
161
            new QName("" , "html-version");
162

    
163

    
164
        /// <summary>
165
        /// Build-tree option (XSLT only)
166
        /// </summary>
167
        public static readonly QName BUILD_TREE =
168
            new QName("", "build-tree");
169

    
170
        /// <summary>QName identifying the serialization parameter "omit-xml-declaration".
171
        /// The value is the string "yes" or "no".</summary>
172

    
173
        public static readonly QName OMIT_XML_DECLARATION =
174
            new QName("", "omit-xml-declaration");
175

    
176
        /// <summary>QName identifying the serialization parameter "standalone".
177
        /// The value is the string "yes" or "no" or "omit".</summary>
178

    
179
        public static readonly QName STANDALONE =
180
            new QName("", "standalone");
181

    
182
        /// <summary>QName identifying the serialization parameter "suppress-indentation"
183
        /// (introduced in XSLT/XQuery 3.0). Previously available as "saxon:suppress-indentation"
184
        /// The value is the string "yes" or "no" or "omit".</summary>
185

    
186
        public static readonly QName SUPPRESS_INDENTATION =
187
            new QName("", "suppress-indentation");
188

    
189
        /// <summary>QName identifying the serialization parameter "undeclare-prefixes".
190
        /// The value is the string "yes" or "no".</summary>
191

    
192
        public static readonly QName UNDECLARE_PREFIXES =
193
            new QName("", "undeclare-prefixes");
194

    
195
        /// <summary>QName identifying the serialization parameter "use-character-maps".
196
        /// This is available only with XSLT. The value of the parameter is a list of expanded QNames
197
        /// in Clark notation giving the names of character maps defined in the XSLT stylesheet.</summary>
198

    
199
        public static readonly QName USE_CHARACTER_MAPS =
200
            new QName("", "use-character-maps");
201

    
202
        /// <summary>QName identifying the serialization parameter "version"</summary>
203

    
204
        public static readonly QName VERSION =
205
            new QName("", "version");
206

    
207
        private static readonly String SAXON = NamespaceConstant.SAXON;
208

    
209

    
210
        /// <summary>QName identifying the serialization parameter "saxon:character-representation"</summary>
211

    
212

    
213
        public static readonly QName SAXON_CHARACTER_REPRESENTATION =
214
            new QName(SAXON, "saxon:character-representation");
215

    
216

    
217
        /// <summary>
218
        /// Saxon extension for use when writing to the text output method; this option causes the processing
219
        /// instructions hex and b64 to be recognized containing hexBinary or base64 data respectively.
220
        /// </summary>
221
        public static readonly QName SAXON_RECOGNIZE_BINARY =
222
            new QName("", "saxon:recognize-binary");
223

    
224
        /// <summary>QName identifying the serialization parameter "saxon:indent-spaces". The value
225
        /// is an integer (represented as a string) indicating the amount of indentation required.
226
        /// If specified, this parameter overrides indent="no".</summary>
227

    
228
        public static readonly QName SAXON_INDENT_SPACES =
229
            new QName(SAXON, "saxon:indent-spaces");
230

    
231

    
232
        /// <summary>
233
        /// Saxon extension: set to an integer (represented as a string) giving the desired maximum
234
        /// length of lines when indenting.Default is 80.
235
        /// </summary>
236
        public static readonly QName SAXON_LINE_LENGTH =
237
            new QName("", "saxon:line-length");
238

    
239

    
240
        /// <summary>
241
        /// Saxon extension: set to a space-separated list of attribute names, in Clark notation,
242
        /// indicating that attributes present in the list should be serialized in the order
243
        /// indicated, followed by attributes not present in the list(these are sorted first
244
        /// by namespace, then by local name).
245
        /// </summary>
246
        public static readonly QName SAXON_ATTRIBUTE_ORDER =
247
            new QName("", "saxon:attribute-order");
248

    
249
        /// <summary>
250
        ///  Saxon extension: request canonical XML output.
251
        /// </summary>
252
        public static readonly QName SAXON_CANONICAL =
253
            new QName("", "saxon:canonical");
254

    
255
        /// <summary>
256
        /// Saxon extension: set to any string. Indicates the sequence of characters used to represent
257
        /// a newline in the text output method, and in newlines used for indentation in any output
258
        /// methods that use indentation.
259
        /// </summary>
260
        public static readonly QName SAXON_NEWLINE =
261
            new QName("", "saxon:newline");
262

    
263

    
264
        /// <summary>
265
        /// Saxon extension for internal use: used in XSLT to tell the serializer whether the
266
        /// stylesheet used version="1.0" or version = "2.0"
267
        /// </summary>
268
        public static readonly QName SAXON_STYLESHEET_VERSION =
269
            new QName("", "saxon:stylesheet-version");
270

    
271
        /// <summary>QName identifying the serialization parameter "saxon:double-space". The value of this 
272
        /// parameter is given as a space-separated list of expanded QNames in Clark notation, that is 
273
        /// "{uri}local"; each QName identifies an element that should be preceded by an extra blank line within
274
        /// indented output.</summary>
275

    
276
        public static readonly QName SAXON_DOUBLE_SPACE =
277
            new QName(SAXON, "saxon:double-space");
278

    
279
        /// <summary>QName identifying the serialization parameter "suppress-indentation". Retained
280
        /// as a synonym of SUPPRESS_INDENTATION for backwards compatibility.</summary>
281

    
282
        public static readonly QName SAXON_SUPPRESS_INDENTATION = SUPPRESS_INDENTATION;
283

    
284
        /// <summary>QName identifying the serialization parameter "saxon:next-in-chain". This
285
        /// is available only with XSLT, and identifies the URI of a stylesheet that is to be used to
286
        /// process the results before passing them to their final destination.</summary>
287

    
288
        public static readonly QName NEXT_IN_CHAIN =
289
            new QName(SAXON, "saxon:next-in-chain");
290

    
291
        /// <summary>QName identifying the serialization parameter "saxon:require-well-formed". The
292
        /// value is the string "yes" or "no". If set to "yes", the output must be a well-formed
293
        /// document, or an error will be reported. ("Well-formed" here means that the document node
294
        /// must have exactly one element child, and no text node children other than whitespace-only
295
        /// text nodes).</summary>
296

    
297
        public static readonly QName SAXON_REQUIRE_WELL_FORMED =
298
            new QName(SAXON, "saxon:require-well-formed");
299

    
300

    
301
        /// <summary>
302
        /// Saxon extension for interfacing with debuggers; indicates that the location information is
303
        /// available for events in this output stream
304
        /// </summary>
305
        public static readonly QName SUPPLY_SOURCE_LOCATOR =
306
            new QName("", "supply-source-locator");
307

    
308

    
309
        /// <summary>
310
        /// Saxon extension, indicates that the output of a query is to be wrapped before serialization,
311
        /// such that each item in the result sequence is enclosed in an element indicating its type
312
        /// </summary>
313
        public static readonly QName SAXON_WRAP =
314
            new QName("", "", "wrap-result-sequence");
315

    
316
        /// <summary>Create a Serializer</summary>
317

    
318
        internal Serializer(net.sf.saxon.s9api.Serializer s)
319
        {
320
            serializer = s;
321
        }
322

    
323
        /// <summary>Set a serialization property</summary>
324
        /// <remarks>In the case of XSLT, properties set within the serializer override
325
        /// any properties set in <c>xsl:output</c> declarations in the stylesheet.
326
        /// Similarly, with XQuery, they override any properties set in the Query
327
        /// prolog using <c>declare option saxon:output</c>.</remarks>
328
        /// <example>
329
        ///   <code>
330
        ///     Serializer qout = new Serializer();
331
        ///     qout.SetOutputProperty(Serializer.METHOD, "xml");
332
        ///     qout.SetOutputProperty(Serializer.INDENT, "yes");
333
        ///     qout.SetOutputProperty(Serializer.SAXON_INDENT_SPACES, "1");
334
        ///   </code>
335
        /// </example> 
336
        /// <param name="name">The name of the serialization property to be set</param>
337
        /// <param name="value">The value to be set for the serialization property. May be null
338
        /// to unset the property (that is, to set it back to the default value).</param>
339

    
340
        public void SetOutputProperty(QName name, String value)
341
        {
342
           props.setProperty(name.ClarkName, value);
343
           serializer.setOutputProperty(net.sf.saxon.s9api.Serializer.getProperty(name.UnderlyingQName()), value);
344
        }
345

    
346
        /// <summary>
347
		/// Set default output properties, for use when no explicit properties are set using <c>SetOutputProperty()</c>.
348
        /// The values supplied are typically those specified in the stylesheet or query. In the case of XSLT,
349
        /// they are the properties associated with unamed <c>xsl:output</c> declarations.
350
        /// </summary>
351
        /// <param name="props"></param>
352

    
353
		public void SetDefaultOutputProperties(JProperties props)
354
		{
355
			this.defaultOutputProperties = props;
356
		}
357

    
358
        /// <summary>
359
        /// Get a character map
360
        /// </summary>
361
        
362
		public JCharacterMapIndex GetCharacterMap()
363
        {
364
            return this.characterMap;
365
        }
366

    
367
        /// <summary>
368
        /// Set a character map to be used
369
        /// </summary>
370
        /// <param name="charMap">the character map</param>
371

    
372
		public void SetCharacterMap(JCharacterMapIndex charMap)
373
		{
374
			this.characterMap = charMap;
375
		}
376
			
377

    
378
        /// <summary>Specify the destination of the serialized output, in the
379
        /// form of a file name</summary>
380
        /// <param name="filename">The name of the file to receive the serialized output. This
381
        /// method sets the destination base URI to the URI corresponding to the name of the supplied file.</param>
382
		/// <exception cref="DynamicError">Throws a <c>DynamicError</c> if it is not possible to 
383
		/// create an output stream to write to this file, for example, if the filename is in a
384
        /// directory that does not exist.</exception>
385

    
386
        public void SetOutputFile(String filename)
387
        {
388
            try
389
            {
390
                serializer.setOutputFile(new java.io.File(filename));
391
            }
392
            catch (java.io.IOException err)
393
            {
394
                JXPathException e = new JXPathException(err);
395
                throw new DynamicError(e);
396
            }
397
        }
398

    
399

    
400
        /// <summary>Specify the destination of the serialized output, in the
401
        /// form of a <c>Stream</c>.</summary>
402
        /// <remarks>Saxon will not close the stream on completion; this is the
403
        /// caller's responsibility.</remarks>
404
        /// <param name="stream">The stream to which the output will be written.
405
        /// This must be a stream that allows writing.</param>
406

    
407
        public void SetOutputStream(Stream stream)
408
        {
409

    
410
            serializer.setOutputStream(new JDotNetOutputStream(stream));
411
        }
412
			
413
    	/// <summary>Get the current output destination.</summary> 
414
		/// <returns>an <c>OutputStream</c>, <c>Writer</c>, or <c>File</c>, depending on the previous calls to
415
		/// <c>SetOutputstream</c>, <c>SetOutputWriter</c>, or <c>SetOutputFile</c>; or null, if no output destintion has
416
        /// been set up.</returns>
417

    
418
		public object GetOutputDestination(){
419
			return serializer.getOutputDestination();		
420
		}
421

    
422

    
423
		/// <summary>Set the <c>Processor</c> associated with this <c>Serializer</c>. This will be called automatically if the
424
		/// serializer is created using one of the <c>Processor.NewSerializer()</c> methods.</summary>
425
		/// <param name="processor"> the associated <c>Processor</c></param>
426
        
427
        public void SetProcessor(Processor processor)
428
        {
429
            this.processor = processor;
430
            this.config = processor.Implementation;
431
        }
432

    
433
        /// <summary>Specify the destination of the serialized output, in the
434
        /// form of a <c>TextWriter</c>.</summary>
435
        /// <remarks>Note that when writing to a <c>TextWriter</c>, character encoding is
436
        /// the responsibility of the <c>TextWriter</c>, not the <c>Serializer</c>. This
437
        /// means that the encoding requested in the output properties is ignored; it also
438
        /// means that characters that cannot be represented in the target encoding will
439
        /// use whatever fallback representation the <c>TextWriter</c> defines, rather than
440
        /// being represented as XML character references.</remarks>
441
        /// <param name="textWriter">The stream to which the output will be written.
442
        /// This must be a stream that allows writing. Saxon will not close the
443
        /// <c>TextWriter</c> on completion; this is the caller's responsibility.</param>
444

    
445
        public void SetOutputWriter(TextWriter textWriter)
446
        {
447
            serializer.setOutputWriter(new JDotNetWriter(textWriter));
448
        }
449

    
450

    
451
        /// <summary>
452
		/// Serialize an <c>XdmNode</c> to the selected output destination using this serializer.
453
        /// </summary>
454
        /// <param name="node">The node to be serialized</param>
455
        /// <remarks>since 9.8</remarks>
456
        public void SerializeXdmNode(XdmNode node)
457
        {
458
            serializer.serializeNode((net.sf.saxon.s9api.XdmNode)XdmValue.FromGroundedValueToJXdmValue(node.value));
459
        }
460

    
461

    
462
        /// <summary>
463
		/// Serialize an arbitary <c>XdmValue</c> to the selected output destination using this serializer.
464
        /// The supplied sequence is first wrapped in a document node according to the rules given in section 2
465
		/// (Sequence Normalization) of the XSLT/XQuery serialization specification; the resulting document node 
466
		/// is then serialized using the serialization parameters defined in this serializer. A call on this 
467
		/// method will close the writer or output stream internally.
468
        /// </summary>
469
        /// <param name="value"> The value to be serialized</param>
470
        /// <remarks>since 9.8</remarks>
471
        public void SerializeXdmValue(XdmValue value) {
472

    
473

    
474
            
475
            if (value is XdmNode)
476
            {
477
                SerializeXdmNode((XdmNode)value);  
478
            }
479
            else {
480
                serializer.serializeXdmValue(net.sf.saxon.s9api.XdmValue.wrap(value.Unwrap()));
481
            }
482

    
483
        }
484

    
485
        
486
        /// <summary>
487
        /// Close any resources associated with this destination. Note that this does <b>not</b>
488
        /// close any user-supplied OutputStream or Writer; those must be closed explicitly
489
        /// by the calling application.
490
        /// </summary>
491
        public void Close()
492
        {
493
            serializer.close();
494
        }
495

    
496

    
497
        /// <summary>
498
        /// The underlying <c>Destination</c> object in the Saxon implementation
499
        /// </summary>
500
        /// <remarks>
501
        /// <para>This property provides access to internal methods in the Saxon engine that are
502
        /// not specifically exposed in the .NET API. In general these methods should be
503
        /// considered to be less stable than the classes in the Saxon.Api namespace.</para> 
504
        /// <para>The internal methods follow
505
        /// Java naming conventions rather than .NET conventions.</para>
506
        /// <para>Information about the returned <see cref="net.sf.saxon.Configuration"/> object 
507
        /// (and the objects it provides access to) is included in the Saxon JavaDoc docmentation.
508
        /// </para>
509
        /// </remarks>
510
        /// <returns>returns the underlying Destination object</returns>
511
        public JDestination GetUnderlyingDestination()
512
        {
513
            return serializer;
514
        }
515

    
516

    
517
        /// <summary>
518
        /// Close the destination and notify all registered listeners that it has been closed.
519
        /// This method is intended for internal use by Saxon. The method first calls
520
		/// <see cref="Close"/> to close the destination, then it calls <c>java.util.function.Consumer.accept()</c> 
521
		/// on each of the listeners in turn to notify the fact that it has been closed.
522
        /// </summary>
523
        public void CloseAndNotify()
524
        {
525
            try
526
            {
527
                serializer.closeAndNotify();
528
            }
529
            catch (net.sf.saxon.s9api.SaxonApiException exception) {
530
                throw new StaticError(exception);
531
            }
532
        }
533

    
534

    
535
        /// <summary>This property determines the base Uri of the constructed <c>Serializer</c>. 
536
        /// </summary>
537

    
538
        public Uri BaseUri
539
        {
540
            get { return new Uri(serializer.getDestinationBaseURI().toASCIIString()); }
541
            set { serializer.setDestinationBaseURI(new java.net.URI(value.ToString())); }
542
        }
543

    
544

    
545

    
546
    }
547

    
548
    /// <summary>
549
	/// A <c>DomDestination</c> represents an <c>XmlDocument</c> that is constructed to hold the
550
    /// output of a query or transformation.
551
    /// </summary>
552
    /// <remarks>
553
    /// No data needs to be supplied to the <c>DomDestination</c> object. The query or transformation
554
    /// populates an <c>XmlDocument</c>, which may then be retrieved as the value of the <c>XmlDocument</c>
555
    /// property.
556
    /// </remarks>
557

    
558
    public class DomDestination : XmlDestination
559
    {
560

    
561
        internal JDotNetDomBuilder builder;
562
        internal net.sf.saxon.dotnet.DotNetDomDestination destination;
563

    
564
        /// <summary>Construct a <c>DomDestination</c>.</summary>
565
        /// <remarks>With this constructor, the system will create a new DOM Document
566
        /// to act as the destination of the query or transformation results. The document
567
		/// node of the new document may be retrieved via the <c>XmlDocument</c> property.</remarks>
568

    
569
        public DomDestination()
570
        {
571
            builder = new JDotNetDomBuilder();
572
            destination = new net.sf.saxon.dotnet.DotNetDomDestination(builder);
573
        }
574

    
575
        /// <summary>Construct a <c>DomDestination</c> based on an existing document node.</summary>
576
        /// <remarks>The new data will be added as a child of the supplied node.</remarks>
577
        /// <param name="attachmentPoint">The document node to which new contents will
578
        /// be attached. To ensure that the new document is well-formed, this document node
579
        /// should have no existing children.</param>
580

    
581
        public DomDestination(XmlDocument attachmentPoint)
582
        {
583
            builder = new JDotNetDomBuilder();
584
            builder.setAttachmentPoint(attachmentPoint);
585
        }
586

    
587
        /// <summary>Construct a <c>DomDestination</c> based on an existing document fragment node.</summary>
588
        /// <remarks>The new data will be added as a child of the supplied node.</remarks>
589
        /// <param name="attachmentPoint">The document fragment node to which new contents will
590
        /// be attached. The new contents will be added after any existing children.</param>
591

    
592
        public DomDestination(XmlDocumentFragment attachmentPoint)
593
        {
594
            builder = new JDotNetDomBuilder();
595
            builder.setAttachmentPoint(attachmentPoint);
596
        }
597

    
598
        /// <summary>Construct a <c>DomDestination</c> based on an existing element node.</summary>
599
        /// <remarks>The new data will be added as a child of the supplied element node.</remarks>
600
        /// <param name="attachmentPoint">The element node to which new contents will
601
        /// be attached. The new contents will be added after any existing children.</param>
602

    
603
        public DomDestination(XmlElement attachmentPoint)
604
        {
605
            builder = new JDotNetDomBuilder();
606
            builder.setAttachmentPoint(attachmentPoint);
607
        }
608

    
609
        /// <summary>After construction, retrieve the constructed document node.</summary>
610
        /// <remarks>If the zero-argument constructor was used, this will be a newly
611
        /// constructed document node. If the constructor supplied a document node, the
612
        /// same document node will be returned. If the constructor supplied a document fragment
613
        /// node or an element node, this method returns the <c>OwnerDocument</c> property of 
614
        /// that node.</remarks>
615

    
616
        public XmlDocument XmlDocument
617
        {
618
            get { return builder.getDocumentNode(); }
619
        }
620

    
621

    
622
        /// <summary>
623
        /// Close any resources associated with this destination. Note that this does <b>not</b>
624
        /// close any user-supplied OutputStream or Writer; those must be closed explicitly
625
        /// by the calling application.
626
        /// </summary>
627
        public void Close()
628
        {
629
            builder.close();
630
        }
631

    
632

    
633

    
634
        /// <summary>
635
        /// The underlying <c>Destination</c> object in the Saxon implementation
636
        /// </summary>
637
        /// <remarks>
638
        /// <para>This property provides access to internal methods in the Saxon engine that are
639
        /// not specifically exposed in the .NET API. In general these methods should be
640
        /// considered to be less stable than the classes in the Saxon.Api namespace.</para> 
641
        /// <para>The internal methods follow
642
        /// Java naming conventions rather than .NET conventions.</para>
643
        /// <para>Information about the returned <see cref="net.sf.saxon.Configuration"/> object 
644
        /// (and the objects it provides access to) is included in the Saxon JavaDoc docmentation.
645
        /// </para>
646
        /// </remarks>
647
        /// <returns>returns the underlying Destination object</returns>
648
        public JDestination GetUnderlyingDestination()
649
        {
650
            return destination;
651
        }
652

    
653

    
654
	}
655

    
656
	/// <summary>
657
	/// A <c>RawDestination</c> is an <c>Destination</c> that accepts a sequence output
658
	/// by a stylesheet or query and returns it directly as an <c>XdmValue</c>, without
659
	/// constructing an XML tree, and without serialization. It corresponds to the serialization
660
	/// option <code>build-tree="no"</code>.
661
	/// </summary>
662

    
663
    public class RawDestination : XmlDestination
664

    
665
    {
666

    
667
        internal net.sf.saxon.s9api.RawDestination destination;
668

    
669
        /// <summary>Construct a <c>RawDestination</c></summary>
670

    
671
        public RawDestination()
672
        {
673
            destination = new net.sf.saxon.s9api.RawDestination();
674
        }
675

    
676
        /// <summary>
677
        /// The underlying <c>Destination</c> object in the Saxon implementation
678
        /// </summary>
679
        /// <remarks>
680
        /// <para>This property provides access to internal methods in the Saxon engine that are
681
        /// not specifically exposed in the .NET API. In general these methods should be
682
        /// considered to be less stable than the classes in the Saxon.Api namespace.</para> 
683
        /// <para>The internal methods follow
684
        /// Java naming conventions rather than .NET conventions.</para>
685
        /// <para>Information about the returned <see cref="net.sf.saxon.Configuration"/> object 
686
        /// (and the objects it provides access to) is included in the Saxon JavaDoc docmentation.
687
        /// </para>
688
        /// </remarks>
689
        /// <returns>returns the underlying Destination object</returns>
690
        public JDestination GetUnderlyingDestination()
691
        {
692
            return destination;
693
        }
694

    
695
        /// <summary>
696
        /// Close the destination and notify all registered listeners that it has been closed.
697
        /// This method is intended for internal use by Saxon. The method first calls
698
		/// <see cref="Close"/> to close the destination, then it calls <c>java.util.function.Consumer.accept()</c>
699
		/// on each of the listeners in turn to notify the fact that it has been closed.
700
        /// </summary>
701
        public void CloseAndNotify()
702
        {
703
            destination.closeAndNotify();
704
        }
705

    
706

    
707

    
708
        /// <summary>This property determines the base URI of the constructed <c>XdmNode</c>. 
709
        /// If the <c>BaseUri</c> property of the <c>XdmDestination</c> is set before the destination is written to,
710
        /// then the constructed <c>XdmNode</c> will have this base URI. Setting this property after constructing the node
711
        /// has no effect.
712
        /// </summary>
713

    
714
        public Uri BaseUri
715
        {
716
            get { return new Uri(destination.getDestinationBaseURI().toASCIIString()); }
717
            set { destination.setDestinationBaseURI(new java.net.URI(value.ToString())); }
718
        }
719

    
720

    
721
        /// <summary>
722
        /// Close any resources associated with this destination. Note that this does <b>not</b>
723
        /// close any user-supplied OutputStream or Writer; those must be closed explicitly
724
        /// by the calling application.
725
        /// </summary>
726
        public void Close()
727
        {
728
            destination.close();
729
        }
730

    
731
        /// <summary>After construction, retrieve the constructed document node.</summary>
732
        /// <remarks>
733
        /// <para>The value of the property will be null if no data has been written to the
734
        /// <c>RawDestination</c>, either because the process that writes to the destination has not
735
        /// yet been run, or because the process produced no output.</para>
736
        /// </remarks>
737

    
738
        public XdmValue XdmValue
739
        {
740
            get
741
            {
742
                net.sf.saxon.om.GroundedValue value = destination.getXdmValue().getUnderlyingValue();
743
                return (value == null ? null : XdmValue.Wrap(value));
744
            }
745
        }
746
    }
747

    
748
    /// <summary>
749
	/// A <c>NullDestination</c> is an <c>XmlDestination</c> that discards all its output.
750
    /// </summary>
751

    
752
    public class NullDestination : XmlDestination
753
    {
754

    
755
        net.sf.saxon.s9api.NullDestination destination;
756
        /// <summary>Construct a <c>NullDestination</c></summary>
757

    
758
        public NullDestination()
759
        {
760
            destination = new net.sf.saxon.s9api.NullDestination();
761
        }
762

    
763
        /// <summary>This property determines the base Uri of the constructed <c>Serializer</c>. 
764
        /// </summary>
765

    
766
        public Uri BaseUri
767
        {
768
            get { return new Uri(destination.getDestinationBaseURI().toASCIIString()); }
769
            set { destination.setDestinationBaseURI(new java.net.URI(value.ToString())); }
770
        }
771

    
772

    
773
        /// <summary>
774
        /// The underlying <c>Destination</c> object in the Saxon implementation, which in the NullDestination is null.
775
        /// </summary>
776
        /// <returns>returns null</returns>
777
        public JDestination GetUnderlyingDestination()
778
        {
779
            return destination;
780
        }
781

    
782
    }
783

    
784

    
785
    /// <summary>
786
    /// A <c>TextWriterDestination</c> is an implementation of <c>XmlDestination</c> that wraps
787
    /// an instance of <c>XmlWriter</c>.
788
    /// </summary>
789
    /// <remarks>
790
    /// <para>The name <c>TextWriterDestination</c> is a misnomer; originally this class would
791
    /// only wrap an <c>XmlTextWriter</c>. It will now wrap any <c>XmlWriter</c>.</para>
792
    /// <para>Note that when a <c>TextWriterDestination</c> is used to process the output of a stylesheet
793
    /// or query, the output format depends only on the way the underlying <c>XmlWriter</c>
794
    /// is configured; serialization parameters present in the stylesheet or query are ignored.
795
    /// The XSLT <c>disable-output-escaping</c> option is also ignored. If serialization
796
    /// is to be controlled from the stylesheet or query, use a <c>Serializer</c> as the
797
    /// <c>Destination</c>.</para>
798
    /// </remarks>
799

    
800
    public class TextWriterDestination : JAbstractDestination, XmlDestination
801
    {
802

    
803
        internal XmlWriter writer;
804
        internal bool closeAfterUse = true;
805

    
806
		/// <summary>Construct a <c>TextWriterDestination</c></summary>
807
        /// <param name="writer">The <c>XmlWriter</c> that is to be notified of the events
808
        /// representing the XML document.</param>
809

    
810
        public TextWriterDestination(XmlWriter writer)
811
        {
812
            this.writer = writer;
813
        }
814

    
815
        /// <summary>
816
        /// The <c>CloseAfterUse</c> property indicates whether the underlying <c>XmlWriter</c> is closed
817
        /// (by calling its <c>Close()</c> method) when Saxon has finished writing to it. The default
818
        /// value is true, in which case <c>Close()</c> is called. If the property is set to <c>false</c>,
819
        /// Saxon will refrain from calling the <c>Close()</c> method, and merely call <c>Flush()</c>,
820
        /// which can be useful if further output is to be written to the <c>XmlWriter</c> by the application.
821
        /// </summary>
822

    
823
        public bool CloseAfterUse
824
        {
825
            get { return closeAfterUse; }
826
            set { closeAfterUse = value; }
827
        }
828

    
829
        /// <summary>
830
        /// Close any resources associated with this destination. Note that this does <b>not</b>
831
        /// close any user-supplied OutputStream or Writer; those must be closed explicitly
832
        /// by the calling application.
833
        /// </summary>
834
        public override void close()
835
        {
836
            writer.Close();
837
        }
838

    
839

    
840
        /// <summary>
841
		/// Return a <c>Receiver</c>. Saxon calls this method to obtain a Java <c>Receiver</c>, to which it then sends
842
        /// a sequence of events representing the content of an XML document. The method is intended
843
        /// primarily for internal use, and may give poor diagnostics if used incorrectly.
844
        /// </summary>
845
        /// <returns>The receiver</returns>
846
		/// <param name="pipe">The Saxon configuration as a <c>JPipelineConfiguration</c>. 
847
		/// This is supplied so that the destination can
848
        /// use information from the configuration (for example, a reference to the name pool)
849
		/// to construct or configure the returned <c>Receiver</c>.</param>
850
		/// <param name="params1"></param>
851
        
852
		public JReceiver GetReceiver(JPipelineConfiguration pipe, JSerializationProperties params1)
853
        {
854
            JDotNetReceiver dnr = new JDotNetReceiver(writer);
855
			dnr.setPipelineConfiguration (pipe);
856
            dnr.setCloseAfterUse(closeAfterUse);
857
            return params1.makeSequenceNormalizer(dnr);
858
        }
859

    
860
        /// <summary>
861
		/// Return a <c>Receiver</c>. Saxon calls this method to obtain a Java <c>Receiver</c>, to which it then sends
862
        /// a sequence of events representing the content of an XML document. The method is intended
863
        /// primarily for internal use, and may give poor diagnostics if used incorrectly.
864
        /// </summary>
865
        /// <returns>The receiver</returns>
866
		/// <param name="pipe">The Saxon configuration as a <c>JPipelineConfiguration</c>. 
867
		/// This is supplied so that the destination can
868
        /// use information from the configuration (for example, a reference to the name pool)
869
		/// to construct or configure the returned <c>Receiver</c>.</param>
870
		/// <param name="value2">Serialization parameters known to the caller of the method; typically, output
871
        ///  properties defined in a stylesheet or query. These will mainly be of interest if the destination is performing serialization, but
872
        ///  soem properties (such as <c>item-separator</c>) are also used in other situations.</param>
873
        public override JReceiver getReceiver(JPipelineConfiguration pipe, JSerializationProperties value2)
874
        {
875
            return GetReceiver(pipe, value2); 
876
        }
877

    
878
        /// <summary>
879
        /// The underlying <c>Destination</c> object in the Saxon implementation
880
        /// </summary>
881
        /// <remarks>
882
        /// <para>This property provides access to internal methods in the Saxon engine that are
883
        /// not specifically exposed in the .NET API. In general these methods should be
884
        /// considered to be less stable than the classes in the Saxon.Api namespace.</para> 
885
        /// <para>The internal methods follow
886
        /// Java naming conventions rather than .NET conventions.</para>
887
        /// <para>Information about the returned <see cref="net.sf.saxon.Configuration"/> object 
888
        /// (and the objects it provides access to) is included in the Saxon JavaDoc docmentation.
889
        /// </para>
890
        /// </remarks>
891
        /// <returns>returns the underlying Destination object</returns>
892
        public JDestination GetUnderlyingDestination()
893
        {
894
            return this;
895
        }
896
    }
897

    
898
    /*
899
    /// <summary>
900
    /// A completely general functional interface for functions that take
901
    /// no argument, return void, and potentially throw a Exception
902
    /// </summary>
903
    public interface IAction {
904

    
905
        /// <summary>
906
        /// Perform the requested action
907
        /// </summary>
908
        void Act();
909

    
910
    } */
911

    
912
    /*internal class ActionImpl: net.sf.saxon.s9api.Action {
913

    
914
        private IAction action;
915
        public ActionImpl(IAction actioni) {
916
            action = actioni;
917
        }
918

    
919
        public void act()
920
        {
921
            try
922
            {
923
                action.Act();
924

    
925
            }
926
            catch (net.sf.saxon.s9api.SaxonApiException ex) {
927

    
928
                throw new DynamicError(ex);
929
            }
930

    
931
        }
932

    
933
    }*/
934

    
935

    
936
    internal class AbstractDestination : XmlDestination
937
    {
938
        private Xslt30Transformer xslt30Transformer;
939
        private XmlDestination destination;
940

    
941
        internal AbstractDestination(Xslt30Transformer xslt30Transformer, XmlDestination destination)
942
        {
943
            this.xslt30Transformer = xslt30Transformer;
944
            this.destination = destination;
945
        }
946

    
947
        JDestination XmlDestination.GetUnderlyingDestination()
948
        {
949
            return xslt30Transformer.GetUnderlyingXslt30Transformer.asDocumentDestination(destination.GetUnderlyingDestination());
950
        }
951
    }
952

    
953

    
954
    /// <summary>
955
    /// An <c>XdmDestination</c> is an <c>XmlDestination</c> in which an <c>XdmNode</c> 
956
    /// is constructed to hold the output of a query or transformation: 
957
    /// that is, a tree using Saxon's implementation of the XDM data model.
958
    /// </summary>
959
    /// <remarks>
960
    /// <para>No data needs to be supplied to the <c>XdmDestination</c> object. The query or transformation
961
    /// populates an <c>XmlNode</c>, which may then be retrieved as the value of the <c>XmlNode</c>
962
    /// property.</para>
963
    /// <para>An <c>XdmDestination</c> can be reused to hold the results of a second transformation only
964
    /// if the <c>Reset</c> method is first called to reset its state.</para>
965
    /// </remarks>
966

    
967
    public class XdmDestination : XmlDestination
968
    {
969
        internal net.sf.saxon.s9api.XdmDestination destination;
970

    
971
        /// <summary>Construct an <c>XdmDestination</c></summary>
972

    
973
        public XdmDestination()
974
        {
975
            destination = new net.sf.saxon.s9api.XdmDestination();
976
        }
977

    
978
        ///<summary>
979
        /// The Tree Model implementation to be used for the constructed document. By default
980
		/// the <c>TinyTree</c> is used. The main reason for using the <c>LinkedTree</c> alternative is if
981
		/// updating is required (the <c>TinyTree</c> is not updateable).
982
        ///</summary>
983

    
984
        public TreeModel TreeModel
985
        {
986
            get
987
            {
988
                return  (TreeModel)destination.getTreeModel().getSymbolicValue();
989
            }
990
            set
991
            {
992
                destination.setTreeModel(net.sf.saxon.om.TreeModel.getTreeModel((int)value));
993
            }
994
        }
995

    
996
		/// <summary>This property determines the base URI of the constructed <c>XdmNode</c>. 
997
		/// If the <c>BaseUri</c> property of the <c>XdmDestination</c> is set before the destination is written to,
998
		/// then the constructed <c>XdmNode</c> will have this base URI. Setting this property after constructing the node
999
        /// has no effect.
1000
        /// </summary>
1001

    
1002
        public Uri BaseUri
1003
        {
1004
            get { return new Uri(destination.getBaseURI().toASCIIString()); }
1005
            set { destination.setBaseURI(new java.net.URI(value.ToString())); }
1006
        }
1007

    
1008

    
1009
        /// <summary>Reset the state of the <c>XdmDestination</c> so that it can be used to hold
1010
        /// the result of another query or transformation.</summary>
1011

    
1012
        public void Reset()
1013
        {
1014
            destination.reset();
1015
        }
1016

    
1017
        /// <summary>After construction, retrieve the constructed document node.</summary>
1018
        /// <remarks>
1019
        /// <para>The value of the property will be null if no data has been written to the
1020
		/// <c>XdmDestination</c>, either because the process that writes to the destination has not
1021
        /// yet been run, or because the process produced no output.</para>
1022
        /// </remarks>
1023

    
1024
        public XdmNode XdmNode
1025
        {
1026
            get
1027
            {
1028
                JNodeInfo jnode = destination.getXdmNode().getUnderlyingNode();
1029
                return (jnode == null ? null : (XdmNode)XdmValue.Wrap(jnode));
1030
            }
1031
        }
1032

    
1033

    
1034
        /// <summary>
1035
		/// Get the underlying Saxon <c>Destination</c> object from the <c>XdmDestination</c>.
1036
        /// This method is for internal use but is provided for the benefit of applications that need to mix
1037
        /// use of the Saxon .NET API with direct use of the underlying objects
1038
        /// and methods offered by the Java implementation.
1039
        /// </summary>
1040
        public JDestination GetUnderlyingDestination()
1041
        {
1042
            return destination;
1043
        }
1044

    
1045

    
1046
        /// <summary>
1047
        /// Set the base URI of the resource being written to this destination
1048
        /// </summary>
1049
        /// <param name="uri">the base URI to be used</param>
1050
        public void setDestinationBaseURI(java.net.URI uri)
1051
        {
1052
            destination.setDestinationBaseURI(uri);
1053
        }
1054

    
1055
        /// <summary>
1056
        /// Get the base URI of the resource being written to this destination
1057
        /// </summary>
1058
        /// <returns>the base URI, or null if none is known</returns>
1059
        public java.net.URI getDestinationBaseURI()
1060
        {
1061
            return destination.getDestinationBaseURI();
1062
        }
1063

    
1064

    
1065

    
1066
        /// <summary>
1067
        /// Close the destination, allowing resources to be released. Saxon calls this
1068
        /// method when it has finished writing to the destination.
1069
        /// </summary>
1070
        public void Close()
1071
        {
1072
            destination.close();
1073
        }
1074

    
1075
        /// <summary>
1076
        /// <c>TreeProtector</c> is a filter that ensures that the events reaching the <c>Builder</c> constitute a single
1077
        /// tree rooted at an element or document node (because anything else will crash the builder)
1078
        /// </summary>
1079

    
1080
        public class TreeProtector : JProxyReceiver
1081
        {
1082

    
1083
            private int level = 0;
1084
            private bool ended = false;
1085

    
1086
            /// <summary>
1087
            /// Constructor
1088
            /// </summary>
1089
            /// <param name="next">Set the underlying receiver</param>
1090
            public TreeProtector(JReceiver next)
1091
                : base(next)
1092
            {
1093

    
1094
            }
1095

    
1096
            /// <summary>
1097
            /// Start of a document node
1098
            /// </summary>
1099
            /// <param name="properties"></param>
1100
            public override void startDocument(int properties)
1101
            {
1102
                if (ended)
1103
                {
1104
                    JXPathException e = new JXPathException("Only a single document can be written to an XdmDestination");
1105
                    throw new DynamicError(e);
1106
                }
1107
                base.startDocument(properties);
1108
                level++;
1109
            }
1110

    
1111
            /// <summary>
1112
            /// Notify the end of a document node
1113
            /// </summary>
1114
            public override void endDocument()
1115
            {
1116
                base.endDocument();
1117
                level--;
1118
                if (level == 0)
1119
                {
1120
                    ended = true;
1121
                }
1122
            }
1123

    
1124
            /// <summary>
1125
            /// Notify the start of an element
1126
            /// </summary>
1127
            /// <param name="nameCode"></param>
1128
			/// <param name="typeCode"></param>
1129
			/// <param name="attributes"></param>
1130
			/// <param name="namespaces"></param>
1131
            /// <param name="location"></param>
1132
            /// <param name="properties"></param>
1133
            public override void startElement(JNodeName nameCode, JSchemaType typeCode, JAttributeMap attributes, JNamespaceMap namespaces, JLocation location, int properties)
1134
            {
1135
                if (ended)
1136
                {
1137
                    JXPathException e = new JXPathException("Only a single root node can be written to an XdmDestination");
1138
                    throw new DynamicError(e);
1139
                }
1140
                base.startElement(nameCode, typeCode, attributes, namespaces, location, properties);
1141
                level++;
1142
            }
1143

    
1144
            /// <summary>
1145
            /// End of element
1146
            /// </summary>
1147
            public override void endElement()
1148
            {
1149
                base.endElement();
1150
                level--;
1151
                if (level == 0)
1152
                {
1153
                    ended = true;
1154
                }
1155
            }
1156

    
1157
            /// <summary>
1158
            /// Character data
1159
            /// </summary>
1160
            /// <param name="chars">Character data as input</param>
1161
            /// <param name="location">Provides information such as line number and system ID</param>
1162
            /// <param name="properties">Bit significant value. The following bits are defined</param>
1163
			public override void characters(JCharSequence chars, JLocation location, int properties)
1164
            {
1165
                if (level == 0)
1166
                {
1167
                    JXPathException e = new JXPathException("When writing to an XdmDestination, text nodes are only allowed within a document or element node");
1168
                    throw new DynamicError(e);
1169
                }
1170
                base.characters(chars, location, properties);
1171
            }
1172

    
1173
            /// <summary>
1174
            /// Processing instruction
1175
            /// </summary>
1176
            /// <param name="target">The PI name. This must be a legal name (it will not be checked)</param>
1177
            /// <param name="data">The data portion of the processing instruction</param>
1178
            /// <param name="location">provides information about the PI</param>
1179
            /// <param name="properties">Additional information about the PI</param>
1180
			public override void processingInstruction(String target, JCharSequence data, JLocation location, int properties)
1181
            {
1182
                if (level == 0)
1183
                {
1184
                    JXPathException e = new JXPathException("When writing to an XdmDestination, processing instructions are only allowed within a document or element node");
1185
                    throw new DynamicError(e);
1186
                }
1187
                base.processingInstruction(target, data, location, properties);
1188
            }
1189

    
1190
            /// <summary>
1191
            /// Output a comment
1192
            /// </summary>
1193
            /// <param name="chars">The content of the comment</param>
1194
            /// <param name="location">provides information such as line number and system ID</param>
1195
            /// <param name="properties">Additional information about the comment</param>
1196
			public override void comment(JCharSequence chars, JLocation location, int properties)
1197
            {
1198
                if (level == 0)
1199
                {
1200
                    JXPathException e = new JXPathException("When writing to an XdmDestination, comment nodes are only allowed within a document or element node");
1201
                }
1202
                base.comment(chars, location, properties);
1203
            }
1204

    
1205

    
1206
            /// <summary>
1207
            /// Append an  arbitrary item (node or atomic value) to the output
1208
            /// </summary>
1209
            /// <param name="item">the item to be appended</param>
1210
            /// <param name="location">the location of the calling instruction, for diagnostics</param>
1211
            /// <param name="copyNamespaces">if the item is an element node, this indicates whether its namespace need to be copied. 
1212
            /// 0x80000 means ALL_NAMESPACE, 0x40000 means LOCAL_NAMESPACE and 0 means no namespace</param>
1213
			public override void append(JItem item, JLocation location, int copyNamespaces)
1214
            {
1215
                if (level == 0)
1216
                {
1217
                    JXPathException e = new JXPathException("When writing to an XdmDestination, atomic values are only allowed within a document or element node");
1218
                }
1219
                base.append(item, location, copyNamespaces);
1220
            }
1221

    
1222
        }
1223
    }
1224

    
1225

    
1226
}
1227

    
1228
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1229
// Copyright (c) 2020 Saxonica Limited.
1230
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
1231
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
1232
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
1233
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(2-2/13)