Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
aa470adf
Commit
aa470adf
authored
Feb 18, 2002
by
arjen@co3064164-a.bitbike.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "well-formed" XML checker script.
parent
7bed2413
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
Docs/Support/xwf
Docs/Support/xwf
+67
-0
No files found.
Docs/Support/xwf
0 → 100755
View file @
aa470adf
#!/usr/bin/perl -w
#
# Parse document and report first syntax (well-formedness) error found.
#
use
strict
;
use
XML::
Parser
;
use
Getopt::
Std
;
my
%
opts
;
getopts
('
e
',
\%
opts
);
my
$ENTREFS
=
exists
(
$opts
{'
e
'}
);
# flag: check ent refs
my
$parser
=
XML::
Parser
->
new
(
ErrorContext
=>
2
,
# output error context
);
# get input from files
if
(
@ARGV
)
{
foreach
(
@ARGV
)
{
my
$file
=
$_
;
unless
(
-
r
$file
)
{
print
STDERR
"
ERROR: Can't open '
$file
'.
\n
";
return
;
}
my
$input
=
'';
open
(
F
,
$file
);
while
(
<
F
>
)
{
$input
.=
$_
;
}
close
F
;
# parse and report errors
if
(
&
parse_string
(
$input
))
{
print
STDERR
"
ERROR in
$file
:
\n
$@
\n
";
}
else
{
print
STDERR
"
'
$file
' is well-formed.
\n
";
}
}
print
"
All files checked.
\n
";
# get input from STDIN
}
else
{
my
$input
=
"";
while
(
<
STDIN
>
)
{
$input
.=
$_
;
}
if
(
&
parse_string
(
$input
))
{
print
STDERR
"
ERROR in stream:
\n
$@
\n
";
}
else
{
print
STDERR
"
No syntax errors found in XML stream.
\n
";
}
}
# parse the string and return error message
#
# NOTE: By default, entity refs are not expanded. XML::Parser can be
# told not to expand entity refs, but will still try to find
# replacement text just in case, which we don't want. Therefore, we
# need to do a stupid regexp replacement, removing entities from input.
#
sub
parse_string
{
my
$string
=
shift
;
unless
(
$ENTREFS
)
{
$string
=~
s/\&[^\s;]+;//g
;
# remove entity references
}
eval
{
$parser
->
parse
(
$string
);
};
$@
=~
s/at \/.*?$//s
;
# remove module line number
return
$@
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment