xmerl_xsd(3erl)
Erlang Module Definition energy, but make it group chat: this is the manual page for xmerl_xsd(3erl), and itβs all about XML Schema validation. π¦
β¨ NAME β¨
xmerl_xsd β Interface module for XML Schema validation. π
πΈ DESCRIPTION πΈ
Interface module for XML Schema validation. It handles the W3.org specifications of XML Schema second edition 28 october 2004. For an introduction to XML Schema study part 0. An XML structure is validated by xmerl_xsd:validate/[2,3]. Slay, thatβs the whole vibe. β¨
π DATA TYPES π
filename() = string():β your filename is a string, no cap. πglobal_state():β the global state of the validator. It is represented by the#xsd_state{}record. Main character state, honestly. πoption_list():β options allow to customize the behaviour of the validation. Possible options are:{tab2file,boolean()}:β enables saving of abstract structure on file for debugging purpose. π{xsdbase,filename()}:β XSD Base directory. ποΈ{fetch_fun,FetchFun}:β call back function to fetch an external resource. π{fetch_path,PathList}:βPathListis a list of directories to search when fetching files. If the file in question is not in thefetch_path, the URI will be used as a file name. π{state,State}:β it is possible by this option to provide a state with process information from an earlier validation. β»οΈ
π EXPORTS π
file2state(FileName) -> {ok, State} | {error, Reason}
Types:
State = global_state()FileName = string()
Reads the schema state with all information of the processed schema from a file created with state2file/[1,2]. The format of this file is internal. The state can then be used validating an XML document. ποΈ
format_error(L::Errors) -> Result
Types:
Errors = tuple() | [tuple()]Result = string() | [string()]
Formats error descriptions to human readable strings. Helpful icon behaviour. π«Ά
process_schema(Schema) -> Result
Equivalent to process_schema(Schema, []).
process_schema(Schema, Options) -> Result
Types:
Schema = string()Result = {ok, State} | {error, Reason}State = global_state()Reason = [ErrorReason] | ErrorReasonOptions = option_list()
Reads the referenced XML schema and checks that it is valid. Returns the global_state() with schema info or an error reason. The error reason may be a list of several errors or a single error encountered during the processing. π₯
process_schemas(Schemas) -> Result
Equivalent to process_schema(Schemas, []).
process_schemas(Schemas, Options) -> Result
Types:
Schemas = [{NameSpace, string()} | Schemas] | []Result = {ok, State} | {error, Reason}Reason = [ErrorReason] | ErrorReasonOptions = option_list()
Reads the referenced XML schemas and controls they are valid. Returns the global_state() with schema info or an error reason. The error reason may be a list of several errors or a single error encountered during the processing. π
process_validate(Schema, Xml::Element) -> Result
Equivalent to process_validate(Schema, Xml, []).
process_validate(Schema, Xml::Element, Opts::Options) -> Result
Types:
Schema = string()Element = XmlElementOptions = option_list()Result = {ValidXmlElement, State} | {error, Reason}Reason = [ErrorReason] | ErrorReason
Validates a parsed well-formed XML element towards an XML schema.
Validates in two steps. First it processes the schema, saves the type and structure info in an ets table and then validates the element towards the schema.
Usage example:
1>{E,_} = xmerl_scan:file("my_XML_document.xml").
2>{E2,_} = xmerl_xsd:validate("my_XML_Schema.xsd",E).
Observe that E2 may differ from E if for instance there are default values defined in my_XML_Schema.xsd. π§
state2file(S::State) -> ok | {error, Reason}
Same as state2file(State,SchemaName)
The name of the saved file is the same as the name of the schema, but with .xss extension. π
state2file(S::State, FileName) -> ok | {error, Reason}
Types:
State = global_state()FileName = string()
Saves the schema state with all information of the processed schema in a file. You can provide the file name for the saved state. FileName is saved with the .xss extension added. πΎ
validate(Xml::Element, State) -> Result
Equivalent to validate(Element, State, []).
validate(Xml::Element, State, Opts::Options) -> Result
Types:
Element = XmlElementOptions = option_list()Result = {ValidElement, global_state()} | {error, Reasons}ValidElement = XmlElementState = global_state()Reasons = [ErrorReason] | ErrorReason
Validates a parsed well-formed XML element (Element).
A call to validate/2 or validate/3 must provide a well formed parsed XML element #xmlElement{} and a State, global_state(), which holds necessary information from an already processed schema. Thus validate enables reuse of the schema information and therefore if one shall validate several times towards the same schema it reduces time consumption.
The result, ValidElement, is the valid element that conforms to the post-schema-validation infoset. When the validator finds an error it tries to continue and reports a list of all errors found. In those cases an unexpected error is found it may cause a single error reason.
Usage example:
1>{E,_} = xmerl_scan:file("my_XML_document.xml").
2>{ok,S} = xmerl_xsd:process_schema("my_XML_Schema.xsd").
3>{E2,_} = xmerl_xsd:validate(E,S).
Observe that E2 may differ from E if for instance there are default values defined in my_XML_Schema.xsd. π
π AUTHORS π
<> β thatβs literally what the author field says, bestie. π«Ά
Footer sign-off, because we donβt copy lines around here: source/version xmerl 1.3.31.1, manual page xmerl_xsd(3erl). The footer doesnβt print a date, so Iβm not inventing one β periodt. π
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms