spl-schema-from-xml
The spl-schema-from-xml command creates an SPL tuple declaration from an XML document.
Usage
spl-schema-from-xml -h, --help |
{[--attributesName=<name>] [-c,--outputClause] [--composite=<name>]
[-f, --flatten=<attributes | elements | none>]
[--ignoreNamespaces] [--mainComposite=<name>][--namespace=<name>]
-o,--outfile=<filename> [--textName=<name>]
-t,--trigger=<triggerXPath[,...]> [-x,--xsd=<filename>] <xmlFileName>}
Authority
You do not need any authority to run this command.
Description
This command generates artifacts for use with the XMLParse operator.
The spl-schema-from-xml command
examines an XML document and produces an SPL tuple type declaration
for each unique element type. If there are XML attributes within an
element, an SPL attribute of type map<rstring, rstring> called _attrs
is
added to the tuple declaration. If the element has text content, an
SPL attribute of type rstring
called _text
is
added to the tuple declaration. If there are any nested elements,
a nested tuple (or list<tuple>) for each nested element type with
the element name as its name is added to the tuple declaration. Element
names that are not representable in SPL cause an unrecoverable error.
The xml:space="preserve"
attribute
is ignored when determining whether an element has text content. XML
elements are considered to have text content only if there are non-whitespace
characters between the begin and end tag.
After the spl-schema-from-xml command is run, the tuple declarations and optional output clause can be copied into your SPL application. The tuple declarations and output clause can also be edited, for example if the SPL tuple attribute names differ from the XML element and attribute names.
Options and arguments
- --attributesName=name
- Specifies the name to use for the attributes map. By default, the name is
_attrs
. - -c, --outputClause
- Specifies that output clauses must be generated.
- -composite=compositeName
- Generate a complete composite operator that wraps an XMLParse operator that is configured to read the XML and output a stream for each trigger specified.
- -f, --flatten=attributes|elements|none
- Specifies to flatten the attributes, elements, or neither.
- -h, --help
- Specifies to show the command syntax and help information.
- --ignoreNamespaces
- Specifies to ignore the prefix
:
part of XML names. This option is intended to be used with the XMLParse operator parameterignoreNamespaces : true;
. - -mainComposite=compositeName
- Specifies to generate a main composite that calls the composite generated by the -–composite option, giving it a FileSource and an FileSink operator for each output stream. The resulting SPL file is compilable and runnable. The -–composite option must be specified or the -–mainComposite option is ignored.
- -namespace=namespace
- Specifies to add a namespace directive in the generated SPL file. The -–composite option must be specified or the -–namespace option is ignored.
- -o, --outfile=fileName
- Specify the file name into which the SPL tuple declaration and optional output clauses are generated. This value is required.
- --textName=name
- Specifies the name that is used in place of
_text
for the element text content. - -t, --trigger=triggerXPath
- Specifies a list of trigger expressions. The command generates one output clause per trigger. This value is required.
- xmlFileName
- Specifies the name of the input XML document that is used to generate the output. This value is required.
- -x, --xsd=fileName
- Specifies that an XSD file must be generated, and the name of the file.
Examples
spl-schema-from-xml -o=output --trigger=/c --outputClause --xsd=myFile.xsd myInputFile.xml