34 |
35 |
--------------------------------------------------------------------------------
/statemachine_test.py:
--------------------------------------------------------------------------------
1 | from statemachine import StateMachine
2 |
3 | def ones_counter(val):
4 | print("ONES State: ", end=' ')
5 | while 1:
6 | if val <= 0 or val >= 30:
7 | newState = "Out_of_Range"
8 | break
9 | elif 20 <= val < 30:
10 | newState = "TWENTIES"
11 | break
12 | elif 10 <= val < 20:
13 | newState = "TENS"
14 | break
15 | else:
16 | print(" @ %2.1f+" % val, end=' ')
17 | val = math_func(val)
18 | print(" >>")
19 | return newState, val
20 |
21 | def tens_counter(val):
22 | print("TENS State: ", end=' ')
23 | while 1:
24 | if val <= 0 or val >= 30:
25 | newState = "Out_of_Range"
26 | break
27 | elif 1 <= val < 10:
28 | newState = "ONES"
29 | break
30 | elif 20 <= val < 30:
31 | newState = "TWENTIES"
32 | break
33 | else:
34 | print(" #%2.1f+" % val, end=' ')
35 | val = math_func(val)
36 | print(" >>")
37 | return (newState, val)
38 |
39 | def twenties_counter(val):
40 | print("TWENTIES State:", end=' ')
41 | while 1:
42 | if val <= 0 or val >= 30:
43 | newState = "Out_of_Range"
44 | break
45 | elif 1 <= val < 10:
46 | newState = "ONES"
47 | break
48 | elif 10 <= val < 20:
49 | newState = "TENS"
50 | break
51 | else:
52 | print(" *%2.1f+" % val, end=' ')
53 | val = math_func(val)
54 | print(" >>")
55 | return (newState, val)
56 |
57 | def math_func(n):
58 | from math import sin
59 | return abs(sin(n))*31
60 |
61 | if __name__== "__main__":
62 | m = StateMachine()
63 | m.add_state("ONES", ones_counter)
64 | m.add_state("TENS", tens_counter)
65 | m.add_state("TWENTIES", twenties_counter)
66 | m.add_state("OUT_OF_RANGE", None, end_state=1)
67 | m.set_start("ONES")
68 | m.run(1)
69 |
70 |
--------------------------------------------------------------------------------
/test.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
--------------------------------------------------------------------------------
/docs/sam.css:
--------------------------------------------------------------------------------
1 | :root
2 | {
3 | --title-font: "Gill Sans", sans-serif;
4 | }
5 |
6 | body
7 | {
8 | max-width: 42rem
9 | }
10 |
11 | .note
12 | {
13 | box-sizing: border-box;
14 | max-width: 42rem;
15 | width: 100%;
16 | display: table;
17 | margin: 0 0 20px;
18 | border-style: solid;
19 | background: #fff3d4;
20 | border-collapse: separate;
21 | border-color: #f6b73c;
22 | clear: left;
23 | padding: 12px 32px 12px 12px;
24 | border-width: 0 0 0 5px;
25 | }
26 |
27 | .note::before
28 | {
29 | display: inline-block;
30 | width: 30px;
31 | font-family: var(--title-font);
32 | font-size: 12pt;
33 | font-style: normal;
34 | font-weight: 400;
35 | content: 'NOTE:';
36 |
37 | }
38 |
39 | pre.codeblock
40 | {
41 | box-sizing: border-box;
42 | max-width: 42rem;
43 | width: 100%;
44 | display: table;
45 | margin: 0 0 20px;
46 | border-style: solid;
47 | background: #e4f0f5;
48 | border-collapse: separate;
49 | border-color: #3f87a6;
50 | clear: left;
51 | padding: 12px 32px 12px 12px;
52 | border-width: 0 0 0 5px;
53 | }
54 |
55 | .title
56 | {
57 | font-family: var(--title-font);
58 | }
59 |
60 | .structures::before
61 | {
62 | font-family: var(--title-font);
63 | font-size: 18pt;
64 | content: "Structures";
65 | font-weight: bold;
66 | }
67 | .syntax::before
68 | {
69 | font-family: var(--title-font);
70 | font-size: 12pt;
71 | content: "Syntax";
72 | font-weight: bold;
73 | }
74 | .semantics::before
75 | {
76 | font-family: var(--title-font);
77 | font-size: 12pt;
78 | content: "Semantics";
79 | font-weight: bold;
80 | }
81 | .model::before
82 | {
83 | font-family: var(--title-font);
84 | font-size: 12pt;
85 | content: "Model";
86 | font-weight: bold;
87 | }
88 | .xml-serialization::before
89 | {
90 | font-family: var(--title-font);
91 | font-size: 12pt;
92 | content: "XML Serialization";
93 | font-weight: bold;
94 | }
95 | .SOM::before
96 | {
97 | font-family: var(--title-font);
98 | font-size: 12pt;
99 | content: "SAM Object Model";
100 | font-weight: bold;
101 | }
102 |
103 | dt
104 | {
105 | font-weight: bold;
106 | }
107 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | sam
2 | ===
3 |
4 | Semantic Authoring Markdown
5 |
6 | XML was designed to be human readable, but not human writable. Graphical editors help, though they have their issues
7 | (like trying to find the right insertion point to add permitted elements). But graphical editors have a problem: when
8 | they hide the tags, they also hide the structure.
9 |
10 | Semantic Authoring Markdown brings the ideas behind Markdown -- a natural syntax for writing HTML documents -- to
11 | structured writing. It creates a syntax that captures structure, like XML, but is easy to write in a text editor
12 | -- like markdown.
13 |
14 | ### Documentation
15 |
16 | See the documentation at https://mbakeranalecta.github.io/sam/.
17 |
18 | ### NOTE
19 |
20 | The SAM Language is still being defined and both the language itself and the way it is serialized and represented internally by the parser is subject to change. I hope to stabilize the language definition soon.
21 |
22 | ### Backward-incompatible changes
23 |
24 | Since SAM is under active development, there may be backward-incompatible changes in the language. They will be noted here as they occur, up until we get to the point where the language or its serialization are considered final.
25 |
26 | * Revision 227cb3dd7bb322f5579858806071c1ff8456c0b6 introduced a change in the
27 | way the XML representation of a record is generate. A record
28 | used to output as "row". It is now output as "record".
29 |
30 | * Revision 3fdd6528d88b1a7f0a72c10ce5b5e768433eaf19 introduced a change in how inline code is serialized. It is now serialized as a `` element rather than as a `` element with an `` nested element.
31 |
32 | * Revision 8e8c6a0b4c9c41bd72fab5fd53e3d967e9688110 removed the `===` flag for a block of embedded code, which had been briefly introduced in an earlier revision. Blocks of embed code should now be represented as regular code blocks using an encoding attribute `(=svg)` rather than a language attribute `(svg)`.
33 |
34 | * Revision fac3fea6a9570a20c825369417ab2eaf94d34d2b made annotation lookup case insensitive. Case sensitive lookup can be turned on using the declaration `!annotation-lookup: case sensitive`
35 |
36 | * Revision 828ef33d291f1364a6edf036588ac5f21fac0abb addressed issue #142 by detecting recursive includes. This had the side effect of changing the behavior when the parser encounters an error in an included file. Previously this error was demoted to a warning (not sure why). Now it is treated as an error and stops the parser. Without this change, the error would not get noted in the error count for batch processing, which is clearly not a good idea. To allow for more lenient error handling while retaining appropriate error reporting, we would need to introduce a reportable non-fatal error type. Issue #148 has been raised to consider this.
37 |
38 | * Revision e0fa711d14219cbad19636515e2dc2bbe3a82f28:
39 |
40 | * Changed the format of error messages to report the original line on which the error occurred rather than a representation of the object created.
41 |
42 | * Changed the format produced by the `__str__()` method on doc structure objects to a normalized representation of the input text generated by the new `regurgitate()` method.
43 |
44 | * Changed the serialization of citations on a block so they come before the title, not after it.
45 |
46 | * Changed the object model of Blockinsert and Inlineinsert object to make the type and item value separate fields of the object rather than simple attributes.
47 |
48 | * Changed serialization of block embed from "embed" to "embedblock" to be consistent with "codeblock".
49 |
50 | * Changed type of embedded blocks from Codeblock to Embedblock.
51 |
52 | * Removed support for embeded XML fragments per the discussion of issue #145. SAM has outgrown this feature, which is incompatible with the plan to introduce SAM Schemas.
53 |
54 | * Revision 1d16fd6d0544c32fa23930f303989b1b4a82c477 addressed #157 by changing the serialization of citations as described in #157 and adding support of the use of keys in citations.
55 |
56 | * Revision ad4365064bdfe61fa43228991a31b3174feb2957 removes the smart quotes parser option (the flag that turned smart quotes on and off on the command line) and introduced the `!smart-quotes` document declaration and the option to add custom smart quotes rules to the parser.
57 |
58 | * Revision b4ca40baa03233ff306ed20a59da92668e4e0872 changes the syntax for inserting a value by reference.
59 | It used to be `>(#foo)` but this was confusing because parenthese are used to create names and ids, not
60 | to reference them. The syntax for referencing a name or id is [#foo]. So, the syntax for inserting a value by
61 | reference is now `>[#foo]`. This applies to strings, ids, names, fragments, and keys. Note that the syntax for
62 | inserting a value by URI still uses parentheses, since this is new information, not a reference to another
63 | internal value. Also note the difference between `[#foo]` which means generate a reference to the content with
64 | the name `foo` and `>[#foo]` which means insert the content with the name foo at the current location. (These are
65 | of course, operations performed at application layer, not by the parser.)
66 |
67 | * Starting with revision dd07a4b798fcaa14a722a345b5ab8e07c3df42a1 the way attributes were modeled internally
68 | changed. Instead of using as separate Attribute object, attributes became Python attributes on the relevant
69 | block or phrase object. This does not affect command line use but would affect programmatic access to
70 | the document structure.
71 |
72 | * Starting with revision dd07a4b798fcaa14a722a345b5ab8e07c3df42a1, the use of fragment references
73 | with the syntax `[~foo]` was removed (see issue #166). Fragments can be inserted by name or ID just
74 | like any other block type.
75 |
76 | * From revision 3e9b8f6fd8cddf9cbedb25c44ab48323216ce71e
77 |
78 | * The change to insert by reference in b4ca40baa03233ff306ed20a59da92668e4e0872
79 | is reversed. It caused slightly more confusion than the old version.
80 |
81 | * The `~` symbol or referencing an fragment is removed. Fragments should
82 | be referenced by name or id.
83 |
84 | * The strings feature has been renamed "variable". This chiefly affects
85 | the serialization of variable definitions and references.
86 |
87 | * In revision 1f20902624d29dab002353df8374952c63fff81d the serialization of citations has been changed to support
88 | compound identifiers and to support easier processing of citations. See the
89 | language docs for details.
90 |
91 | * In revision defbc97c9bd592ab454296852c3d9a65e1007996 the command line options changed to support three different
92 | output modes as subcommands. Other options changed as well. See above for the new command line options. Also,
93 | the serialization interface to the parser changed. When calling the parser from a python program you no longer
94 | call `samparser.serialize('xml')` or `samparser.serialize('html')` but `samparser.doc.serialize_xml()`
95 | and `samparser.doc.serialize_html()` respectively.
96 |
97 | Please report any other backward incompatibilities you find so they can be added to this list.
98 |
99 |
--------------------------------------------------------------------------------
/docsource/samschemaspec.sam:
--------------------------------------------------------------------------------
1 | spec: SAM Schema Spec
2 |
3 | introduction:
4 |
5 | This is the specification for the SAM schema. It consists of a set of rules
6 | that specify how a sam schema is written and interpreted.
7 |
8 | rule:(#encoding) Encoding
9 |
10 | A SAM Schemas is encoded in UTF8
11 |
12 | rule:(#names) Names
13 |
14 | Element names must be valid XML names.
15 |
16 | rule:(#header) SAM Schema Header
17 |
18 | A SAM Schema begins with a SAM Schema Header
19 |
20 | A SAM schema header consists of the word "samschema" followed by a colon
21 | followed optionally by a namespace URI in curly braces. For example:
22 |
23 | ```(samschema)
24 | samschema:{http://spfeopentoolkit.org/ns/spfe-doc}
25 |
26 |
27 | If specified, the namespace URI specifies the default namespace of all the
28 | elements defined in the schema.
29 |
30 | rule:(#namespaces) Namespaces
31 |
32 |
33 | rule:(#root) Root element declaration
34 |
35 | Unlike an XML schema, which declares a collection of elements, several of which
36 | might be suitable for document roots, SAM schemas always declare a document
37 | root element.
38 |
39 | The document root element is declared as a valid element name beginning in the
40 | first column. It is the first element declaration following the SAM schema
41 | header and any {include statements}(rule "#include").
42 |
43 | rule:(#includes) Includes
44 |
45 | You can include another samschema in the current samschema document using
46 | an include statement.
47 |
48 | Included samschemas are processed as if they were part of the current
49 | samschema with the following provisions:
50 |
51 | * The included sam schema may not include a {root element declaration}[#root]).
52 | This means that any elements declared in an included samschama must be
53 | declared inside {named structures}[#stuctures].
54 |
55 | * If the included sam schema contains a default namespace, it will be used
56 | as the namespace for the elements defined in the included samschema.
57 |
58 | * If the included sam schema does not contain a default namespace declaration,
59 | and the including sam schema does contain a namespace declaration,
60 | the elements in the included sameschema will be placed in the declared namespace
61 | of the including samschema. This rule is applied down the tree of includes from
62 | the top level schema and is evaluated as each include statement is processed
63 | from the top down.
64 |
65 | rule:(#blocks) blocks declarations
66 |
67 | An SAM document consists of blocks, fields, record sets, flows, decorations,
68 | and annotations. Blocks and
69 | fields are declared the same way. The distinction between a block and a
70 | field is that a block has children and a field does not.
71 |
72 | For a field, SAM interprets any content after the field tag as the value of
73 | the field.
74 |
75 | For a block, SAM interprets any content after the block tag as an
76 | implicit {title}(rule "#implicit") field.
77 |
78 | rule:(#implicit) Implicit elements
79 |
80 | SAM recognized certain elements by their context in the SAM document. They
81 | do not have explicit tags in the content. These implicit elements are delineated
82 | either by punctuation or by their position relative to other elements.
83 |
84 | Implicit elements are implicit in the instance. They must be declared in the
85 | schema. It is an error if an implicit element occurs in the instance in a
86 | position in which it is not permitted in the schema.
87 |
88 | The implicit elements are as follows:
89 |
90 | |p| The p element represents a paragraph. It is recognized as a block of
91 | lines with no leading tag. It ends with a blank line. p elements are the
92 | only elements that can contain decorations and annotations.
93 |
94 | |bold| The bold element is a decoration occurring within text and is
95 | indicated by surrounding the text with asterisks.
96 |
97 | |italic| The italic decoration is indicated by surrounding the text
98 | with underscores.
99 |
100 | |mono| The mono decoration is indicated by back ticks. It indicates that
101 | the text should be rendered in a monospaced font.
102 |
103 | |quotes| The quotes decoration is indicated by surrounding the text
104 | in straight double quotes. You can use printers quotes in your document
105 | but they will be recognized as plain text, not markup.
106 |
107 | |title| The title element is implicit if there is text on the same line as
108 | a block tag, and if a title field is allowed as the first filed of the block.
109 | Text in this position is an error if a title field is not allowed in
110 | this location by a the schema of if the title element that is allowed is
111 | a block element rather than a field element.
112 |
113 | |blockquote| The blockquote block element is indicated by opening
114 | with three double quotes on a line by themselves, plus any parameters on
115 | the opening quotes. The quoted material must be indented from the blockquote
116 | markers
117 |
118 | |codeblock| The codeblock block element is indicated by opening and closing with
119 | three backtick on a line by themselves, plus any attributes on the
120 | opening backticks.
121 |
122 | |fragment| The fragment element contains a set of elements that can be
123 | reused by inserting the fragment into other locations in the document, or
124 | other documents. Fragments can also be use to apply conditions to a
125 | set of elements that would otherwise lack a common container.
126 | Recommended practice it to use fragments to contain
127 | only general text elements, which helps ensure that the inserted fragment will
128 | be schema compliant in the receiving document (assuming a common definition
129 | of general text elements). A fragment is indicated by three tildes (of the
130 | block name "fragment".
131 |
132 | |string| The definition of a string, which may be inserted in the
133 | document, but is not intended to be published where defined.
134 |
135 | rule:(#ideomatic-annotation-types) Idiomatic annotations
136 | Certain annotation types are considered idiomatic. That is, the name
137 | is considered bound by convention to a certain meaning. This does not
138 | mean that you cannot use the type for other things, or use other names
139 | for that function, but editor and tools are entitled to provide enhanced
140 | support for the idiomatic meaning of the names.
141 |
142 | In some cases, idiomatic types may have specialized or atypical treatment
143 | of the standard attributes. For instance, the link type uses the
144 | specifically attribute for the URL to link to, which is an eccentric
145 | interpretation of what specifically is intended for.
146 |
147 | |link| The link type is idiomatically used for inserting explicit hyperlinks. The
148 | specifically attribute is used to specify the url to link to. The
149 | namespace attribute remains a namespace. It could be used if the protocol
150 | or location is anything other than HTTP/Web.
151 |
152 | A schema can rename an idiomatic type, so that the tool behavior associated
153 | with the idiomatic type can be applied to the new type:
154 |
155 | ```(samschema)
156 | href=link
157 |
158 |
159 | rule:(#idiomatic-elements) Idiomatic elements
160 |
161 | Idiomatic elements are elements with intended meanings. Those meaning are
162 | not actually enforced by the SAM parser and the application is free to
163 | do what it likes with them. However, users and editing applications are
164 | entitled to treat the idiomatic elements as having their intended meanings.
165 | In some cases, the annotations of idiomatic elements are interpreted in
166 | special ways. The attributes will be assigned names that reflect their idiomatic usage,
167 | rather than the standard names.
168 |
169 | |blockquote| Annotation is recognized as a citation. Annotation type is
170 | recognized as the type of publication (web, book, article, etc.). Specifically
171 | the text of the citation is the format specified by the namespace attribute.
172 | It specifically attribute will be named "citation", and the namespace attribute
173 | will be named format.
174 | It is up to the downstream processor to parse the citation into its parts.
175 |
176 |
177 | |codeblock| Annotation type is recognized as a specifying the language and
178 | source of the codeblock. Specifically is recognized as the source and is
179 | named "source".
180 |
181 |
182 | rule:(#implicit-structures) Implicit structures
183 | SAM also recognized implicit structures. An implicit structure occurs where
184 | more than one element is recognized by context. The implicit structures are:
185 |
186 | |unordered lists| Unordered lists are indicated by starting a line with an
187 | asterisk. The root element of the structure in {ul}(element).
188 | The container for the list item is {li}(element). The container for
189 | the text is {p}(element).
190 |
191 | |ordered lists| Ordered lists are indicated by starting a line with a number.
192 | Numbers do not have to be sequential. The root element of the structure in {ol}.
193 | The container for the list item is {li}. The container for the text is {p}.
194 |
195 | |labeled lists| Labeled lists are indicated by surrounding the label text with
196 | pipe characters at the start of a paragraph. The root element of the structure
197 | in {ll}(element). Each labeled list item has the name {li} and contains the label
198 | and the labeled paragraph.
199 |
200 | |block titles| When you place text after the name of a block that has nested
201 | content (as opposed to one that is merely a field with a single value), that
202 | text is treated as {title}(element) for the block.
203 |
204 | rule:(#rename-implicit) Renaming implicit structures
205 |
206 | You can rename the implicit elements so that the output of the SAM parser
207 | gives them different names. To rename an implicit element, use the new name
208 | followed by an equals sign, followed by the implicit element name.
209 |
210 | Thus, to create a paragraph element named para instead of p, specify the
211 | element as follows:
212 |
213 | ```(samschema)
214 | para=p
215 |
216 |
217 | rule:(#create-implicit) Creating implicit structures
218 |
219 | rule:(#order-number) Order and number of elements in structures
220 |
221 | You can indicate the order and number of elements in a structure.
222 |
223 | |~| All the items in the structure in any order.
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
--------------------------------------------------------------------------------
/test.xslt:
--------------------------------------------------------------------------------
1 |
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 | <!DOCTYPE html>
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 | &
259 | &
260 |
261 |
262 | "
263 | "
264 |
265 |
266 | <
267 | <
268 |
269 |
270 | >
271 | >
272 |
273 |
274 |
275 |
276 |
277 | &
278 | &
279 |
280 |
281 | <
282 | <
283 |
284 |
285 | >
286 | >
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
--------------------------------------------------------------------------------
/LICENSE-2.0.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/docsource/parser.sam:
--------------------------------------------------------------------------------
1 | article: SAM Parser
2 |
3 | <<<(menu.sami)
4 |
5 | SAM Parser is an application to process SAM files into an equivalent XML representation which
6 | you can then further process in any desired form of output.
7 |
8 | SAM Parser allows to specify an XSLT 1.0 stylesheet to post-process the output XML into a
9 | desired output format. In particular, it only allows for processing individual SAM files to
10 | individual output files. It does not support any kind of assembly or linking of multiple source files.
11 | This facility is not intended to meet all output needs, but it
12 | provides a simple way to create basic outputs.
13 |
14 | SAM Parser is a Python 3 program that requires the regex and libxml libraries that are not
15 | distributed with the default Python distribution. If you don't already have a Python 3 install,
16 | the easiest way to get one with the required libraries installed is to install
17 | {Anaconda}(https://www.continuum.io/downloads).
18 |
19 | SAM Parser is invoked as follows:
20 |
21 | ```(console)
22 | samparser
23 |
24 | Three output modes are available:
25 |
26 | * `xml` outputs a version of the document in XML. You can use an XSD schema to validate the output file and/or an XSLT 1.0 stylesheet to transform it into another format.
27 | * `html` outputs a version of the document in HTML with embedded semantic markup. You can supply one of more CSS stylesheets and/or one or more JavaScrip files to include.
28 | * `regurgitate` outputs a version of the document in SAM with various references resolved and normalized.
29 |
30 | All output modes take the following options:
31 |
32 | * `` The path the SAM file or files to be processed. (required)
33 | * `[-outfile