-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript_parameters.py
55 lines (44 loc) · 2.05 KB
/
script_parameters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright 2015, 2016 Altova GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__copyright__ = "Copyright 2015, 2016 Altova GmbH"
__license__ = 'http://www.apache.org/licenses/LICENSE-2.0'
# This script demonstrates how to supply additional parameters to RaptorXML Python API v2 scripts.
# To specify one or more script parameters on the command line, use the --script-param="key:value" option.
# To specify one or more script parameters in XMLSpy, edit the "Script Parameters" field in the RaptorXML Server Options dialog.
#
# Example invocation:
# raptorxml valxml-withxsd --streaming=false --script=script_parameters.py
# --script-param="mystring:Lorem ipsum" --script-param="myint:99"
# --script-param="foo:bar" ExpReport.xml
from altova import *
def print_params(params):
# Print out all supplied script parameters
for key, value in params.items():
print(key, '=', value)
# Access some specific parameters (using predefined defaults if parameter
# was not specified)
mystring = params.get('mystring', 'hello world')
# Manually cast to int, as script parameters are always represented as
# strings
myint = int(params.get('myint', 42))
print('mystring =', mystring)
print('myint =', myint)
# Main entry point, will be called by RaptorXML after the XML instance
# validation job has finished
def on_xsi_finished(job, instance):
print_params(job.script_params)
# Main entry point, will be called by RaptorXML after the XBRL instance
# validation job has finished
def on_xbrl_finished(job, instance):
print_params(job.script_params)