spl-schema-from-xml

The spl-schema-from-xml command creates an SPL tuple declaration from an XML document.

Usage

Figure 1. spl-schema-from-xml

1? --attributesName=name? 
2.1 -c
2.1 --outputClause? --composite=name? 
2.1 -f
2.1 --flatten
1=
2.1 attributes
2.1 elements
2.1 none? 
2.1 -h
2.1 --help?  --ignoreNamespaces? --mainComposite=compositeName? --namespace=name 
2.1 -o
2.1 --outfile
1=filename? --textName=name 
2.1 -t
2.1 --trigger
1=
1+ ,triggerXPath? 
2.1 -x
2.1 --xsd
1=fileName  xmlFileName
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.
Specify whether the attribute or nested element can be flattened. The valid values are:
  • attributes: For each attribute, an SPL attribute is added with the same name as the XML attribute, and type rstring if the attribute is considered mandatory, or list<rstring>[1] if the attribute is considered optional.
  • elements: For each nested element that can be flattened, an SPL attribute is added of type rstring (if the nested element is mandatory and has a cardinality of 1), list<rstring>[1] (if the nested element is considered optional with a cardinality of 1), or list<rstring> (if the nested element is considered optional or has a cardinality > 1).
  • none: Do not flatten the attribute or element. This value is the default.
-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 parameter ignoreNamespaces : 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