 |
|
| |
XMLREWRITE(1) |
User Contributed Perl Documentation |
XMLREWRITE(1) |
xmlrewrite - cleanup XML based on schemas
# EXPERIMENTAL!
xmlrewrite infile.xml schema-files >outfile.xml
xmlrewrite -x infile.xml -s schema-files -o outfile.xml
cat x.xml | xmlrewrite - schemas/*.xsd | lpr
xmlrewrite -p schema2001 file.xml
xmlrewrite --repair in.xml --xmlns =http://somens
Convert an XML message into an XML with the same information. A
schema is required to enforce the correct information: for instance
whitespace removal is only allowed when the type definition permits it.
The command has TWO MODES:
- --transform
(default)
- The input message is processed as is, and then some transformations are
made on that message. All options will be used to change the output.
- --repair
- The input message is corrupted. First, it will be read. Then the options
will be used to change the input XML. After this, no transformations will
be applied: the corrected message is written. Many xml generators
(especially schema editing tools) are broken: their results can be fixed
in this mode.
This is the first release of rewrite. It still lacks most of the
more interesting features which I have in mind. There are also a few real
limitiations in the current version:
- The result is not seriously
tested
You can either specify an XML message filename and one or more
schema filenames as arguments, or use the options.
- --repair | --transform
- The execution mode. The effect of many options will change according to
the mode: be careful.
- --xml|-x filename
- The file which contains the xml message. A single dash (-) means
"stdin".
- --plugin|-p
<pre-defined or CLASS>
- Plugins add transformations to the available options. You can either
specify a pre-defined name, or the name of a CLASS which will be loaded
and then used. The CLASS must extend XML::Rewrite.
Pre-defined plugins:
schema2001 Schema version 2001
These plugins will load the required schema's automatically,
so you only need to provide your own.
xmlrewrite -p schema2001 myschema.xsd >clean.xsd
- --schema|-s
filename(s)
- This option can be repeated, or the filenames separated by comma's, if you
have more than one schema file to parse. All imported and included schema
components have to be provided explicitly, except schema-2001 which is
always loaded.
- --type|-t TYPE
- The type of the root element, required if the XML is not namespaceo
qualified, although the schema is. If not specified, the root element is
automatically inspected.
The TYPE notation is
"{namespace}localname". Be warned to
use quoting on the UNIX command-line, because curly braces have a
special meaning for the shell.
- --output|-o
filename
- By default (or when the filename is a '-'), the output is printed to
stdout.
- --blanks-before
all|containers|none
- Put a blank line before (the comments before) each element, only
containers (element with childs) or never.
- --xmlns
PREFIX=NAMESPACE[,PREFIX=NS]
- PREFIX and NAMESPACE combination, to be used in the output. You may use
this option more than once, and seperate a few definitions in one string
with commas.
abc=http://myns # prefix abc
=http://myns # default namespace
This module is part of Perl's XML-Compile distribution. Website:
http://perl.overmeer.net/xml-compile/
Copyrights 2008 by Mark Overmeer. For other contributors see
ChangeLog.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See
http://www.perl.com/perl/misc/Artistic.html
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc.
|