2:18 PM XMLWF command in Linux to check/validate/parse an XML file |
xmlwf - Determines if an XML document is well-formed. It is non- validating parser. FORMAT
Examples of well-formed documents:
<?xml version="1.0" standalone="yes"?>. <?xml version="1.0" encoding="ISO-8859-1"?> NOTE: xmlwf does not currently check for a valid XML declaration.
Note:- If the document has a DTD, and it strictly complies with that DTD, then the document is also considered valid. xmlwf is a non-validating parser i.e. it does not check the DTD. However, it does support external entities (see the -x option). Examples: We will try to understand this using a simple example.Lets create a demo xml file with some attributes:
The type of file we checked is XML, note that if we don't give the declaration i.e. the first line, the file type will be shown as ASCII text.
Now we will check for the well formedness of the file using xmlwf command.
We find that the xml file is not well formed because the start tag of student is wrong (see the highlighted text). Now we will correct this as bellow:
We will test the file again as below. we find that now the document is well formed.
Like wise it will throw error for erroneous xml file. Other errors could be:
OPTIONS -c If the input file is well-formed and xmlwf doesn't encounter any errors, the input file is simply copied to the output directory unchanged. This implies no namespaces (turns off -n) and requires -d to specify an output file. -d output-dir The output filenames will be exactly the same as the input filenames or "STDIN" if the input is coming from standard input. Therefore, you must be careful that the output file does not go into the same directory as the input file. Otherwise, xmlwf will delete the input file before it generates the output file (just like running cat < file > file in most shells). Two structurally equivalent XML documents have a byte-for-byte identical canonical XML representation. -e encoding -m Outputs some strange sort of XML file that completely describes the the input file, including character postitions. Requires -d to specify an output file. -n Turns on namespace processing. (describe namespaces) -c disables namespaces. -p Tells xmlwf to process external DTDs and parameter entities. Normally xmlwf never parses parameter entities. -p tells it to always parse them. -p implies -x. -r Normally xmlwf memory-maps the XML file before parsing; this can result in faster parsing on many platforms. -r turns off memory-mapping and uses normal file IO calls instead. Of course, memory-mapping is automatically turned off when reading from standard input. Use of memory-mapping can cause some platforms to report substantially higher memory usage for xmlwf, -s Prints an error if the document is not standalone. A document is standalone if it has no external subset and no references to parameter entities. -t Turns on timings. This tells Expat to parse the entire file, but not perform any processing. This gives a fairly accurate idea of the raw speed of Expat itself without client overhead. -t turns off most of the output options (-d, -m, -c, ...). -v Prints the version of the Expat library being used, including some information on the compile-time configuration of the library, and then exits. -w Enables support for Windows code pages. Normally, xmlwf will throw an error if it runs across an encoding that it is not equipped to handle itself. With -w, xmlwf will try to use a Windows code page. See also -e. -x Turns on parsing external entities.
|
|
Related blogs
You may also like to see:
[2014-03-17] | [Open System-Linux] |
AWK command for scanning and analysing a large file in Linux |
[2015-06-03] | [Open System-Linux] |
STAT command : check file or filesystem statistics |
[2014-02-19] | [Open System-Linux] |
Shift Key is not working!! Mapping keyboard keys from one to another |
[2016-02-05] | [Open System-Linux] |
Lets try to understand sticky bit concept in Linux! |
[2014-02-12] | [Open System-Linux] |
SCP a secure copy program in Linux |
Total comments: 0 | |