1# xml-8.0.tcl --
2#
3#	This file provides generic XML services for all implementations.
4#	This file supports Tcl 8.0 regular expressions.
5#
6#	See xmlparse.tcl for the Tcl implementation of a XML parser.
7#
8# Copyright (c) 1998-2002 Zveno Pty Ltd
9# http://www.zveno.com/
10#
11# Zveno makes this software and all associated data and documentation
12# ('Software') available free of charge for any purpose.
13# Copies may be made of this Software but all of this notice must be included
14# on any copy.
15#
16# The Software was developed for research purposes and Zveno does not warrant
17# that it is error free or fit for any purpose.  Zveno disclaims any
18# liability for all claims, expenses, losses, damages and costs any user may
19# incur as a result of using, copying or modifying the Software.
20#
21# Copyright (c) 1997 Australian National University (ANU).
22#
23# ANU makes this software and all associated data and documentation
24# ('Software') available free of charge for any purpose. You may make copies
25# of the Software but you must include all of this notice on any copy.
26#
27# The Software was developed for research purposes and ANU does not warrant
28# that it is error free or fit for any purpose.  ANU disclaims any
29# liability for all claims, expenses, losses, damages and costs any user may
30# incur as a result of using, copying or modifying the Software.
31#
32# $Id: xml-8.0.tcl,v 1.4 2002/08/30 07:52:16 balls Exp $
33
34package require -exact Tcl 8.0
35
36package require sgml 1.8
37
38package provide xmldefs 1.10
39
40namespace eval xml {
41
42    # Convenience routine
43    proc cl x {
44	return "\[$x\]"
45    }
46
47    # Define various regular expressions
48
49    # Characters
50    variable Char $::sgml::Char
51
52    # white space
53    variable Wsp " \t\r\n"
54    variable noWsp [cl ^$Wsp]
55
56    # Various XML names and tokens
57
58    variable NameChar $::sgml::NameChar
59    variable Name $::sgml::Name
60    variable Names $::sgml::Names
61    variable Nmtoken $::sgml::Nmtoken
62    variable Nmtokens $::sgml::Nmtokens
63
64    # The definition of the Namespace URI for XML Namespaces themselves.
65    # The prefix 'xml' is automatically bound to this URI.
66    variable xmlnsNS http://www.w3.org/XML/1998/namespace
67
68    # Tokenising expressions
69
70    variable tokExpr <(/?)([cl ^$Wsp>/]+)([cl $Wsp]*[cl ^>]*)>
71    variable substExpr "\}\n{\\2} {\\1} {\\3} \{"
72
73    # table of predefined entities
74
75    variable EntityPredef
76    array set EntityPredef {
77	lt <   gt >   amp &   quot \"   apos '
78    }
79
80}
81
82###
83###	General utility procedures
84###
85
86# xml::noop --
87#
88# A do-nothing proc
89
90proc xml::noop args {}
91
92### Following procedures are based on html_library
93
94# xml::zapWhite --
95#
96#	Convert multiple white space into a single space.
97#
98# Arguments:
99#	data	plain text
100#
101# Results:
102#	As above
103
104proc xml::zapWhite data {
105    regsub -all "\[ \t\r\n\]+" $data { } data
106    return $data
107}
108
109