author | William Roberts <williamr@symbian.org> |
Wed, 03 Jun 2009 18:33:51 +0100 | |
changeset 3 | 8b87ea768cb8 |
parent 0 | 02cd6b52f378 |
permissions | -rw-r--r-- |
0
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
1 |
package XML::Handler::BuildDOM; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
2 |
use strict; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
3 |
use XML::DOM; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
4 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
5 |
# |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
6 |
# TODO: |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
7 |
# - add support for parameter entity references |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
8 |
# - expand API: insert Elements in the tree or stuff into DocType etc. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
9 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
10 |
sub new |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
11 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
12 |
my ($class, %args) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
13 |
bless \%args, $class; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
14 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
15 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
16 |
#-------- PerlSAX Handler methods ------------------------------ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
17 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
18 |
sub start_document # was Init |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
19 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
20 |
my $self = shift; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
21 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
22 |
# Define Document if it's not set & not obtainable from Element or DocType |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
23 |
$self->{Document} ||= |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
24 |
(defined $self->{Element} ? $self->{Element}->getOwnerDocument : undef) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
25 |
|| (defined $self->{DocType} ? $self->{DocType}->getOwnerDocument : undef) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
26 |
|| new XML::DOM::Document(); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
27 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
28 |
$self->{Element} ||= $self->{Document}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
29 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
30 |
unless (defined $self->{DocType}) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
31 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
32 |
$self->{DocType} = $self->{Document}->getDoctype |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
33 |
if defined $self->{Document}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
34 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
35 |
unless (defined $self->{Doctype}) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
36 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
37 |
#?? should be $doc->createDocType for extensibility! |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
38 |
$self->{DocType} = new XML::DOM::DocumentType ($self->{Document}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
39 |
$self->{Document}->setDoctype ($self->{DocType}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
40 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
41 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
42 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
43 |
# Prepare for document prolog |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
44 |
$self->{InProlog} = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
45 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
46 |
# We haven't passed the root element yet |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
47 |
$self->{EndDoc} = 0; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
48 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
49 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
50 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
51 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
52 |
sub end_document # was Final |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
53 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
54 |
my $self = shift; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
55 |
unless ($self->{SawDocType}) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
56 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
57 |
my $doctype = $self->{Document}->removeDoctype; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
58 |
$doctype->dispose; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
59 |
#?? do we always want to destroy the Doctype? |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
60 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
61 |
$self->{Document}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
62 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
63 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
64 |
sub characters # was Char |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
65 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
66 |
my $self = $_[0]; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
67 |
my $str = $_[1]->{Data}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
68 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
69 |
if ($self->{InCDATA} && $self->{KeepCDATA}) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
70 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
71 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
72 |
# Merge text with previous node if possible |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
73 |
$self->{Element}->addCDATA ($str); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
74 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
75 |
else |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
76 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
77 |
# Merge text with previous node if possible |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
78 |
# Used to be: $expat->{DOM_Element}->addText ($str); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
79 |
if ($self->{LastText}) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
80 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
81 |
$self->{LastText}->appendData ($str); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
82 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
83 |
else |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
84 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
85 |
$self->{LastText} = $self->{Document}->createTextNode ($str); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
86 |
$self->{Element}->appendChild ($self->{LastText}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
87 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
88 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
89 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
90 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
91 |
sub start_element # was Start |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
92 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
93 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
94 |
my $elem = $hash->{Name}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
95 |
my $attr = $hash->{Attributes}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
96 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
97 |
my $parent = $self->{Element}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
98 |
my $doc = $self->{Document}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
99 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
100 |
if ($parent == $doc) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
101 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
102 |
# End of document prolog, i.e. start of first Element |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
103 |
$self->{InProlog} = 0; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
104 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
105 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
106 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
107 |
my $node = $doc->createElement ($elem); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
108 |
$self->{Element} = $node; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
109 |
$parent->appendChild ($node); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
110 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
111 |
my $i = 0; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
112 |
my $n = scalar keys %$attr; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
113 |
return unless $n; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
114 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
115 |
if (exists $hash->{AttributeOrder}) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
116 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
117 |
my $defaulted = $hash->{Defaulted}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
118 |
my @order = @{ $hash->{AttributeOrder} }; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
119 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
120 |
# Specified attributes |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
121 |
for (my $i = 0; $i < $defaulted; $i++) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
122 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
123 |
my $a = $order[$i]; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
124 |
my $att = $doc->createAttribute ($a, $attr->{$a}, 1); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
125 |
$node->setAttributeNode ($att); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
126 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
127 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
128 |
# Defaulted attributes |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
129 |
for (my $i = $defaulted; $i < @order; $i++) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
130 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
131 |
my $a = $order[$i]; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
132 |
my $att = $doc->createAttribute ($elem, $attr->{$a}, 0); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
133 |
$node->setAttributeNode ($att); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
134 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
135 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
136 |
else |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
137 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
138 |
# We're assuming that all attributes were specified (1) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
139 |
for my $a (keys %$attr) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
140 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
141 |
my $att = $doc->createAttribute ($a, $attr->{$a}, 1); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
142 |
$node->setAttributeNode ($att); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
143 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
144 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
145 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
146 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
147 |
sub end_element |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
148 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
149 |
my $self = shift; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
150 |
$self->{Element} = $self->{Element}->getParentNode; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
151 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
152 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
153 |
# Check for end of root element |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
154 |
$self->{EndDoc} = 1 if ($self->{Element} == $self->{Document}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
155 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
156 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
157 |
sub entity_reference # was Default |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
158 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
159 |
my $self = $_[0]; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
160 |
my $name = $_[1]->{Name}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
161 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
162 |
$self->{Element}->appendChild ( |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
163 |
$self->{Document}->createEntityReference ($name)); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
164 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
165 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
166 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
167 |
sub start_cdata |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
168 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
169 |
my $self = shift; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
170 |
$self->{InCDATA} = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
171 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
172 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
173 |
sub end_cdata |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
174 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
175 |
my $self = shift; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
176 |
$self->{InCDATA} = 0; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
177 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
178 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
179 |
sub comment |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
180 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
181 |
my $self = $_[0]; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
182 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
183 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
184 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
185 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
186 |
my $comment = $self->{Document}->createComment ($_[1]->{Data}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
187 |
$self->{Element}->appendChild ($comment); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
188 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
189 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
190 |
sub doctype_decl |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
191 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
192 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
193 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
194 |
$self->{DocType}->setParams ($hash->{Name}, $hash->{SystemId}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
195 |
$hash->{PublicId}, $hash->{Internal}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
196 |
$self->{SawDocType} = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
197 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
198 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
199 |
sub attlist_decl |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
200 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
201 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
202 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
203 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
204 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
205 |
$self->{DocType}->addAttDef ($hash->{ElementName}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
206 |
$hash->{AttributeName}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
207 |
$hash->{Type}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
208 |
$hash->{Default}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
209 |
$hash->{Fixed}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
210 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
211 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
212 |
sub xml_decl |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
213 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
214 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
215 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
216 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
217 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
218 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
219 |
$self->{Document}->setXMLDecl (new XML::DOM::XMLDecl ($self->{Document}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
220 |
$hash->{Version}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
221 |
$hash->{Encoding}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
222 |
$hash->{Standalone})); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
223 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
224 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
225 |
sub entity_decl |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
226 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
227 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
228 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
229 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
230 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
231 |
# Parameter Entities names are passed starting with '%' |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
232 |
my $parameter = 0; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
233 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
234 |
#?? parameter entities currently not supported by PerlSAX! |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
235 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
236 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
237 |
$self->{DocType}->addEntity ($parameter, $hash->{Name}, $hash->{Value}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
238 |
$hash->{SystemId}, $hash->{PublicId}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
239 |
$hash->{Notation}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
240 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
241 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
242 |
# Unparsed is called when it encounters e.g: |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
243 |
# |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
244 |
# <!ENTITY logo SYSTEM "http://server/logo.gif" NDATA gif> |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
245 |
# |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
246 |
sub unparsed_decl |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
247 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
248 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
249 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
250 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
251 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
252 |
# same as regular ENTITY, as far as DOM is concerned |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
253 |
$self->entity_decl ($hash); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
254 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
255 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
256 |
sub element_decl |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
257 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
258 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
259 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
260 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
261 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
262 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
263 |
$self->{DocType}->addElementDecl ($hash->{Name}, $hash->{Model}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
264 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
265 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
266 |
sub notation_decl |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
267 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
268 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
269 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
270 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
271 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
272 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
273 |
$self->{DocType}->addNotation ($hash->{Name}, $hash->{Base}, |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
274 |
$hash->{SystemId}, $hash->{PublicId}); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
275 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
276 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
277 |
sub processing_instruction |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
278 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
279 |
my ($self, $hash) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
280 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
281 |
local $XML::DOM::IgnoreReadOnly = 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
282 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
283 |
undef $self->{LastText}; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
284 |
$self->{Element}->appendChild (new XML::DOM::ProcessingInstruction |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
285 |
($self->{Document}, $hash->{Target}, $hash->{Data})); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
286 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
287 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
288 |
return 1; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
289 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
290 |
__END__ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
291 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
292 |
=head1 NAME |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
293 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
294 |
XML::Handler::BuildDOM - PerlSAX handler that creates XML::DOM document structures |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
295 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
296 |
=head1 SYNOPSIS |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
297 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
298 |
use XML::Handler::BuildDOM; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
299 |
use XML::Parser::PerlSAX; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
300 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
301 |
my $handler = new XML::Handler::BuildDOM (KeepCDATA => 1); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
302 |
my $parser = new XML::Parser::PerlSAX (Handler => $handler); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
303 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
304 |
my $doc = $parser->parsefile ("file.xml"); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
305 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
306 |
=head1 DESCRIPTION |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
307 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
308 |
XML::Handler::BuildDOM creates L<XML::DOM> document structures |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
309 |
(i.e. L<XML::DOM::Document>) from PerlSAX events. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
310 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
311 |
This class used to be called L<XML::PerlSAX::DOM> prior to libxml-enno 1.0.1. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
312 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
313 |
=head2 CONSTRUCTOR OPTIONS |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
314 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
315 |
The XML::Handler::BuildDOM constructor supports the following options: |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
316 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
317 |
=over 4 |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
318 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
319 |
=item * KeepCDATA => 1 |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
320 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
321 |
If set to 0 (default), CDATASections will be converted to regular text. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
322 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
323 |
=item * Document => $doc |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
324 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
325 |
If undefined, start_document will extract it from Element or DocType (if set), |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
326 |
otherwise it will create a new XML::DOM::Document. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
327 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
328 |
=item * Element => $elem |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
329 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
330 |
If undefined, it is set to Document. This will be the insertion point (or parent) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
331 |
for the nodes defined by the following callbacks. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
332 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
333 |
=item * DocType => $doctype |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
334 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
335 |
If undefined, start_document will extract it from Document (if possible). |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
336 |
Otherwise it adds a new XML::DOM::DocumentType to the Document. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
337 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
338 |
=back |