C based XML tools in your $ORACLE_HOME

Being triggered by Laurent Schneider’s post “extract xml from the command line“; I completely forgot about the C-based XDK tooling you nowadays can find in your $ORACLE_HOME. You, probably just like me, weren’t even aware, there were some (C-based that is). Most of these are executable’s and not “just” Java tools, although xsql is a shell script that still starts Java. More information can be found here in the “Oracle® XML Developer’s Kit Programmer’s Guide 11.2

I mean in principle they are not “new”, they were there since 8.1.x, but now they are compiled executables which you can use on the shell prompt and or in scripting and that is, at least for me, easier than doing the same via their $ORACLE_HOME/xdk Java counterparts.

A shortlist:

[oracle@localhost bin]$ pwd
/home/oracle/app/oracle/product/11.2.0/dbhome_2/bin

[oracle@localhost bin]$ ls -l x* schema
-rwxr-xr-x 1 oracle oracle 3433339 Jun 23 19:56 schema
-rwxr-xr-x 1 oracle oracle 3582629 Jun 23 19:55 xml
-rwxr-xr-x 1 oracle oracle 4006197 Jun 23 19:56 xmlcg
-rwx------ 1 oracle oracle   49812 Mar 11  2009 xmlwf
-rwxr-xr-x 1 oracle oracle 3485095 Jun 23 19:56 xsl
-rwxr-xr-x 1 oracle oracle     748 Nov 12  2006 xsql
-rwxr-xr-x 1 oracle oracle 3496134 Jun 23 19:56 xvm

[oracle@localhost bin]$ file x* schema
xml:    ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
xmlcg:  ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
xmlwf:  ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
xsl:    ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
xsql:   Bourne shell script text executable
xvm:    ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
schema: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped

So here a small overview on what they can do…

schema

The “schema” binary is probably the XML Schema Processor and can validate schemas, allowing use of simple and complex XML datatypes.

[oracle@localhost bin]$ schema -h
Unknown switch -h
Usage: schema [flags]  [schema] [working dir]

Where:
        is the XML instance document to validate (required)
    [schema]      is the default schema (optional)
    [working dir] is the working directory for processing (optional)

Flags:
    -0                Always exit with code 0 (success)
    -c                Extra tests to improve code coverage
    -e      Specify default input file encoding
    -E      Specify output/data/presentation encoding
    -i                Ignore provided schema file
    -o           Validation options
    -p                Print instance document to stdout on success
    -v                Show version number
    -u                forced to Unicode path

[oracle@localhost bin]$ schema -v
Oracle XML Developers Kit 11.2.0.1.0

xml

Among others, “xml”, can be used for checks on XML well formedness and creates and parses XML with industry standard DOM and SAX interfaces.

[oracle@localhost bin]$ xml -h
Usage: xml    [switches] [document URI]
  or   xml -f [switches] [document filespec]
Switches:
    -B       Set the Base uri for XSLT processor.
 BaseUri of http://pqr/xsl.txt resolves pqr.txt to http://pqr/pqr.txt
    -c                Conformance check only, no validation
    -e      Specify default input file encoding (-ee to force)
    -E      Specify output/data/presentation encoding
    -f                File - Interpret  as filespec, not URI
    -G    evaluates XPointer scheme examples give in a file
    -h                Help - show this usage help (-hh for more options)
    -i             Number of times to iterate the XSLT processing
    -l      Language for error reporting
    -o    Specify output file of XSLT processor
    -p                Print document/DTD structures after parse
    -P                Pretty print from root element
    -PP               Pretty print from root node (DOC); includes XMLDecl
    -PE     Specify encoding for -P or -PP output
    -PX               Include XMLDecl in output always
    -s 

xmlcf

xmlcg” is a C++ tool to generate C++ classes based on XML input.

[oracle@localhost bin]$ xmlcg -h
Error: Unknown switch
Usage: xmlcg [switches] 
    -d           DTD - input is external DTD (specify output name)
    -o      Output - specify output directory
    -e       Encoding - specify input file encoding
    -h                 Help - show this usage help
    -v                 Version - show Class Generator version#
    -s           Schema - input is an XML Schema (spec. output name)

[oracle@localhost bin]$ xmlcg /tmp/otn_dev_xsd_schema.xml
Generating classes from DTD...
[oracle@localhost bin]$ xmlcg  /tmp/otn_dev_xsd_schema.invalid.xml
In line 14 of /tmp/otn_dev_xsd_schema.invalid.xml:
LPX-00225: end-element tag "OWNER" does not match start-element tag "ROW"
Parse failed, code 225

[oracle@localhost bin]$ xmlcg -v
Oracle XML Developers Kit 11.2.0.1.0

xmlwf

The “xmlwf” tool is not described in the XDK manual and just / “only” checks on XML well formedness which can be useful in itself.

[oracle@localhost bin]$ xmlwf -h
usage: xmlwf [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] [-e encoding] file ...

[oracle@localhost bin]$ xmlwf /tmp/otn_dev_xsd_schema.xml
[oracle@localhost bin]$ xmlwf /tmp/otn_dev_xsd_schema.invalid.xml
/tmp/otn_dev_xsd_schema.invalid.xml:14:17: mismatched tag

[oracle@localhost bin]$ xmlwf -v
xmlwf using expat_2.0.1
sizeof(XML_Char)=1, sizeof(XML_LChar)=1, XML_DTD, XML_CONTEXT_BYTES=1024, XML_NS

xsl

Tool “xsl” is a C XSLT generator and can transform XML into other text-based formats such as HTML.

[oracle@localhost bin]$ xsl -h
Usage: xsl [switches]  
  or   xsl -f [switches] [document filespec]
Switches:
    -B       Set the Base uri for XSLT processor.
 BaseUri of http://pqr/xsl.txt resolves pqr.txt to http://pqr/pqr.txt
    -e      Specify default input file encoding (-ee to force)
    -E      Specify output/data/presentation encoding
    -f                File - Interpret  as filespec, not URI
    -G    evaluates XPointer scheme examples give in a file
    -h                Help - show this usage help (-hh for more options)
    -i             Number of times to iterate the XSLT processing
    -l      Language for error reporting
    -o    Specify output file of XSLT processor
    -v                Version - show parser version and exit
    -V    To test top level variables in CXSLT
    -w                Whitespace - preserve ALL whitespace
    -W                Warning - stop parsing after a warning

xsql

Combines XML, SQL, and XSLT in the server to deliver dynamic Web content.

[oracle@localhost bin]$ xsql
Oracle XML Developers Kit 11.2.0.2.0 - Production
XML-25009: Missing arguments on command line

Usage: xsql xsqlFileURI [outFileName] [param1=value1 ... paramN=valueN]

xvm

“xvm” is the C alternative of the XSLT Virtual Machine (XVM) which provides a high-performance XSLT transformation engine that supports compiled stylesheets.

[oracle@localhost bin]$ xvm -h
Usage:
  xvm  switches  
  xvm  switches  

Switches:
    -c        Compile . The bytecode is in '.xvm'.
    -ct       Compile  and transform .
    -t        Transform  using bytecode from .
    -xc       Compile . The bytecode is in 'code.xvm'.
    -xct      Compile and evaluate  with .
    -xt       Evaluate XPath bytecode from  with .

Examples:
  xvm  -ct  db.xsl db.xml
  xvm  -t   db.xvm db.xml
  xvm  -xct "doc/emloyee[15]/family"  db.xml
Marco Gralike Written by: