1xmerl_xsd(3)               Erlang Module Definition               xmerl_xsd(3)
2
3
4

NAME

6       xmerl_xsd - Interface module for XML Schema validation.
7

DESCRIPTION

9       Interface module for XML Schema validation. It handles the W3.org spec‐
10       ifications of XML Schema second edition 28 october 2004. For an  intro‐
11       duction  to  XML  Schema study part 0. An XML structure is validated by
12       xmerl_xsd:validate/[2,3].
13

DATA TYPES

15         filename() = string():
16
17
18         global_state():
19
20
21           The global state of the  validator.  It  is  representated  by  the
22           #xsd_state{} record.
23
24         option_list():
25
26
27           Options allow to customize the behaviour of the validation.
28
29           Possible options are :
30
31           {tab2file,boolean()}:
32             Enables  saving  of abstract structure on file for debugging pur‐
33             pose.
34
35           {xsdbase,filename()}:
36             XSD Base directory.
37
38           {fetch_fun,FetchFun}:
39             Call back function to fetch an external resource.
40
41           {fetch_path,PathList}:
42             PathList is a list of directories to search when fetching  files.
43             If the file in question is not in the fetch_path, the URI will be
44             used as a file name.
45
46           {state,State}:
47             It is possible by this option to provide  a  state  with  process
48             information from an earlier validation.
49

EXPORTS

51       file2state(FileName) -> {ok, State} | {error, Reason}
52
53              Types:
54
55                 State = global_state()
56                 FileName = string()
57
58              Reads  the  schema  state  with all information of the processed
59              schema from a file created with state2file/[1,2]. The format  of
60              this  file is internal. The state can then be used validating an
61              XML document.
62
63       format_error(L::Errors) -> Result
64
65              Types:
66
67                 Errors = tuple() | [tuple()]
68                 Result = string() | [string()]
69
70              Formats error descriptions to human readable strings.
71
72       process_schema(Schema) -> Result
73
74              Equivalent to process_schema(Schema, []).
75
76       process_schema(Schema, Options) -> Result
77
78              Types:
79
80                 Schema = string()
81                 Result = {ok, State} | {error, Reason}
82                 State = global_state()
83                 Reason = [ErrorReason] | ErrorReason
84                 Options = option_list()
85
86              Reads the referenced XML schema and checks  that  it  is  valid.
87              Returns  the global_state() with schema info or an error reason.
88              The error reason may be a list of several  errors  or  a  single
89              error encountered during the processing.
90
91       process_schemas(Schemas) -> Result
92
93              Equivalent to process_schema(Schemas, []).
94
95       process_schemas(Schemas, Options) -> Result
96
97              Types:
98
99                 Schemas = [{NameSpace, string()} | Schemas] | []
100                 Result = {ok, State} | {error, Reason}
101                 Reason = [ErrorReason] | ErrorReason
102                 Options = option_list()
103
104              Reads  the  referenced  XML schemas and controls they are valid.
105              Returns the global_state() with schema info or an error  reason.
106              The  error  reason  may  be a list of several errors or a single
107              error encountered during the processing.
108
109       process_validate(Schema, Xml::Element) -> Result
110
111              Equivalent to process_validate(Schema, Xml, []).
112
113       process_validate(Schema, Xml::Element, Opts::Options) -> Result
114
115              Types:
116
117                 Schema = string()
118                 Element = XmlElement
119                 Options = option_list()
120                 Result = {ValidXmlElement, State} | {error, Reason}
121                 Reason = [ErrorReason] | ErrorReason
122
123              Validates a  parsed  well-formed  XML  element  towards  an  XML
124              schema.
125
126              Validates in two steps. First it processes the schema, saves the
127              type and structure info in an ets table and then  validates  the
128              element towards the schema.
129
130              Usage example:
131
132              1>{E,_} = xmerl_scan:file("my_XML_document.xml").
133              2>{E2,_} = xmerl_xsd:validate("my_XML_Schema.xsd",E).
134
135              Observe  that  E2  may  differ  from E if for instance there are
136              default values defined in my_XML_Schema.xsd.
137
138       state2file(S::State) -> ok | {error, Reason}
139
140              Same as state2file(State,SchemaName)
141
142              The name of the saved file is  the  same  as  the  name  of  the
143              schema, but with .xss extension.
144
145       state2file(S::State, FileName) -> ok | {error, Reason}
146
147              Types:
148
149                 State = global_state()
150                 FileName = string()
151
152              Saves  the  schema  state  with all information of the processed
153              schema in a file. You can provide the file name  for  the  saved
154              state. FileName is saved with the .xss extension added.
155
156       validate(Xml::Element, State) -> Result
157
158              Equivalent to validate(Element, State, []).
159
160       validate(Xml::Element, State, Opts::Options) -> Result
161
162              Types:
163
164                 Element = XmlElement
165                 Options = option_list()
166                 Result = {ValidElement, global_state()} | {error, Reasons}
167                 ValidElement = XmlElement
168                 State = global_state()
169                 Reasons = [ErrorReason] | ErrorReason
170
171              Validates a parsed well-formed XML element (Element).
172
173              A  call  to  validate/2 or validate/3 must provide a well formed
174              parsed XML element #xmlElement{} and  a  State,  global_state(),
175              which  holds  necessary  information  from  an already processed
176              schema. Thus validate enables reuse of  the  schema  information
177              and  therefore  if  one shall validate several times towards the
178              same schema it reduces time consumption.
179
180              The result, ValidElement, is the valid element that conforms  to
181              the  post-schema-validation infoset. When the validator finds an
182              error it tries to continue and reports  a  list  of  all  errors
183              found.  In those cases an unexpected error is found it may cause
184              a single error reason.
185
186              Usage example:
187
188              1>{E,_} = xmerl_scan:file("my_XML_document.xml").
189              2>{ok,S} = xmerl_xsd:process_schema("my_XML_Schema.xsd").
190              3>{E2,_} = xmerl_xsd:validate(E,S).
191
192              Observe that E2 may differ from E  if  for  instance  there  are
193              default values defined in my_XML_Schema.xsd.
194

AUTHORS

196       <>
197
198
199
200                                 xmerl 1.3.26                     xmerl_xsd(3)
Impressum