Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merged from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 76ba31355cc60cf99703f02945d8c015518337effa5651076fab4187d91a2cfe
User & Date: rolf 2020-07-23 23:50:07
Context
2020-07-30
14:33
Integrated further improvements and features to recovering. check-in: 0e98933aa6 user: rolf tags: schema
2020-07-23
23:50
Merged from schema. check-in: 227e773285 user: rolf tags: wip
23:50
Merged from trunk. check-in: 76ba31355c user: rolf tags: schema
23:47
More work on README.md. check-in: d6e437fb0d user: rolf tags: trunk
2020-07-09
01:16
Added the text constraint command duration. check-in: 45a05b0b4f user: rolf tags: schema
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to CHANGES.





1
2
3
4
5
6
7




2020-07-03  Rolf Ade  <rolf@pointsman.de>

        User configurable separator character between namespace URI
        and local name for XML namespace-aware SAX parser:  Added the
        option -namespaceseparator to the expat command.

2020-05-14  Rolf Ade  <rolf@pointsman.de>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
2020-07-23  Rolf Ade  <rolf@pointsman.de>

        Added -indent value "tab" to asXML and asJSON.

2020-07-03  Rolf Ade  <rolf@pointsman.de>

        User configurable separator character between namespace URI
        and local name for XML namespace-aware SAX parser:  Added the
        option -namespaceseparator to the expat command.

2020-05-14  Rolf Ade  <rolf@pointsman.de>

Name change from README to README.md.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


45
46
47
48
49
50

51
52
53
54
55
56
57

58
59
60
61




62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

109
110
111
112
113
114
115

116
117
118
119
120







    tDOM - a XML/DOM/XPath/XSLT/HTML/JSON implementation for Tcl
                          (Version 0.9.2)


This directory contains a freely distributable thread-safe extension
to Tcl/Tk called tDOM.

tDOM contains:

    *  for convenience expat 2.2.5, the XML parser originated from
       James Clark, although you're able to link tDOM with other
       expat versions or the library provided by the system.

    *  building a DOM tree from XML in one go implemented in C for
       maximum performance and minimum memory usage, and DOM I and II
       methods to work on such a tree using either a OO-like or a
       handle syntax.

    *  a Tcl interface to expat for event-like (SAX-like) XML parsing.

    *  a complete, compliant and fast XPath implementation in C
       following the November 99 W3C recommendation for navigating and
       data extraction.

    *  a fast XSLT implementation in C following the W3C Recommendation
       16 November 1999.
    
    *  optional DTD validation.

    *  a JSON parser which parses any possible JSON input into a DOM
       tree without losing information.

    *  an efficient and Tcl'ish way to create XML and HTML documents
       and JSON string.

    *  as build option an interface to the gumbo HTML5 parser, which
       also digests almost any other HTML.

    *  an even faster simple XML parser for trusted XML input.

    *  A slim Tcl interface to use expat as pull-parser.



    *  additional convenience methods.
 
    *  and more.


DOCUMENTATION


    The documentation is included into the source distribution in HTML
    and man format. Alternatively, read it online starting at
    http://tdom.org/index.html/doc/trunk/doc/index.html


GETTING THE CODE


    The development repository is hosted at http://tdom.org and is
    mirrored at http://core.tcl.tk/tdom. You are encouraged to use
    trunk.





    If you insist on using an older tDOM with lesser features and
    probably more bugs, you should use the latest release 0.9.1. Get
    the source code release from
    http://tdom.org/downloads/tdom-0.9.1-src.tgz or
    http://tdom.org/downloads/tdom-0.9.1-src.zip

    Windows binaries (32 bit as well as 64 bit) of the 0.9.1 release
    are also available. Get it from
    http://tdom.org/downloads/tdom-0.9.1-windows-x64.zip and 
    http://tdom.org/downloads/tdom-0.9.1-windows-x86.zip
    
    The provided windows binaries include (statically linked) the
    HTML5 parser.


COMPILING tDOM


    Depending on your platform (unix/mac or win), go to the
    corresponding directory and invoke the configure script:

        ../configure
        make 
        make test
        make install

    Alternatively, you can build the tDOM package in just about any
    directory elsewhere on the filesystem (since TEA-compatible).
    
    You might also want to do "../configure --help" to get a list of
    all supported options of the configure script. In the "unix"
    directory there is a "CONFIG" file containing some examples on how
    to invoke the "configure" script for some common cases. You can
    peek there. This file also includes a short description of the
    tDOM specific configure options.

    Since tDOM is TEA-compatible you should be able to build it using
    the MinGW build environment for Windows. There is also the MSVC
    nmake file so you can compile the package with Microsoft tools.
    Refer to the README in the win directory for more details about
    building on Windows.

    The compile process will build the tDOM shared library suitable for
    loading into the Tcl shell using standard "package require" mechanism.


REPORTING BUGS


    Please head to http://tdom.org/index.html/ticket and click on "New
    Ticket". Log in as anonymous and report your findings. If you
    prefer to have an individual login write Rolf a mail.


HISTORY


    tDOM was started by Jochen Loewer (loewerj@hotmail.com) and
    developed by Jochen and Rolf Ade (rolf@pointsman.de) with
    contributions by Zoran Vasiljevic (zv@archiware.com). Since more
    than a dozen years it is maintained and developed by Rolf Ade.






<
|
<

<
<
<
<
|

|
|
|

|
|
|
|

|

|
|
|

|
|
|
|

|
|

|
|

|
|

|

|

>
>
|
|
|


<
>

|
|
|


<
>

|
<
<
>
>
>
>

<
<
|
|
|

<
|
|
|
|
|
|


<
>

|
|

|
|
|
|

|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|


<
>

|
|
|


<
>

|
|
|
|
>
>
>
>
>
1

2

3




4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52

53
54
55


56
57
58
59
60


61
62
63
64

65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109

110
111
112
113
114
115
116
117
118
119
120


## tDOM - a XML / DOM / XPath / XSLT / HTML / JSON implementation for Tcl Version 0.9.2






### tDOM contains:

   *  for convenience expat 2.2.9, the XML parser originated from
      James Clark, although you're able to link tDOM with other
      expat versions or the library provided by the system.

   *  building a DOM tree from XML in one go implemented in C for
      maximum performance and minimum memory usage, and DOM I and II
      methods to work on such a tree using either a OO-like or a
      handle syntax.

   *  a Tcl interface to expat for event-like (SAX-like) XML parsing.

   *  a complete, compliant and fast XPath implementation in C
      following the November 99 W3C recommendation for navigating and
      data extraction.

   *  a fast XSLT implementation in C following the W3C Recommendation
      16 November 1999.
   
   *  optional DTD validation.

   *  a JSON parser which parses any possible JSON input into a DOM
      tree without losing information.

   *  an efficient and Tcl'ish way to create XML and HTML documents
      and JSON strings.

   *  as build option an interface to the gumbo HTML5 parser, which
      also digests almost any other HTML.

   *  an even faster simple XML parser for trusted XML input.

   *  a slim Tcl interface to use expat as pull-parser.

   *  a secure way to share DOM trees by threads

   *  additional convenience methods.

   *  and more.



### Documentation

The documentation is included into the source distribution in HTML and
man format. Alternatively, read it
[online](http://tdom.org/index.html/doc/trunk/doc/index.html).



### Getting the code

The development repository is hosted at <http://tdom.org> and is


mirrored at <http://core.tcl.tk/tdom>. You are invited to use trunk
which you get as
[tarball](http://tdom.org/index.html/tarball/trunk/tdom-trunk.tar.gz)
or as [zip archive](http://tdom.org/index.html/zip/trunk/tdom-trunk.zip)



The latest release is 0.9.1. Get the source code as
[tarball](http://tdom.org/downloads/tdom-0.9.1-src.tgz) or
as [zip archive](http://tdom.org/downloads/tdom-0.9.1-src.zip).


Windows binaries of the 0.9.1 release are also available. Get it for
[64 bit](http://tdom.org/downloads/tdom-0.9.1-windows-x64.zip or [32
bit](http://tdom.org/downloads/tdom-0.9.1-windows-x86.zip).

The provided windows binaries include (statically linked) the
HTML5 parser.



### Compiling tdom

Depending on your platform (unix/mac or win), go to the
corresponding directory and invoke the configure script:

    ../configure
    make 
    make test
    make install

Alternatively, you can build the tDOM package in just about any
directory elsewhere on the filesystem (since TEA-compatible).

You might also want to do "../configure --help" to get a list of
all supported options of the configure script. In the "unix"
directory there is a "CONFIG" file containing some examples on how
to invoke the "configure" script for some common cases. You can
peek there. This file also includes a short description of the
tDOM specific configure options.

Since tDOM is TEA-compatible you should be able to build it using
the MinGW build environment for Windows. There is also the MSVC
nmake file so you can compile the package with Microsoft tools.
Refer to the README in the win directory for more details about
building on Windows.

The compile process will build the tDOM shared library suitable for
loading into the Tcl shell using standard "package require" mechanism.



### Reporting bugs

Open a [ticket](http://tdom.org/index.html/ticket). Log in as
anonymous and report your findings. If you prefer to have an
individual login write Rolf a mail.



### History

tDOM was started by Jochen Loewer (loewerj@hotmail.com) and
developed by Jochen and Rolf Ade (rolf@pointsman.de) with
contributions by Zoran Vasiljevic (zv@archiware.com). Since more
than a dozen years it is maintained and developed by Rolf Ade.


### ... ahh, Licensing!!

Sigh. See LICENSE file.

Changes to doc/dom.xml.

300
301
302
303
304
305
306
307
308
309
310
311




312
313
314
315
316
317
318
                with the <m>-html5</m> option. If this option is
                given, no node within the created DOM tree will be
                internally marked as placed into an XML Namespace,
                even if there is a default namespace in scope for
                un-prefixed elements or even if the element has a
                defined namespace prefix. One consequence is that
                XPath node expressions on such a DOM tree doesn't work
                as expected. Prefixed element nodes can't be selected
                and element nodes without prefix will be seen by XPath
                expressions as if they are not in any namespace (no
                matter if they are in fact should be in a default
                namespace).




                </desc>
              </optdef>

            </optlist>
<p/>
</desc>
        </commanddef>







|
|
|
|
|
>
>
>
>







300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
                with the <m>-html5</m> option. If this option is
                given, no node within the created DOM tree will be
                internally marked as placed into an XML Namespace,
                even if there is a default namespace in scope for
                un-prefixed elements or even if the element has a
                defined namespace prefix. One consequence is that
                XPath node expressions on such a DOM tree doesn't work
                as may be expected. Prefixed element nodes can't be
                selected naively and element nodes without prefix will
                be seen by XPath expressions as if they are not in any
                namespace (no matter if they are in fact should be in
                a default namespace). If you need to inject prefixed
                node names into an XPath expression use the '%' syntax
                described in the documentation of the of the
                <command>domNode</command> command method
                <method>>selectNodes</method>.
                </desc>
              </optdef>

            </optlist>
<p/>
</desc>
        </commanddef>

Changes to doc/domDoc.html.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119










120
121
122
123
124
125
126
...
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
...
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
<html>
<head>
<link rel="stylesheet" href="manpage.css"><title>tDOM manual: domDoc</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8">
</head><body>
<div class="header">
<div class="navbar" align="center">
<a href="#SECTid0x556942783d40">NAME</a> · <a href="#SECTid0x556942762ba0">SYNOPSIS</a> · <a href="#SECTid0x556942812d40">DESCRIPTION </a> · <a href="#SECTid0x55694287cb70">SEE ALSO</a> · <a href="#SECTid0x55694287cf00">KEYWORDS</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0x556942783d40">NAME</a></h2><p class="namesection">
<b class="names">domDoc - </b><br>Manipulates an instance of a DOM document object</p>
  
  <h2><a name="SECTid0x556942762ba0">SYNOPSIS</a></h2><pre class="syntax">domDocObjCmd <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre><pre class="syntax">domDoc <i class="m">docToken</i> <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre>

  <h2><a name="SECTid0x556942812d40">DESCRIPTION </a></h2><p>This command manipulates one particular instance of a document
object. <i class="m">method</i> indicates a specific method of the document class. These
methods should closely conform to the W3C recommendation "Document Object Model
(Core) Level 1" (<a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html</a>). Look
at these documents for a deeper understanding of the functionality.</p><p>The valid methods are:</p><dl class="commandlist">
        
          <dt>
<b class="method">documentElement</b> ?<i class="m">objVar</i>?</dt>
................................................................................
          <dt><b class="method">getDefaultOutputMethod</b></dt>
          <dd>Returns the default output method of the document. This is
usually a result of a XSLT transformation.</dd>
        

      
        <dt>
<b class="method">asXML</b> <b class="option">?-indent none/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-doctypeDeclaration &lt;boolean&gt;?</b> <b class="option">-xmlDeclaration &lt;boolean&gt;?</b> <b class="option">-encString &lt;string&gt;</b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b>
</dt>
        <dd>
<p>Returns the DOM tree as an (optional indented) XML
        string or sends the output directly to the given
        channelId.</p>











        <p>If the option <i class="m">-escapeNonASCII</i> is given,
        every non 7 bit ASCII character in attribute values or element
        PCDATA content will be escaped as character reference in
        decimal representation.</p>

        <p>The flag <i class="m">-doctypeDeclaration</i> determines whether
        there will be a DOCTYPE declaration emitted before the first
................................................................................
<i class="m">xpathQuery</i> to the document. The context node of the query is the root
node in the sense of the XPath recommendation (not the document element). The
result can be a string/value, a list of strings, a list of nodes or a list
of attribute name / value pairs. If <i class="m">typeVar</i> is given
the result type name is stored into that variable (empty,
bool, number, string, nodes, attrnodes or mixed).</p>

<p>The argument <i class="m">xpathQuery</i> has to be a valid XPath
expression. However, there is one exception to that rule. Tcl variable
names can appear in the XPath statement at any position where it is
legal according to the rules of the XPath syntax to put an XPath
variable. The value of the variable is substituted for the variable
name. Ignoring the syntax rules of XPath the Tcl variable name may be
any legal Tcl var name: local variables, global variables, array
entries and so on.  The value will always be seen as string literal by
the xpath engine. Cast the value explicitly with the according xpath
functions (number(), boolean()) to another data type, if needed.</p>

<p>The option <i class="m">-namespaces</i> expects a tcl list with prefix /
namespace pairs as argument. If this option is not given, then any
namespace prefix within the xpath expression will be first resolved
against the list of prefix / namespace pairs set with the
selectNodesNamespaces method for the document the node belongs to. If
this fails, then the namespace definitions in scope of the context
node will be used to resolve the prefix. If this option is given, any
namespace prefix within the xpath expression will be first resolved
against that given list (and ignoring the document global prefix /
namespace list). If the list binds the same prefix to different
namespaces, then the first binding will win.  If this fails, then the
namespace definitions in scope of the context node will be used to
resolve the prefix, as usual.</p>

<p>If the <i class="m">-cache</i> option is used with a true value, then the
<i class="m">xpathQuery</i> will be looked up in a document specific cache. If
the query is found, then the stored pre-compiled query will be used.
If the query isn't found, it will be compiled and stored in the cache,
for use in further calls. Please notice, that the <i class="m">xpathQuery</i> as
given as string is used as key for the cache. This means that equal
XPath expressions, which differ only in white space, are treated as
different cache entries. Special care is needed if the XPath
expression includes namespace prefixes or references to tcl variables.
Both namespace prefixes and tcl variable references will be resolved
according to the XML prefix namespace mappings and tcl variable values
at expression compilation time. If the same XPath expression is used
later on in a context with other XML prefix namespace mappings or
values of the used tcl variables, make sure to first remove the
compiled expression from the cache with the help of the
<b class="method">deleteXPathCache</b> method, to force a recompilation.
Without using the <i class="m">-cache</i> option such consideration is never
needed.</p>

<p>Examples:</p>
          <pre class="example">set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ]
foreach paragraph $paragraphNodes {
    lappend  values [$paragraph selectNodes attribute::type]
}

set doc [dom parse {&lt;doc xmlns="http://www.defaultnamespace.org"&gt;&lt;child/&gt;&lt;/doc&gt;}]
set root [$doc documentElement]
set childNodes [$root selectNodes -namespaces {default http://www.defaultnamespace.org} default:child]</pre>

          </dd>
      

      
        <dt>
<b class="method">baseURI</b> <i class="m">?URI?</i>
</dt>
................................................................................

  </dl><p>Otherwise, if an unknown method name is given, the command with the
same name as the given method within the namespace <tt class="samp">::dom::domDoc</tt> is
tried to be executed. This allows quick method additions on Tcl level.</p><p>Newly created nodes are appended to a hidden fragment list. If they
are not moved into the tree they are automatically deleted as soon as the whole
document gets deleted.</p>

    <h2><a name="SECTid0x55694287cb70">SEE ALSO</a></h2><p class="seealso">dom, domNode</p>

    <h2><a name="SECTid0x55694287cf00">KEYWORDS</a></h2><p class="keywords">
<a class="keyword" href="keyword-index.html#KW-DOMnodecreation">DOM node creation</a>, <a class="keyword" href="keyword-index.html#KW-documentelement">document element</a>
</p>

</div><hr class="navsep"><div class="navbar" align="center">
<a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a>
</div>
</body>
</html>






|


|


|

|







 







|






>
>
>
>
>
>
>
>
>
>







 







|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|

|








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
...
596
597
598
599
600
601
602
603
604
605
606


















































607
608
609
610
611
612
613
...
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
<html>
<head>
<link rel="stylesheet" href="manpage.css"><title>tDOM manual: domDoc</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8">
</head><body>
<div class="header">
<div class="navbar" align="center">
<a href="#SECTid0x558e11bed630">NAME</a> · <a href="#SECTid0x558e11b23bb0">SYNOPSIS</a> · <a href="#SECTid0x558e11bcbd50">DESCRIPTION </a> · <a href="#SECTid0x558e11c389e0">SEE ALSO</a> · <a href="#SECTid0x558e11c38d70">KEYWORDS</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0x558e11bed630">NAME</a></h2><p class="namesection">
<b class="names">domDoc - </b><br>Manipulates an instance of a DOM document object</p>
  
  <h2><a name="SECTid0x558e11b23bb0">SYNOPSIS</a></h2><pre class="syntax">domDocObjCmd <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre><pre class="syntax">domDoc <i class="m">docToken</i> <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre>

  <h2><a name="SECTid0x558e11bcbd50">DESCRIPTION </a></h2><p>This command manipulates one particular instance of a document
object. <i class="m">method</i> indicates a specific method of the document class. These
methods should closely conform to the W3C recommendation "Document Object Model
(Core) Level 1" (<a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html</a>). Look
at these documents for a deeper understanding of the functionality.</p><p>The valid methods are:</p><dl class="commandlist">
        
          <dt>
<b class="method">documentElement</b> ?<i class="m">objVar</i>?</dt>
................................................................................
          <dt><b class="method">getDefaultOutputMethod</b></dt>
          <dd>Returns the default output method of the document. This is
usually a result of a XSLT transformation.</dd>
        

      
        <dt>
<b class="method">asXML</b> <b class="option">?-indent none/tabs/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-doctypeDeclaration &lt;boolean&gt;?</b> <b class="option">-xmlDeclaration &lt;boolean&gt;?</b> <b class="option">-encString &lt;string&gt;</b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b>
</dt>
        <dd>
<p>Returns the DOM tree as an (optional indented) XML
        string or sends the output directly to the given
        channelId.</p>

        <p>The -indent option requires "no", "none", "tabs" or a
        natural number betwenn 0 and 8, both included, as value. With
        the values "no" or "none" no additional white space outside of
        markup will be added to the serialization. I. Otherwise, it's
        a "pretty-print" serialization, due to inserting white space
        between end and the next start tag according to the nesting
        level. The level indentation wide is given with the number. If
        the value is "tabs", then indentation is done with tabs, one
        tab per level.</p>
        
        <p>If the option <i class="m">-escapeNonASCII</i> is given,
        every non 7 bit ASCII character in attribute values or element
        PCDATA content will be escaped as character reference in
        decimal representation.</p>

        <p>The flag <i class="m">-doctypeDeclaration</i> determines whether
        there will be a DOCTYPE declaration emitted before the first
................................................................................
<i class="m">xpathQuery</i> to the document. The context node of the query is the root
node in the sense of the XPath recommendation (not the document element). The
result can be a string/value, a list of strings, a list of nodes or a list
of attribute name / value pairs. If <i class="m">typeVar</i> is given
the result type name is stored into that variable (empty,
bool, number, string, nodes, attrnodes or mixed).</p>

          <p>See the documentation of the of the
          <b class="command">domNode</b> command method
          <b class="method">selectNodes</b> for a detailed description of
          the arguments.</p>


















































          </dd>
      

      
        <dt>
<b class="method">baseURI</b> <i class="m">?URI?</i>
</dt>
................................................................................

  </dl><p>Otherwise, if an unknown method name is given, the command with the
same name as the given method within the namespace <tt class="samp">::dom::domDoc</tt> is
tried to be executed. This allows quick method additions on Tcl level.</p><p>Newly created nodes are appended to a hidden fragment list. If they
are not moved into the tree they are automatically deleted as soon as the whole
document gets deleted.</p>

    <h2><a name="SECTid0x558e11c389e0">SEE ALSO</a></h2><p class="seealso">dom, domNode</p>

    <h2><a name="SECTid0x558e11c38d70">KEYWORDS</a></h2><p class="keywords">
<a class="keyword" href="keyword-index.html#KW-DOMnodecreation">DOM node creation</a>, <a class="keyword" href="keyword-index.html#KW-documentelement">document element</a>
</p>

</div><hr class="navsep"><div class="navbar" align="center">
<a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a>
</div>
</body>
</html>

Changes to doc/domDoc.n.

233
234
235
236
237
238
239
240
241
242
243
244
245
246










247
248
249
250
251
252
253
...
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
Tcl object commands (for nodes, fragment/new nodes, the document object itself)
and the underlying DOM tree.
.TP
\&\fB\fBgetDefaultOutputMethod\fP
\&\fRReturns the default output method of the document. This is
usually a result of a XSLT transformation.
.TP
\&\fB\fBasXML\fP \fB?-indent none/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB?-doctypeDeclaration <boolean>?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP
\&\fR
.RS
.PP
Returns the DOM tree as an (optional indented) XML
string or sends the output directly to the given
channelId.










.PP
If the option \fI-escapeNonASCII\fR is given,
every non 7 bit ASCII character in attribute values or element
PCDATA content will be escaped as character reference in
decimal representation.
.PP
The flag \fI-doctypeDeclaration\fR determines whether
................................................................................
\&\fIxpathQuery\fR to the document. The context node of the query is the root
node in the sense of the XPath recommendation (not the document element). The
result can be a string/value, a list of strings, a list of nodes or a list
of attribute name / value pairs. If \fItypeVar\fR is given
the result type name is stored into that variable (empty,
bool, number, string, nodes, attrnodes or mixed).
.PP
The argument \fIxpathQuery\fR has to be a valid XPath
expression. However, there is one exception to that rule. Tcl variable
names can appear in the XPath statement at any position where it is
legal according to the rules of the XPath syntax to put an XPath
variable. The value of the variable is substituted for the variable
name. Ignoring the syntax rules of XPath the Tcl variable name may be
any legal Tcl var name: local variables, global variables, array
entries and so on.  The value will always be seen as string literal by
the xpath engine. Cast the value explicitly with the according xpath
functions (number(), boolean()) to another data type, if needed.
.PP
The option \fI-namespaces\fR expects a tcl list with prefix /
namespace pairs as argument. If this option is not given, then any
namespace prefix within the xpath expression will be first resolved
against the list of prefix / namespace pairs set with the
selectNodesNamespaces method for the document the node belongs to. If
this fails, then the namespace definitions in scope of the context
node will be used to resolve the prefix. If this option is given, any
namespace prefix within the xpath expression will be first resolved
against that given list (and ignoring the document global prefix /
namespace list). If the list binds the same prefix to different
namespaces, then the first binding will win.  If this fails, then the
namespace definitions in scope of the context node will be used to
resolve the prefix, as usual.
.PP
If the \fI-cache\fR option is used with a true value, then the
\&\fIxpathQuery\fR will be looked up in a document specific cache. If
the query is found, then the stored pre-compiled query will be used.
If the query isn't found, it will be compiled and stored in the cache,
for use in further calls. Please notice, that the \fIxpathQuery\fR as
given as string is used as key for the cache. This means that equal
XPath expressions, which differ only in white space, are treated as
different cache entries. Special care is needed if the XPath
expression includes namespace prefixes or references to tcl variables.
Both namespace prefixes and tcl variable references will be resolved
according to the XML prefix namespace mappings and tcl variable values
at expression compilation time. If the same XPath expression is used
later on in a context with other XML prefix namespace mappings or
values of the used tcl variables, make sure to first remove the
compiled expression from the cache with the help of the
\&\fBdeleteXPathCache\fP method, to force a recompilation.
Without using the \fI-cache\fR option such consideration is never
needed.
.PP
Examples:

          
.CS
set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ]
foreach paragraph $paragraphNodes {
    lappend  values [$paragraph selectNodes attribute::type]
}

set doc [dom parse {<doc xmlns="http://www.defaultnamespace.org"><child/></doc>}]
set root [$doc documentElement]
set childNodes [$root selectNodes -namespaces {default http://www.defaultnamespace.org} default:child]
.CE
.RE
.TP
\&\fB\fBbaseURI\fP \fI?URI?\fB
\&\fRReturns the present baseURI of the document. If the optional
argument URI is given, sets the base URI of the document to the given URI.
.TP
\&\fB\fBappendFromScript\fP \fItclScript\fB







|






>
>
>
>
>
>
>
>
>
>







 







|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
...
625
626
627
628
629
630
631
632
633
634
635
636
637



















































638
639
640
641
642
643
644
Tcl object commands (for nodes, fragment/new nodes, the document object itself)
and the underlying DOM tree.
.TP
\&\fB\fBgetDefaultOutputMethod\fP
\&\fRReturns the default output method of the document. This is
usually a result of a XSLT transformation.
.TP
\&\fB\fBasXML\fP \fB?-indent none/tabs/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB?-doctypeDeclaration <boolean>?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP
\&\fR
.RS
.PP
Returns the DOM tree as an (optional indented) XML
string or sends the output directly to the given
channelId.
.PP
The -indent option requires "no", "none", "tabs" or a
natural number betwenn 0 and 8, both included, as value. With
the values "no" or "none" no additional white space outside of
markup will be added to the serialization. I. Otherwise, it's
a "pretty-print" serialization, due to inserting white space
between end and the next start tag according to the nesting
level. The level indentation wide is given with the number. If
the value is "tabs", then indentation is done with tabs, one
tab per level.
.PP
If the option \fI-escapeNonASCII\fR is given,
every non 7 bit ASCII character in attribute values or element
PCDATA content will be escaped as character reference in
decimal representation.
.PP
The flag \fI-doctypeDeclaration\fR determines whether
................................................................................
\&\fIxpathQuery\fR to the document. The context node of the query is the root
node in the sense of the XPath recommendation (not the document element). The
result can be a string/value, a list of strings, a list of nodes or a list
of attribute name / value pairs. If \fItypeVar\fR is given
the result type name is stored into that variable (empty,
bool, number, string, nodes, attrnodes or mixed).
.PP
See the documentation of the of the
.TP
\&\fBdomNode
\&\fR command method
\&\fBselectNodes\fP for a detailed description of
the arguments.



















































.RE
.TP
\&\fB\fBbaseURI\fP \fI?URI?\fB
\&\fRReturns the present baseURI of the document. If the optional
argument URI is given, sets the base URI of the document to the given URI.
.TP
\&\fB\fBappendFromScript\fP \fItclScript\fB

Changes to doc/domDoc.xml.

107
108
109
110
111
112
113
114
115
116
117
118










119
120
121
122
123
124
125
...
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
        <commanddef>
          <command><method>getDefaultOutputMethod</method></command>
          <desc>Returns the default output method of the document. This is
usually a result of a XSLT transformation.</desc>
        </commanddef>

      <commanddef>
        <command><method>asXML</method> <option>?-indent none/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>?-doctypeDeclaration &lt;boolean&gt;?</option> <option>-xmlDeclaration &lt;boolean&gt;?</option> <option>-encString &lt;string&gt;</option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command>
        <desc><p>Returns the DOM tree as an (optional indented) XML
        string or sends the output directly to the given
        channelId.</p>











        <p>If the option <m>-escapeNonASCII</m> is given,
        every non 7 bit ASCII character in attribute values or element
        PCDATA content will be escaped as character reference in
        decimal representation.</p>

        <p>The flag <m>-doctypeDeclaration</m> determines whether
        there will be a DOCTYPE declaration emitted before the first
................................................................................
<m>xpathQuery</m> to the document. The context node of the query is the root
node in the sense of the XPath recommendation (not the document element). The
result can be a string/value, a list of strings, a list of nodes or a list
of attribute name / value pairs. If <m>typeVar</m> is given
the result type name is stored into that variable (empty,
bool, number, string, nodes, attrnodes or mixed).</p>

<p>The argument <m>xpathQuery</m> has to be a valid XPath
expression. However, there is one exception to that rule. Tcl variable
names can appear in the XPath statement at any position where it is
legal according to the rules of the XPath syntax to put an XPath
variable. The value of the variable is substituted for the variable
name. Ignoring the syntax rules of XPath the Tcl variable name may be
any legal Tcl var name: local variables, global variables, array
entries and so on.  The value will always be seen as string literal by
the xpath engine. Cast the value explicitly with the according xpath
functions (number(), boolean()) to another data type, if needed.</p>

<p>The option <m>-namespaces</m> expects a tcl list with prefix /
namespace pairs as argument. If this option is not given, then any
namespace prefix within the xpath expression will be first resolved
against the list of prefix / namespace pairs set with the
selectNodesNamespaces method for the document the node belongs to. If
this fails, then the namespace definitions in scope of the context
node will be used to resolve the prefix. If this option is given, any
namespace prefix within the xpath expression will be first resolved
against that given list (and ignoring the document global prefix /
namespace list). If the list binds the same prefix to different
namespaces, then the first binding will win.  If this fails, then the
namespace definitions in scope of the context node will be used to
resolve the prefix, as usual.</p>

<p>If the <m>-cache</m> option is used with a true value, then the
<m>xpathQuery</m> will be looked up in a document specific cache. If
the query is found, then the stored pre-compiled query will be used.
If the query isn't found, it will be compiled and stored in the cache,
for use in further calls. Please notice, that the <m>xpathQuery</m> as
given as string is used as key for the cache. This means that equal
XPath expressions, which differ only in white space, are treated as
different cache entries. Special care is needed if the XPath
expression includes namespace prefixes or references to tcl variables.
Both namespace prefixes and tcl variable references will be resolved
according to the XML prefix namespace mappings and tcl variable values
at expression compilation time. If the same XPath expression is used
later on in a context with other XML prefix namespace mappings or
values of the used tcl variables, make sure to first remove the
compiled expression from the cache with the help of the
<method>deleteXPathCache</method> method, to force a recompilation.
Without using the <m>-cache</m> option such consideration is never
needed.</p>

<p>Examples:</p>
          <example>set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ]
foreach paragraph $paragraphNodes {
    lappend  values [$paragraph selectNodes attribute::type]
}

set doc [dom parse {&lt;doc xmlns="http://www.defaultnamespace.org"&gt;&lt;child/&gt;&lt;/doc&gt;}]
set root [$doc documentElement]
set childNodes [$root selectNodes -namespaces {default http://www.defaultnamespace.org} default:child]</example>

          </desc>
      </commanddef>

      <commanddef>
        <command><method>baseURI</method> <m>?URI?</m></command>
        <desc>Returns the present baseURI of the document. If the optional 
argument URI is given, sets the base URI of the document to the given URI.</desc>







|




>
>
>
>
>
>
>
>
>
>







 







|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
...
547
548
549
550
551
552
553
554
555
556
557


















































558
559
560
561
562
563
564
        <commanddef>
          <command><method>getDefaultOutputMethod</method></command>
          <desc>Returns the default output method of the document. This is
usually a result of a XSLT transformation.</desc>
        </commanddef>

      <commanddef>
        <command><method>asXML</method> <option>?-indent none/tabs/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>?-doctypeDeclaration &lt;boolean&gt;?</option> <option>-xmlDeclaration &lt;boolean&gt;?</option> <option>-encString &lt;string&gt;</option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command>
        <desc><p>Returns the DOM tree as an (optional indented) XML
        string or sends the output directly to the given
        channelId.</p>

        <p>The -indent option requires "no", "none", "tabs" or a
        natural number betwenn 0 and 8, both included, as value. With
        the values "no" or "none" no additional white space outside of
        markup will be added to the serialization. I. Otherwise, it's
        a "pretty-print" serialization, due to inserting white space
        between end and the next start tag according to the nesting
        level. The level indentation wide is given with the number. If
        the value is "tabs", then indentation is done with tabs, one
        tab per level.</p>
        
        <p>If the option <m>-escapeNonASCII</m> is given,
        every non 7 bit ASCII character in attribute values or element
        PCDATA content will be escaped as character reference in
        decimal representation.</p>

        <p>The flag <m>-doctypeDeclaration</m> determines whether
        there will be a DOCTYPE declaration emitted before the first
................................................................................
<m>xpathQuery</m> to the document. The context node of the query is the root
node in the sense of the XPath recommendation (not the document element). The
result can be a string/value, a list of strings, a list of nodes or a list
of attribute name / value pairs. If <m>typeVar</m> is given
the result type name is stored into that variable (empty,
bool, number, string, nodes, attrnodes or mixed).</p>

          <p>See the documentation of the of the
          <command>domNode</command> command method
          <method>selectNodes</method> for a detailed description of
          the arguments.</p>


















































          </desc>
      </commanddef>

      <commanddef>
        <command><method>baseURI</method> <m>?URI?</m></command>
        <desc>Returns the present baseURI of the document. If the optional 
argument URI is given, sets the base URI of the document to the given URI.</desc>

Changes to doc/domNode.html.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
...
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
<html>
<head>
<link rel="stylesheet" href="manpage.css"><title>tDOM manual: domNode</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8">
</head><body>
<div class="header">
<div class="navbar" align="center">
<a href="#SECTid0x5569427a27e0">NAME</a> · <a href="#SECTid0x556942858860">SYNOPSIS</a> · <a href="#SECTid0x556942833710"> DESCRIPTION </a> · <a href="#SECTid0x556942885030">SEE ALSO</a> · <a href="#SECTid0x5569428853c0">KEYWORDS</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0x5569427a27e0">NAME</a></h2><p class="namesection">
<b class="names">domNode - </b><br>Manipulates an instance of a DOM node object</p>



  <h2><a name="SECTid0x556942858860">SYNOPSIS</a></h2><pre class="syntax">$nodeObject <i class="m">method</i> <i class="m">arg arg ...</i>
</pre><pre class="syntax">domNode <i class="m">nodeToken</i> <i class="m">method</i> <i class="m">arg arg ...</i>
</pre>
  <h2><a name="SECTid0x556942833710"> DESCRIPTION </a></h2><p>This command manipulates one particular instance of a DOM node object.
<i class="m">method</i> indicates a specific method of the node class. These methods
should closely conform to the W3C recommendation "Document Object Model
(Core) Level 1" (<a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html</a>)
as well to parts of the W3C draft "XML Pointer Language (XPointer)"
(<a href="http://www.w3.org/TR/1998/WD-xptr-19980303">http://www.w3.org/TR/1998/WD-xptr-19980303</a>).
Please note, that the XPointer methods are deprecated. Use DOM methods
or XPath expressions instead of them.</p><p>The selectNodes method implements the "XML Path
................................................................................
        <dt><b class="method">asList</b></dt>
        <dd>Returns the DOM substree starting form the current node as a
nested Tcl list.</dd>
      

      
        <dt>
<b class="method">asXML</b> <b class="option">?-indent none/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">-xmlDeclaration &lt;boolean&gt;?</b> <b class="option">-encString &lt;string&gt;</b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b>
</dt>
        <dd>
<p>Returns the DOM substree starting from the current
        node as the root node of the result as an (optional indented)
        XML string or sends the output directly to the given
        channelId.</p>

        <p>If the option <i class="m">-escapeNonASCII</i> is given,
        every non 7 bit ASCII character in attribute values or element
        PCDATA content will be escaped as character reference in
        decimal representation.</p>

        <p>The flag <i class="m">-xmlDeclaration</i> determines whether there
        will be an XML Declaration and a newline emitted before
        anything else. The default is, to do not. If this flag is
        given with a true argument then</p>

        <p>
<i class="m">-encString</i> sets the encoding value in the XML
        Declaration. Otherwise, this option is ignored. Please note,
        that this option just enhance the string representation of the
        generated XML Declaration with an encoding information string,
        nothing more. It's up to the user to handle encoding in case
        of writing to a channel or reparsing.</p>
            
        <p>If the option <i class="m">-escapeAllQuot</i> is given,
        quotation marks will be escaped with &amp;quot; even in text
        content of elements.</p>

        <p>If the option <i class="m">-indentAttrs</i> is
        given, then attributes will each be separated with newlines
        and indented to the same level as the parent node plus the
        value given as argument to <i class="m">-indentAttrs</i> (0..8).</p>

        <p>If the option <i class="m">-nogtescape</i> is given then the
        character '&gt;' won't get escaped in attribute values and text
        content of elements. The default is to escape this
        character.</p>

        <p>If the option <i class="m">-noEmptyElementTag</i> is given then no
        empty tag syntax will be used. Instead, if an element has
        empty content it will be serialized with an element start tag
        and an immediately following element end tag.</p>
</dd>

      

      
        <dt>
<b class="method">asHTML</b> <b class="option">?-channel channelId?</b>
<b class="option">?-escapeNonASCII?</b>  <b class="option">?-htmlEntities?</b>
</dt>
................................................................................
      

    </dl><p>Otherwise, if an unknown method name is given, the command with the same
name as the given method within the namespace <tt class="l">::dom::domNode</tt> is tried to
be executed. This allows quick method additions on Tcl level.</p>


  <h2><a name="SECTid0x556942885030">SEE ALSO</a></h2><p class="seealso">dom, domDoc</p>
  
  <h2><a name="SECTid0x5569428853c0">KEYWORDS</a></h2><p class="keywords">
<a class="keyword" href="keyword-index.html#KW-XML">XML</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-document">document</a>, <a class="keyword" href="keyword-index.html#KW-node">node</a>, <a class="keyword" href="keyword-index.html#KW-parsing">parsing</a>
</p>
  
</div><hr class="navsep"><div class="navbar" align="center">
<a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a>
</div>
</body>
</html>






|


|




|


|







 







|







|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<







 







|

|








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516

































517

518
519
520
521
522
523
524
...
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
<html>
<head>
<link rel="stylesheet" href="manpage.css"><title>tDOM manual: domNode</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8">
</head><body>
<div class="header">
<div class="navbar" align="center">
<a href="#SECTid0x55d13d94e630">NAME</a> · <a href="#SECTid0x55d13d884bb0">SYNOPSIS</a> · <a href="#SECTid0x55d13d92cc90"> DESCRIPTION </a> · <a href="#SECTid0x55d13d99ded0">SEE ALSO</a> · <a href="#SECTid0x55d13d99e260">KEYWORDS</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0x55d13d94e630">NAME</a></h2><p class="namesection">
<b class="names">domNode - </b><br>Manipulates an instance of a DOM node object</p>



  <h2><a name="SECTid0x55d13d884bb0">SYNOPSIS</a></h2><pre class="syntax">$nodeObject <i class="m">method</i> <i class="m">arg arg ...</i>
</pre><pre class="syntax">domNode <i class="m">nodeToken</i> <i class="m">method</i> <i class="m">arg arg ...</i>
</pre>
  <h2><a name="SECTid0x55d13d92cc90"> DESCRIPTION </a></h2><p>This command manipulates one particular instance of a DOM node object.
<i class="m">method</i> indicates a specific method of the node class. These methods
should closely conform to the W3C recommendation "Document Object Model
(Core) Level 1" (<a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html</a>)
as well to parts of the W3C draft "XML Pointer Language (XPointer)"
(<a href="http://www.w3.org/TR/1998/WD-xptr-19980303">http://www.w3.org/TR/1998/WD-xptr-19980303</a>).
Please note, that the XPointer methods are deprecated. Use DOM methods
or XPath expressions instead of them.</p><p>The selectNodes method implements the "XML Path
................................................................................
        <dt><b class="method">asList</b></dt>
        <dd>Returns the DOM substree starting form the current node as a
nested Tcl list.</dd>
      

      
        <dt>
<b class="method">asXML</b> <b class="option">?-indent none/tabs/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-doctypeDeclaration &lt;boolean&gt;?</b> <b class="option">-xmlDeclaration &lt;boolean&gt;?</b> <b class="option">-encString &lt;string&gt;</b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b>
</dt>
        <dd>
<p>Returns the DOM substree starting from the current
        node as the root node of the result as an (optional indented)
        XML string or sends the output directly to the given
        channelId.</p>

        <p>See the documentation of the of the <b class="command"> domDoc
        </b> command method <b class="method">asXML</b> for a
        detailed description of the arguments.</p>

































        </dd>

      

      
        <dt>
<b class="method">asHTML</b> <b class="option">?-channel channelId?</b>
<b class="option">?-escapeNonASCII?</b>  <b class="option">?-htmlEntities?</b>
</dt>
................................................................................
      

    </dl><p>Otherwise, if an unknown method name is given, the command with the same
name as the given method within the namespace <tt class="l">::dom::domNode</tt> is tried to
be executed. This allows quick method additions on Tcl level.</p>


  <h2><a name="SECTid0x55d13d99ded0">SEE ALSO</a></h2><p class="seealso">dom, domDoc</p>
  
  <h2><a name="SECTid0x55d13d99e260">KEYWORDS</a></h2><p class="keywords">
<a class="keyword" href="keyword-index.html#KW-XML">XML</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-document">document</a>, <a class="keyword" href="keyword-index.html#KW-node">node</a>, <a class="keyword" href="keyword-index.html#KW-parsing">parsing</a>
</p>
  
</div><hr class="navsep"><div class="navbar" align="center">
<a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a>
</div>
</body>
</html>

Changes to doc/domNode.n.

501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518

519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551

552
553
554
555
556
557
558
\&\fRReturns the column number of that node in the originally parsed
XML.
.TP
\&\fB\fBasList\fP
\&\fRReturns the DOM substree starting form the current node as a
nested Tcl list.
.TP
\&\fB\fBasXML\fP \fB?-indent none/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP
\&\fR
.RS
.PP
Returns the DOM substree starting from the current
node as the root node of the result as an (optional indented)
XML string or sends the output directly to the given
channelId.
.PP
If the option \fI-escapeNonASCII\fR is given,
every non 7 bit ASCII character in attribute values or element

PCDATA content will be escaped as character reference in
decimal representation.
.PP
The flag \fI-xmlDeclaration\fR determines whether there
will be an XML Declaration and a newline emitted before
anything else. The default is, to do not. If this flag is
given with a true argument then
.PP
\&\fI-encString\fR sets the encoding value in the XML
Declaration. Otherwise, this option is ignored. Please note,
that this option just enhance the string representation of the
generated XML Declaration with an encoding information string,
nothing more. It's up to the user to handle encoding in case
of writing to a channel or reparsing.
.PP
If the option \fI-escapeAllQuot\fR is given,
quotation marks will be escaped with &quot; even in text
content of elements.
.PP
If the option \fI-indentAttrs\fR is
given, then attributes will each be separated with newlines
and indented to the same level as the parent node plus the
value given as argument to \fI-indentAttrs\fR (0..8).
.PP
If the option \fI-nogtescape\fR is given then the
character '>' won't get escaped in attribute values and text
content of elements. The default is to escape this
character.
.PP
If the option \fI-noEmptyElementTag\fR is given then no
empty tag syntax will be used. Instead, if an element has
empty content it will be serialized with an element start tag
and an immediately following element end tag.

.RE
.TP
\&\fB\fBasHTML\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP  \fB?-htmlEntities?\fP
\&\fRReturns the DOM substree starting from the current node as the
root node of the result serialized according to HTML rules (HTML elements are
recognized regardless of case, without end tags for empty HTML elements etc.),
as string or sends the output directly to the given channelId. If the option







|








|
<
>
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>







501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517

518
519
520































521
522
523
524
525
526
527
528
\&\fRReturns the column number of that node in the originally parsed
XML.
.TP
\&\fB\fBasList\fP
\&\fRReturns the DOM substree starting form the current node as a
nested Tcl list.
.TP
\&\fB\fBasXML\fP \fB?-indent none/tabs/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB?-doctypeDeclaration <boolean>?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP
\&\fR
.RS
.PP
Returns the DOM substree starting from the current
node as the root node of the result as an (optional indented)
XML string or sends the output directly to the given
channelId.
.PP
See the documentation of the of the

.TP
\&\fB domDoc
\&\fR command method \fBasXML\fP for a































detailed description of the arguments.
.RE
.TP
\&\fB\fBasHTML\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP  \fB?-htmlEntities?\fP
\&\fRReturns the DOM substree starting from the current node as the
root node of the result serialized according to HTML rules (HTML elements are
recognized regardless of case, without end tags for empty HTML elements etc.),
as string or sends the output directly to the given channelId. If the option

Changes to doc/domNode.xml.

445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
      <commanddef>
        <command><method>asList</method></command>
        <desc>Returns the DOM substree starting form the current node as a
nested Tcl list.</desc>
      </commanddef>

      <commanddef>
        <command><method>asXML</method> <option>?-indent none/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>-xmlDeclaration &lt;boolean&gt;?</option> <option>-encString &lt;string&gt;</option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command>
        <desc><p>Returns the DOM substree starting from the current
        node as the root node of the result as an (optional indented)
        XML string or sends the output directly to the given
        channelId.</p>

        <p>If the option <m>-escapeNonASCII</m> is given,
        every non 7 bit ASCII character in attribute values or element
        PCDATA content will be escaped as character reference in
        decimal representation.</p>

        <p>The flag <m>-xmlDeclaration</m> determines whether there
        will be an XML Declaration and a newline emitted before
        anything else. The default is, to do not. If this flag is
        given with a true argument then</p>

        <p><m>-encString</m> sets the encoding value in the XML
        Declaration. Otherwise, this option is ignored. Please note,
        that this option just enhance the string representation of the
        generated XML Declaration with an encoding information string,
        nothing more. It's up to the user to handle encoding in case
        of writing to a channel or reparsing.</p>
            
        <p>If the option <m>-escapeAllQuot</m> is given,
        quotation marks will be escaped with &amp;quot; even in text
        content of elements.</p>

        <p>If the option <m>-indentAttrs</m> is
        given, then attributes will each be separated with newlines
        and indented to the same level as the parent node plus the
        value given as argument to <m>-indentAttrs</m> (0..8).</p>

        <p>If the option <m>-nogtescape</m> is given then the
        character '>' won't get escaped in attribute values and text
        content of elements. The default is to escape this
        character.</p>

        <p>If the option <m>-noEmptyElementTag</m> is given then no
        empty tag syntax will be used. Instead, if an element has
        empty content it will be serialized with an element start tag
        and an immediately following element end tag.</p></desc>

      </commanddef>

      <commanddef>
        <command><method>asHTML</method> <option>?-channel channelId?</option>
<option>?-escapeNonASCII?</option>  <option>?-htmlEntities?</option></command>
        <desc>Returns the DOM substree starting from the current node as the
root node of the result serialized according to HTML rules (HTML elements are







|





|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
































462
463
464
465
466
467
468
      <commanddef>
        <command><method>asList</method></command>
        <desc>Returns the DOM substree starting form the current node as a
nested Tcl list.</desc>
      </commanddef>

      <commanddef>
        <command><method>asXML</method> <option>?-indent none/tabs/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>?-doctypeDeclaration &lt;boolean&gt;?</option> <option>-xmlDeclaration &lt;boolean&gt;?</option> <option>-encString &lt;string&gt;</option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command>
        <desc><p>Returns the DOM substree starting from the current
        node as the root node of the result as an (optional indented)
        XML string or sends the output directly to the given
        channelId.</p>

        <p>See the documentation of the of the <command> domDoc
        </command> command method <method>asXML</method> for a
        detailed description of the arguments.</p>
        </desc>
































      </commanddef>

      <commanddef>
        <command><method>asHTML</method> <option>?-channel channelId?</option>
<option>?-escapeNonASCII?</option>  <option>?-htmlEntities?</option></command>
        <desc>Returns the DOM substree starting from the current node as the
root node of the result serialized according to HTML rules (HTML elements are

Changes to extensions/tnc/tnc.c.

2094
2095
2096
2097
2098
2099
2100




2101
2102
2103
2104
2105
2106
2107
    Tcl_HashEntry *entryPtr;
    Tcl_HashSearch search;

#ifdef TNC_DEBUG
    printf ("TncElementEndCommand start\n");
    printContentStack (tncdata);
#endif




    while (1) {
        if (!TncProbeElementEnd (tncdata)) {
            signalNotValid (userData, TNC_ERROR_ELEMENT_CAN_NOT_END_HERE);
            return;
        }
        if (tncdata->contentStack[tncdata->contentStackPtr - 1].deep == 0) {
            break;







>
>
>
>







2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
    Tcl_HashEntry *entryPtr;
    Tcl_HashSearch search;

#ifdef TNC_DEBUG
    printf ("TncElementEndCommand start\n");
    printContentStack (tncdata);
#endif
    /* Calling XML_StopParser() in an element start event doesn't
     * always prevent expat from calling the element end handler.
     * (Yes, it's an expat thing, raised a few bugs upstream.) */
    if (tncdata->status == TCL_ERROR) return;
    while (1) {
        if (!TncProbeElementEnd (tncdata)) {
            signalNotValid (userData, TNC_ERROR_ELEMENT_CAN_NOT_END_HERE);
            return;
        }
        if (tncdata->contentStack[tncdata->contentStackPtr - 1].deep == 0) {
            break;

Changes to generic/tcldom.c.

158
159
160
161
162
163
164


165
166
167
168
169
170
171
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
....
2874
2875
2876
2877
2878
2879
2880

2881




2882

2883
2884
2885
2886
2887
2888
2889
....
2910
2911
2912
2913
2914
2915
2916

2917




2918
2919
2920




2921
2922
2923
2924
2925
2926
2927
....
3005
3006
3007
3008
3009
3010
3011

3012




3013

3014
3015
3016
3017
3018
3019
3020
....
3100
3101
3102
3103
3104
3105
3106

3107
3108
3109
3110
3111
3112
3113
....
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
....
3191
3192
3193
3194
3195
3196
3197
3198
3199




3200

3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214

3215




3216

3217
3218
3219
3220
3221
3222
3223
....
3225
3226
3227
3228
3229
3230
3231
3232
3233




3234

3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248

3249




3250

3251
3252
3253
3254
3255
3256
3257
....
3264
3265
3266
3267
3268
3269
3270

3271
3272
3273
3274
3275
3276
3277
....
3364
3365
3366
3367
3368
3369
3370



3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
....
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481



3482
3483

3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501



3502
3503

3504
3505
3506
3507
3508
3509
3510
....
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
....
3812
3813
3814
3815
3816
3817
3818





3819
3820
3821
3822
3823
3824
3825
....
3827
3828
3829
3830
3831
3832
3833
3834

3835
3836
3837
3838
3839
3840
3841
#define SERIALIZE_DOCTYPE_DECLARATION 2
#define SERIALIZE_FOR_ATTR 4 
#define SERIALIZE_ESCAPE_NON_ASCII 8
#define SERIALIZE_HTML_ENTITIES 16
#define SERIALIZE_ESCAPE_ALL_QUOT 32
#define SERIALIZE_NO_GT_ESCAPE 64
#define SERIALIZE_NO_EMPTY_ELEMENT_TAG 128



/*----------------------------------------------------------------------------
|   Module Globals
|
\---------------------------------------------------------------------------*/
#ifndef TCL_THREADS
    static int        storeLineColumn       = 0;
................................................................................
    "    getElementsByTagNameNS uri localname    \n"
    "    createElement tagName ?objVar?          \n"
    "    createElementNS uri tagName ?objVar?    \n"
    "    createCDATASection data ?objVar?        \n"
    "    createTextNode text ?objVar?            \n"
    "    createComment text ?objVar?             \n"
    "    createProcessingInstruction target data ?objVar? \n"
    "    asXML ?-indent <none,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n"
    "    asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n"
    "    asText                                  \n"
    "    asJSON ?-indent <none,0..8>?            \n"
    "    getDefaultOutputMethod                  \n"
    "    publicId ?publicId?                     \n"
    "    systemId ?systemId?                     \n"
    "    internalSubset ?internalSubset?         \n"
................................................................................
    "    baseURI ?URI?                \n"
    "    localName                    \n"
    "    delete                       \n"
    "    getLine                      \n"
    "    getColumn                    \n"
    "    @<attrName> ?defaultValue?   \n"
    "    asList                       \n"
    "    asXML ?-indent <none,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n"
    "    asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n"
    "    asText                       \n"
    "    asJSON ?-indent <none,0..8>? \n"
    "    appendFromList nestedList    \n"
    "    appendFromScript script      \n"
    "    insertBeforeFromScript script ref \n"
    "    appendXML xmlString          \n"
................................................................................
|
\---------------------------------------------------------------------------*/
static Tcl_VarTraceProc  tcldom_docTrace;
static Tcl_CmdDeleteProc tcldom_docCmdDeleteProc;

static void tcldom_treeAsJSON(Tcl_Obj *jstring, domNode *node,
                              Tcl_Channel channel, int indent,
                              int level,
                              int inside);

#ifdef TCL_THREADS

static int tcldom_EvalLocked(Tcl_Interp* interp, Tcl_Obj** objv,
                             domDocument* doc, int flag);

static int tcldom_RegisterDocShared(domDocument* doc);
................................................................................
        writeChars(xmlString, chan, ((domTextNode*)node)->nodeValue,
                                    ((domTextNode*)node)->valueLength);
        writeChars(xmlString, chan, "]]>", 3);
        return;
    }

    if ((indent != -1) && doIndent) {

        for(i=0; i<level; i++) {




            writeChars(xmlString, chan, "        ", indent);

        }
    }

    if (node->nodeType == COMMENT_NODE) {
        writeChars(xmlString, chan, "<!--", 4);
        writeChars(xmlString, chan, ((domTextNode*)node)->nodeValue,
                                    ((domTextNode*)node)->valueLength);
................................................................................
    writeChars(xmlString, chan, node->nodeName, -1);

    attrs = node->firstAttr;
    while (attrs) {
        if (indentAttrs > -1) {
            writeChars(xmlString, chan, "\n", 1);
            if ((indent != -1) && doIndent) {

                for(i=0; i<level; i++) {




                    writeChars(xmlString, chan, "        ", indent);
                }
                if (indentAttrs) {




                    writeChars(xmlString, chan, "        ", indentAttrs);
                }
            }
        } else {
            writeChars(xmlString, chan, " ", 1);
        }
        writeChars(xmlString, chan, attrs->nodeName, -1);
................................................................................
                writeChars(xmlString, chan, ">", 1);
            } else {
                writeChars(xmlString, chan, "/>",   2);
            }
        }
    } else {
        if ((indent != -1) && hasElements) {

            for(i=0; i<level; i++) {




                writeChars(xmlString, chan, "        ", indent);

            }
        }
        writeChars (xmlString, chan, "</", 2);
        writeChars(xmlString, chan, node->nodeName, -1);
        if (indent != -1) {
            writeChars(xmlString, chan, ">\n", 2);
        } else {
................................................................................

static
void tcldom_childsAsJSON (
    Tcl_Obj     *jstring,
    domNode     *node, /* Must be an ELEMENT_NODE */
    Tcl_Channel  channel,
    int          indent,

    int          level,
    int          inside
    )
{
    domNode   *child, *nextChild;
    int i, effectivParentType = 0;
    int first = 1;
................................................................................
            }
            if (nextChild) {
                effectivParentType = JSON_ARRAY;
            } else {
                /* Exactly one 'relevant' child node, a text node;
                 * serialize it as simple token value. */
                tcldom_treeAsJSON (jstring, child, channel, indent,
                                   level, JSON_ARRAY);
                return;
            }
        }
    }
        
    switch (effectivParentType) {
    case JSON_ARRAY:
................................................................................
                first = 0;
                level++;
            } else {
                writeChars(jstring, channel, ",", 1);
            }
            if (indent > -1) {
                writeChars(jstring, channel, "\n", 1);
                if (first) level++;
                for (i = 0; i < level; i++) {




                    writeChars(jstring, channel, "        ", indent);

                }
            }
            tcldom_treeAsJSON (jstring, child, channel, indent,
                               level, JSON_ARRAY);
            child = child->nextSibling;
            while (child
                   && child->nodeType != TEXT_NODE
                   && child->nodeType != ELEMENT_NODE) {
                child = child->nextSibling;
            }
        }
        if (indent > -1 && first == 0) {
            writeChars(jstring, channel, "\n", 1);
            level--;

            for (i = 0; i < level; i++) {




                writeChars(jstring, channel, "        ", indent);

            }
        }
        writeChars(jstring, channel, "]",1);
        break;
    case JSON_OBJECT:
        writeChars(jstring, channel, "{",1);
        while (child) {
................................................................................
                first = 0;
                level++;
            } else {
                writeChars(jstring, channel, ",", 1);
            }
            if (indent > -1) {
                writeChars(jstring, channel, "\n", 1);
                if (first) level++;
                for (i = 0; i < level; i++) {




                    writeChars(jstring, channel, "        ", indent);

                }
            }
            tcldom_treeAsJSON (jstring, child, channel, indent,
                               level, JSON_OBJECT);
            child = child->nextSibling;
            /* Inside of a JSON_OBJECT, only element childs make
             * semantically sense. */
            while (child && child->nodeType != ELEMENT_NODE) {
                child = child->nextSibling;
            }
        }
        if (indent > -1 && first == 0) {
            writeChars(jstring, channel, "\n", 1);
            level--;

            for (i = 0; i < level; i++) {




                writeChars(jstring, channel, "        ", indent);

            }
        }
        writeChars(jstring, channel, "}",1);
        break;
    default:
        break;
    }
................................................................................
\---------------------------------------------------------------------------*/
static
void tcldom_treeAsJSON (
    Tcl_Obj     *jstring,
    domNode     *node,  /* Must not be NULL */
    Tcl_Channel  channel,
    int          indent,

    int          level,
    int          inside
    )
{
    domTextNode *textNode;
    int i, seenDP, seenE;
    unsigned char c;
................................................................................
        switch (inside) {
        case JSON_OBJECT:
            /* Write the member name and recurse to the childs for the
             * value. */
            tcldom_AppendEscapedJSON (jstring, channel,
                                      node->nodeName, -1);
            writeChars (jstring, channel, ":", 1);



            tcldom_childsAsJSON (jstring, node, channel, indent,
                                 level, inside);
            break;
        case JSON_ARRAY:
            /* Since we're already inside of an array, the element can
               only be interpreted as a container for a nested JSON
               object or array. */
            tcldom_childsAsJSON (jstring, node, channel, indent,
                                 level, inside);
            break;
        case JSON_START:
            tcldom_childsAsJSON (jstring, node, channel, indent,
                                 level, inside);            
            break;
        }
        return;
    default:
        /* Any other node types (COMMENT_NODE, CDATA_SECTION_NODE, 
           PROCESSING_INSTRUCTION_NODE) are ignored. */
        return;
................................................................................
            goto cleanup;
        }
        switch ((enum asXMLOption) optionIndex) {

        case m_indent:
            if (objc < 4) {
                SetResult("-indent must have an argument "
                          "(0..8 or 'no'/'none')");
                goto cleanup;
            }
            if (strcmp("none", Tcl_GetString(objv[3]))==0) {
                indent = -1;
            }
            else if (strcmp("no", Tcl_GetString(objv[3]))==0) {
                indent = -1;
            }



            else if (Tcl_GetIntFromObj(interp, objv[3], &indent) != TCL_OK) {
                SetResult( "indent must be an integer (0..8) or 'no'/'none'");

                goto cleanup;
            }
            objc -= 2;
            objv += 2;
            break;

        case m_indentAttrs:
            if (objc < 4) {
                SetResult("-indentAttrs must have an argument "
                          "(0..8 or 'no'/'none')");
                goto cleanup;
            }
            if (strcmp("none", Tcl_GetString(objv[3]))==0) {
                indentAttrs = -1;
            }
            else if (strcmp("no", Tcl_GetString(objv[3]))==0) {
                indentAttrs = -1;
            }



            else if (Tcl_GetIntFromObj(interp, objv[3], &indentAttrs) != TCL_OK) {
                SetResult( "indentAttrs must be an integer (0..8) or 'no'/'none'");

                goto cleanup;
            }
            if (indentAttrs > 8) indentAttrs = 8;
            if (indentAttrs < 0) indentAttrs = 0;
            objc -= 2;
            objv += 2;
            break;
................................................................................
    domNode    *node,
    Tcl_Interp *interp,
    int         objc,
    Tcl_Obj    *const objv[]
)
{
    char       *channelId;
    int         optionIndex, mode, indent = -1;
    Tcl_Obj    *resultPtr;
    Tcl_Channel chan = (Tcl_Channel) NULL;

    static const char *asJSONOptions[] = {
        "-channel", "-indent",
        NULL
    };
................................................................................
                return TCL_ERROR;
            }
            if (strcmp("none", Tcl_GetString(objv[3]))==0) {
                indent = -1;
            }
            else if (strcmp("no", Tcl_GetString(objv[3]))==0) {
                indent = -1;





            }
            else if (Tcl_GetIntFromObj(interp, objv[3], &indent) != TCL_OK) {
                SetResult( "indent must be an integer (0..8) or 'no'/'none'");
                return TCL_ERROR;
            } else if (indent < 0 || indent > 8) {
                SetResult( "indent must be an integer (0..8) or 'no'/'none'");
                return TCL_ERROR;
................................................................................
                
            objc -= 2;
            objv += 2;
            break;
        }
    }
    resultPtr = Tcl_NewStringObj("", 0);
    tcldom_treeAsJSON(resultPtr, node, chan, indent, 0, JSON_START);

    Tcl_AppendResult(interp, Tcl_GetString(resultPtr), NULL);
    Tcl_DecrRefCount(resultPtr);
    return TCL_OK;
}

/*----------------------------------------------------------------------------
|   cdataSectionElements







>
>







 







|







 







|







 







<
|







 







>
|
>
>
>
>
|
>







 







>
|
>
>
>
>
|
|
<
>
>
>
>







 







>
|
>
>
>
>
|
>







 







>







 







|







 







|
|
>
>
>
>
|
>



|










>
|
>
>
>
>
|
>







 







|
|
>
>
>
>
|
>



|










>
|
>
>
>
>
|
>







 







>







 







>
>
>

|






|



|







 







|








>
>
>

|
>









|








>
>
>

|
>







 







|







 







>
>
>
>
>







 







|
>







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
...
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
...
402
403
404
405
406
407
408

409
410
411
412
413
414
415
416
....
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
....
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931

2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
....
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
....
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
....
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
....
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
....
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
....
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
....
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
....
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
....
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
....
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
....
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
#define SERIALIZE_DOCTYPE_DECLARATION 2
#define SERIALIZE_FOR_ATTR 4 
#define SERIALIZE_ESCAPE_NON_ASCII 8
#define SERIALIZE_HTML_ENTITIES 16
#define SERIALIZE_ESCAPE_ALL_QUOT 32
#define SERIALIZE_NO_GT_ESCAPE 64
#define SERIALIZE_NO_EMPTY_ELEMENT_TAG 128
#define SERIALIZE_INDENT_WITH_TAB 256
#define SERIALIZE_INDENT_ATTR_WITH_TAB 512

/*----------------------------------------------------------------------------
|   Module Globals
|
\---------------------------------------------------------------------------*/
#ifndef TCL_THREADS
    static int        storeLineColumn       = 0;
................................................................................
    "    getElementsByTagNameNS uri localname    \n"
    "    createElement tagName ?objVar?          \n"
    "    createElementNS uri tagName ?objVar?    \n"
    "    createCDATASection data ?objVar?        \n"
    "    createTextNode text ?objVar?            \n"
    "    createComment text ?objVar?             \n"
    "    createProcessingInstruction target data ?objVar? \n"
    "    asXML ?-indent <none,tabs,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n"
    "    asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n"
    "    asText                                  \n"
    "    asJSON ?-indent <none,0..8>?            \n"
    "    getDefaultOutputMethod                  \n"
    "    publicId ?publicId?                     \n"
    "    systemId ?systemId?                     \n"
    "    internalSubset ?internalSubset?         \n"
................................................................................
    "    baseURI ?URI?                \n"
    "    localName                    \n"
    "    delete                       \n"
    "    getLine                      \n"
    "    getColumn                    \n"
    "    @<attrName> ?defaultValue?   \n"
    "    asList                       \n"
    "    asXML ?-indent <none,tabs,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n"
    "    asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n"
    "    asText                       \n"
    "    asJSON ?-indent <none,0..8>? \n"
    "    appendFromList nestedList    \n"
    "    appendFromScript script      \n"
    "    insertBeforeFromScript script ref \n"
    "    appendXML xmlString          \n"
................................................................................
|
\---------------------------------------------------------------------------*/
static Tcl_VarTraceProc  tcldom_docTrace;
static Tcl_CmdDeleteProc tcldom_docCmdDeleteProc;

static void tcldom_treeAsJSON(Tcl_Obj *jstring, domNode *node,
                              Tcl_Channel channel, int indent,

                              int outputFlags, int level, int inside);

#ifdef TCL_THREADS

static int tcldom_EvalLocked(Tcl_Interp* interp, Tcl_Obj** objv,
                             domDocument* doc, int flag);

static int tcldom_RegisterDocShared(domDocument* doc);
................................................................................
        writeChars(xmlString, chan, ((domTextNode*)node)->nodeValue,
                                    ((domTextNode*)node)->valueLength);
        writeChars(xmlString, chan, "]]>", 3);
        return;
    }

    if ((indent != -1) && doIndent) {
        if (outputFlags & SERIALIZE_INDENT_WITH_TAB) {
            for(i=0; i<level; i++) {
                writeChars(xmlString, chan, "\t", 1);
            }
        } else {
            for(i=0; i<level; i++) {
                writeChars(xmlString, chan, "        ", indent);
            }
        }
    }

    if (node->nodeType == COMMENT_NODE) {
        writeChars(xmlString, chan, "<!--", 4);
        writeChars(xmlString, chan, ((domTextNode*)node)->nodeValue,
                                    ((domTextNode*)node)->valueLength);
................................................................................
    writeChars(xmlString, chan, node->nodeName, -1);

    attrs = node->firstAttr;
    while (attrs) {
        if (indentAttrs > -1) {
            writeChars(xmlString, chan, "\n", 1);
            if ((indent != -1) && doIndent) {
                if (outputFlags & SERIALIZE_INDENT_WITH_TAB) {
                    for(i=0; i<level; i++) {
                        writeChars(xmlString, chan, "\t", 1);
                    }
                } else {
                    for(i=0; i<level; i++) {
                        writeChars(xmlString, chan, "        ", indent);
                    }

                }
                if (outputFlags & SERIALIZE_INDENT_ATTR_WITH_TAB) {
                    writeChars(xmlString, chan, "\t", 1);
                } else {
                    writeChars(xmlString, chan, "        ", indentAttrs);
                }
            }
        } else {
            writeChars(xmlString, chan, " ", 1);
        }
        writeChars(xmlString, chan, attrs->nodeName, -1);
................................................................................
                writeChars(xmlString, chan, ">", 1);
            } else {
                writeChars(xmlString, chan, "/>",   2);
            }
        }
    } else {
        if ((indent != -1) && hasElements) {
            if (outputFlags & SERIALIZE_INDENT_WITH_TAB) {
                for(i=0; i<level; i++) {
                    writeChars(xmlString, chan, "\t", 1);
                }
            } else {
                for(i=0; i<level; i++) {
                    writeChars(xmlString, chan, "        ", indent);
                }
            }
        }
        writeChars (xmlString, chan, "</", 2);
        writeChars(xmlString, chan, node->nodeName, -1);
        if (indent != -1) {
            writeChars(xmlString, chan, ">\n", 2);
        } else {
................................................................................

static
void tcldom_childsAsJSON (
    Tcl_Obj     *jstring,
    domNode     *node, /* Must be an ELEMENT_NODE */
    Tcl_Channel  channel,
    int          indent,
    int          outputFlags,
    int          level,
    int          inside
    )
{
    domNode   *child, *nextChild;
    int i, effectivParentType = 0;
    int first = 1;
................................................................................
            }
            if (nextChild) {
                effectivParentType = JSON_ARRAY;
            } else {
                /* Exactly one 'relevant' child node, a text node;
                 * serialize it as simple token value. */
                tcldom_treeAsJSON (jstring, child, channel, indent,
                                   outputFlags, level, JSON_ARRAY);
                return;
            }
        }
    }
        
    switch (effectivParentType) {
    case JSON_ARRAY:
................................................................................
                first = 0;
                level++;
            } else {
                writeChars(jstring, channel, ",", 1);
            }
            if (indent > -1) {
                writeChars(jstring, channel, "\n", 1);
                if (outputFlags & SERIALIZE_INDENT_WITH_TAB) {
                    for (i = 0; i < level; i++) {
                        writeChars(jstring, channel, "\t", 1);
                    }
                } else {
                    for (i = 0; i < level; i++) {
                        writeChars(jstring, channel, "        ", indent);
                    }
                }
            }
            tcldom_treeAsJSON (jstring, child, channel, indent,
                               outputFlags, level, JSON_ARRAY);
            child = child->nextSibling;
            while (child
                   && child->nodeType != TEXT_NODE
                   && child->nodeType != ELEMENT_NODE) {
                child = child->nextSibling;
            }
        }
        if (indent > -1 && first == 0) {
            writeChars(jstring, channel, "\n", 1);
            level--;
            if (outputFlags & SERIALIZE_INDENT_WITH_TAB) {
                for (i = 0; i < level; i++) {
                    writeChars(jstring, channel, "\t", 1);
                }
            } else {
                for (i = 0; i < level; i++) {
                    writeChars(jstring, channel, "        ", indent);
                }
            }
        }
        writeChars(jstring, channel, "]",1);
        break;
    case JSON_OBJECT:
        writeChars(jstring, channel, "{",1);
        while (child) {
................................................................................
                first = 0;
                level++;
            } else {
                writeChars(jstring, channel, ",", 1);
            }
            if (indent > -1) {
                writeChars(jstring, channel, "\n", 1);
                if (outputFlags & SERIALIZE_INDENT_WITH_TAB) {
                    for (i = 0; i < level; i++) {
                        writeChars(jstring, channel, "\t", 1);
                    }
                } else {
                    for (i = 0; i < level; i++) {
                        writeChars(jstring, channel, "        ", indent);
                    }
                }
            }
            tcldom_treeAsJSON (jstring, child, channel, indent,
                               outputFlags, level, JSON_OBJECT);
            child = child->nextSibling;
            /* Inside of a JSON_OBJECT, only element childs make
             * semantically sense. */
            while (child && child->nodeType != ELEMENT_NODE) {
                child = child->nextSibling;
            }
        }
        if (indent > -1 && first == 0) {
            writeChars(jstring, channel, "\n", 1);
            level--;
            if (outputFlags & SERIALIZE_INDENT_WITH_TAB) {
                for (i = 0; i < level; i++) {
                    writeChars(jstring, channel, "\t", 1);
                }
            } else {
                for (i = 0; i < level; i++) {
                    writeChars(jstring, channel, "        ", indent);
                }
            }
        }
        writeChars(jstring, channel, "}",1);
        break;
    default:
        break;
    }
................................................................................
\---------------------------------------------------------------------------*/
static
void tcldom_treeAsJSON (
    Tcl_Obj     *jstring,
    domNode     *node,  /* Must not be NULL */
    Tcl_Channel  channel,
    int          indent,
    int          outputFlags,
    int          level,
    int          inside
    )
{
    domTextNode *textNode;
    int i, seenDP, seenE;
    unsigned char c;
................................................................................
        switch (inside) {
        case JSON_OBJECT:
            /* Write the member name and recurse to the childs for the
             * value. */
            tcldom_AppendEscapedJSON (jstring, channel,
                                      node->nodeName, -1);
            writeChars (jstring, channel, ":", 1);
            if (indent > -1 || outputFlags & SERIALIZE_INDENT_WITH_TAB) {
                writeChars (jstring, channel, " ", 1);
            }
            tcldom_childsAsJSON (jstring, node, channel, indent,
                                 outputFlags, level, inside);
            break;
        case JSON_ARRAY:
            /* Since we're already inside of an array, the element can
               only be interpreted as a container for a nested JSON
               object or array. */
            tcldom_childsAsJSON (jstring, node, channel, indent,
                                 outputFlags, level, inside);
            break;
        case JSON_START:
            tcldom_childsAsJSON (jstring, node, channel, indent,
                                 outputFlags, level, inside);            
            break;
        }
        return;
    default:
        /* Any other node types (COMMENT_NODE, CDATA_SECTION_NODE, 
           PROCESSING_INSTRUCTION_NODE) are ignored. */
        return;
................................................................................
            goto cleanup;
        }
        switch ((enum asXMLOption) optionIndex) {

        case m_indent:
            if (objc < 4) {
                SetResult("-indent must have an argument "
                          "(0..8 or 'no'/'none'/'tabs')");
                goto cleanup;
            }
            if (strcmp("none", Tcl_GetString(objv[3]))==0) {
                indent = -1;
            }
            else if (strcmp("no", Tcl_GetString(objv[3]))==0) {
                indent = -1;
            }
            else if (strcmp("tabs", Tcl_GetString(objv[3]))==0) {
                outputFlags |= SERIALIZE_INDENT_WITH_TAB;
            }
            else if (Tcl_GetIntFromObj(interp, objv[3], &indent) != TCL_OK) {
                SetResult( "indent must be an integer (0..8) or "
                           "'no'/'none'/'tabs'");
                goto cleanup;
            }
            objc -= 2;
            objv += 2;
            break;

        case m_indentAttrs:
            if (objc < 4) {
                SetResult("-indentAttrs must have an argument "
                          "(0..8 or 'no'/'none'/'tabs')");
                goto cleanup;
            }
            if (strcmp("none", Tcl_GetString(objv[3]))==0) {
                indentAttrs = -1;
            }
            else if (strcmp("no", Tcl_GetString(objv[3]))==0) {
                indentAttrs = -1;
            }
            else if (strcmp("tabs", Tcl_GetString(objv[3]))==0) {
                outputFlags |= SERIALIZE_INDENT_ATTR_WITH_TAB;
            }
            else if (Tcl_GetIntFromObj(interp, objv[3], &indentAttrs) != TCL_OK) {
                SetResult( "indentAttrs must be an integer (0..8) or "
                           "'no'/'none'/'tabs'");
                goto cleanup;
            }
            if (indentAttrs > 8) indentAttrs = 8;
            if (indentAttrs < 0) indentAttrs = 0;
            objc -= 2;
            objv += 2;
            break;
................................................................................
    domNode    *node,
    Tcl_Interp *interp,
    int         objc,
    Tcl_Obj    *const objv[]
)
{
    char       *channelId;
    int         optionIndex, mode, outputFlags = 0, indent = -1;
    Tcl_Obj    *resultPtr;
    Tcl_Channel chan = (Tcl_Channel) NULL;

    static const char *asJSONOptions[] = {
        "-channel", "-indent",
        NULL
    };
................................................................................
                return TCL_ERROR;
            }
            if (strcmp("none", Tcl_GetString(objv[3]))==0) {
                indent = -1;
            }
            else if (strcmp("no", Tcl_GetString(objv[3]))==0) {
                indent = -1;
            }
            else if (strcmp("tabs", Tcl_GetString(objv[3]))==0) {
                /* User wants indentation */
                indent = 0;
                outputFlags |= SERIALIZE_INDENT_WITH_TAB;
            }
            else if (Tcl_GetIntFromObj(interp, objv[3], &indent) != TCL_OK) {
                SetResult( "indent must be an integer (0..8) or 'no'/'none'");
                return TCL_ERROR;
            } else if (indent < 0 || indent > 8) {
                SetResult( "indent must be an integer (0..8) or 'no'/'none'");
                return TCL_ERROR;
................................................................................
                
            objc -= 2;
            objv += 2;
            break;
        }
    }
    resultPtr = Tcl_NewStringObj("", 0);
    tcldom_treeAsJSON(resultPtr, node, chan, indent, outputFlags, 0,
                      JSON_START);
    Tcl_AppendResult(interp, Tcl_GetString(resultPtr), NULL);
    Tcl_DecrRefCount(resultPtr);
    return TCL_OK;
}

/*----------------------------------------------------------------------------
|   cdataSectionElements

Changes to tests/domDoc.test.

315
316
317
318
319
320
321



































322
323
324
325
326
327
328
    set root [$doc documentElement]
    $root setAttribute attr "foo\"bar"
    set result [$doc asXML -indent none]
    $doc delete
    set result
} {<doc attr="foo&quot;bar"/>}




































set doc [dom parse <root/>]

test domDoc-2.1 {publicId - no publicId there} {
    $doc publicId
} {}

test domDoc-2.2 {systemId - no systemId there} {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
    set root [$doc documentElement]
    $root setAttribute attr "foo\"bar"
    set result [$doc asXML -indent none]
    $doc delete
    set result
} {<doc attr="foo&quot;bar"/>}

test domDoc-1.32 {asXML -indent tabs} {
    set doc [dom parse {<doc><a><b/></a></doc>}]
    set result [$doc asXML -indent tabs]
    $doc delete
    set result
} "<doc>\n\t<a>\n\t\t<b/>\n\t</a>\n</doc>\n"

test domDoc-1.33 {asXML -indent tabs} {
    set doc [dom parse {<doc><a><b/></a><c><d><f/></d></c><g/></doc>}]
    set result [$doc asXML -indent tabs]
    $doc delete
    set result
} "<doc>\n\t<a>\n\t\t<b/>\n\t</a>\n\t<c>\n\t\t<d>\n\t\t\t<f/>\n\t\t</d>\n\t</c>\n\t<g/>\n</doc>\n"

test domDoc-1.34 {asXML -indent tabs -noEmptyElementTag} {
    set doc [dom parse {<doc><a><b/></a><c><d><f/></d></c><g/></doc>}]
    set result [$doc asXML -indent tabs -noEmptyElementTag]
    $doc delete
    set result
} "<doc>\n\t<a>\n\t\t<b></b>\n\t</a>\n\t<c>\n\t\t<d>\n\t\t\t<f></f>\n\t\t</d>\n\t</c>\n\t<g></g>\n</doc>\n"

test domDoc-1.35 {asXML -indent tabs -indentAttrs tabs} {
    set doc [dom parse {<doc><a a1="a1" a2="a2"><b/></a><c><d a1="a1" a2="a2"><f/></d></c><g/></doc>}]
    set result [$doc asXML -indent tabs -indentAttrs tabs]
    $doc delete
    set result
} "<doc>\n\t<a\n\t\ta1=\"a1\"\n\t\ta2=\"a2\">\n\t\t<b/>\n\t</a>\n\t<c>\n\t\t<d\n\t\t\ta1=\"a1\"\n\t\t\ta2=\"a2\">\n\t\t\t<f/>\n\t\t</d>\n\t</c>\n\t<g/>\n</doc>\n"

test domDoc-1.36 {asXML -indent tabs -indentAttrs <num>} {
    set doc [dom parse {<doc><a a1="a1" a2="a2"><b/></a><c><d a1="a1" a2="a2"><f/></d></c><g/></doc>}]
    set result [$doc asXML -indent tabs -indentAttrs 2]
    $doc delete
    set result
} "<doc>\n\t<a\n\t  a1=\"a1\"\n\t  a2=\"a2\">\n\t\t<b/>\n\t</a>\n\t<c>\n\t\t<d\n\t\t  a1=\"a1\"\n\t\t  a2=\"a2\">\n\t\t\t<f/>\n\t\t</d>\n\t</c>\n\t<g/>\n</doc>\n"

set doc [dom parse <root/>]

test domDoc-2.1 {publicId - no publicId there} {
    $doc publicId
} {}

test domDoc-2.2 {systemId - no systemId there} {

Changes to tests/domjson.test.

386
387
388
389
390
391
392




































393
394
395
396
397
398
399

test json-6.5 {asJSON - serialization of control characters} {
    set doc [dom parse -json "\"a\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\u0008\\u0009\\u000A\\u000B\\u000C\\u000D\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F\\u0020b\""]
    set result [$doc asJSON]
    $doc delete
    set result
} {"a\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f b"}





































test json-7.1 {jsonType} {
    set doc [dom parse {<j>foo</j>}]
    set root [$doc documentElement]
    set result [list]
    lappend result [$root asJSON]
    lappend result [$root jsonType]







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435

test json-6.5 {asJSON - serialization of control characters} {
    set doc [dom parse -json "\"a\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\u0008\\u0009\\u000A\\u000B\\u000C\\u000D\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F\\u0020b\""]
    set result [$doc asJSON]
    $doc delete
    set result
} {"a\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f b"}

test json-6.6 {asJSON -indent} {
    set doc [dom parse -json {{"a":{"aa":[1,2,3,4,"abc"]},"b":"bvalue"}}]
    set result [$doc asJSON -indent 2]
    $doc delete
    set result
} {{
  "a": {
    "aa": [
      1,
      2,
      3,
      4,
      "abc"
    ]
  },
  "b": "bvalue"
}}

test json-6.7 {asJSON -indent} {
    set doc [dom parse -json {{"a":{"aa":[1,2,3,4,"abc"]},"b":"bvalue"}}]
    set result [$doc asJSON -indent tabs]
    $doc delete
    set result
} {{
	"a": {
		"aa": [
			1,
			2,
			3,
			4,
			"abc"
		]
	},
	"b": "bvalue"
}}

test json-7.1 {jsonType} {
    set doc [dom parse {<j>foo</j>}]
    set root [$doc documentElement]
    set result [list]
    lappend result [$root asJSON]
    lappend result [$root jsonType]