1 Xorn/gEDA XML schematic format {#geda-xml-format}
2 ==============================
4 Xorn implements an alternative, XML-based file format for gEDA
5 schematic and symbol files. This is basically a verbose form of the
6 original gEDA file format. For example,
8 B 0 0 17000 11000 15 0 0 0 -1 -1 0 -1 -1 -1 -1 -1
12 <box x="0" y="0" width="170" height="110" color="lock" width="0"/>
14 However, there are some moderate changes to the format with the
15 intention to make the files more exactly represent what Xorn sees,
16 make the file format more readable, and make working with the files a
19 * Symbols and pixmaps aren't embedded directly into the object but are
20 defined once and referenced by ID. This allows multiple
21 component/picture objects to share the same embedded symbol/pixmap.
23 * Non-embedded symbols and pixmaps are optionally included in the
24 file, as well. This way, the file can be used without the original
25 dependencies at hand while updates in the library are still
26 propagated to the schematic.
28 * Coordinates are represented as fixed-point values; a value of
29 “12345” becomes “123.45”. Floating-point values are supported by
30 Xorn but are rounded to the nearest integer when saving to a file.
31 The XML format has an optional \a hybridnum feature which allows
32 preserving the fractional part; since it can't be represented
33 exactly in base 10, it's appended in hexadecimal notation after the
34 fixed-point part, so a value of “12345.75” would become “123.45:c”.
36 * Fields which have a default value are optional.
38 * Pin objects don't have a \a whichend flag; the first coordinate is
39 always the end which connects to nets. In order to allow an exact
40 SCH->XML->SCH round-trip, there is an additional flag \a inverted
41 which tells whether the pin should be inverted when stored to a
42 <tt>.sch</tt> or <tt>.sym</tt> file but isn't of any relevance
45 * Busses don't have a \a ripperdir field as this can be deduced from
46 the existing ripper components' orientation.
48 * Text objects which are considered attributes by libgeda are
49 represented by a special
50 <tt><attribute name="...">...</attribute></tt>
51 element. In the future, this could allow non-attribute texts to
52 contain “=” characters as well as arbitrary attribute names/values
53 without concern for gEDA attribute splitting rules. Also, it makes
54 automatic processing of the attributes easier.
56 To convert a <tt>.sch</tt> or <tt>.sym</tt> file to an XML file, use
57 <tt>xorn convert</tt>:
59 $ xorn convert resistor-1.sym resistor-1.sym.xml
61 and vice versa. Since the format is automatically guessed from the
62 file name, you'll have to specify the format explicitly when reading
63 from stdin or writing to stdout:
65 $ xorn convert -I sym -O symxml < resistor-1.sym > resistor-1.sym.xml
67 When converting <tt>.sch</tt> files to XML files, the symbols and
68 pixmaps referenced by the schematic are included in the XML file by
69 default. In order to make this possible, you'll need to specify the
70 symbol library directories:
72 $ xorn convert --symbol-library=sym/ \
73 --symbol-library-search=/path/to/library/ \
74 example.sch example.sch.xml
76 When using the default library included with gEDA, you can't use
77 <tt>\--symbol-library-search=</tt>, unfortunately, because it contains
78 symbol name conflicts.
80 If you don't want to include referenced symbols and pixmaps in the XML
81 file---for example, because you are keeping everything under version
82 control and want to minimize changes---you can pass the options
83 <tt>\--omit-symbols</tt> and <tt>\--omit-pixmaps</tt>:
85 $ xorn convert --omit-symbols example.sch example.sch.xml
88 # File format features
90 Instead of a sequential file format version, this format uses *file
91 format features*. The names of the features used in a file are
92 specified as a space-separated list in the attribute \c
93 file-format-features of the root element of the document.
94 Currently, the following file format features are defined:
98 Coordinates and lengths are specified in a hybrid fixed/floating point
99 number format. For example, the value \c "400" would be represented
100 as \c "4.00" which can be abbreviated as \c "4", and the value \c
101 "0.75" would be represented as \c "0.00:c" which can be abbreviated as
104 ## <tt>experimental</tt>
106 Indicates that the file format is experimental and should not be
107 relied upon for productive purposes. Non-experimental versions of the
108 package will refuse to parse a file with this feature.
113 At the root of the XML document is either a \c schematic or a \c
114 symbol element, depending on the file type. It contains a \c content
115 element which in turn contains all objects in the file. Additionally,
116 for each symbol or pixmap which is referenced or embedded in the file,
117 the root element contains a \c symbol or \c pixmap element,
120 <?xml version="1.0" encoding="UTF-8"?>
121 <schematic xmlns="https://hedmen.org/xorn/schematic/"
122 file-format-features="experimental hybridnum">
127 <symbol id="resistor-1" name="resistor-1.sym" mode="referenced">
139 ## Root element (<tt>schematic</tt> or <tt>symbol</tt>)
141 The format is the same for schematic and symbol files, but gEDA
142 imposes additional restrictions. For example, pin objects are only
143 allowed in symbol files, and net, bus, and component objects are only
144 allowed in schematic files. Therefore, it doesn't make sense for a \c
145 symbol root element to contain \c symbol reference elements.
148 -----------------------|----------------------------------------------
149 \c xmlns |<tt>%https://hedmen.org/xorn/schematic/</tt>
150 \c file-format-features|<em>space-separated list of feature names</em>
152 ## Reference element (<tt>symbol</tt> or <tt>pixmap</tt>)
154 In contrast to the original <tt>.sym/.sch</tt> file format, symbols
155 and pixmaps aren't directly specified by their file name. Instead,
156 the \c component or \c picture element contains a *symbol ID* or
157 *pixmap ID* which points to a \c symbol or \c pixmap reference
158 element, respectively. The reference element contains the actual file
159 name and/or the embedded file contents.
161 attribute|description
162 ---------|-----------------------------------------------------
163 id |arbitrary unique string which identifies this element
164 name |file name (optional if \c mode is \c embedded)
168 There are three possible reference modes:
171 ----------|-----------
172 referenced|The actual symbol or pixmap is found in the referenced file, but the contents of that file are included in case the file is lost, to be able to distribute the schematic as a single file, and to be able to detect and print a warning if the file has been modified.
173 omitted |Same as \c referenced, but the contents of the file aren't included (for use with source code management).
174 embedded |The contents of the symbol or pixmap are embedded. The original file name may or may not be specified for informational purposes.
176 The way how the contents of the referenced file are included is
177 different for symbols and pixmaps. For symbols, the \c symbol element
178 contains a \c content element which in turn contains all objects in
179 the symbol. For pixmaps, the \c pixmap element contains the
180 base64-encoded pixmap file as character data.
184 Contains an element for each top-level object in the file. Does not
189 attribute |type |default |valid
190 -------------|------------------|--------|------
191 \c linewidth |fixed-point number|0 |always
192 \c capstyle |cap style value |\c none |always
193 \c dashstyle |dash style value |\c solid|always
194 \c dashlength|fixed-point number|— |dash styles \c dashed, \c center, and \c phantom only
195 \c dashspace |fixed-point number|— |dash styles \c dotted, \c dashed, \c center, and \c phantom only
199 attribute |type |default |valid
200 ------------|------------------|---------|-------
201 \c filltype |fill type value |\c hollow|always
202 \c fillwidth|fixed-point number|— |fill styles \c mesh and \c hatch only
203 \c angle0 |integer |— |fill styles \c mesh and \c hatch only
204 \c pitch0 |fixed-point number|— |fill styles \c mesh and \c hatch only
205 \c angle1 |integer |— |fill style \c mesh only
206 \c pitch1 |fixed-point number|— |fill style \c mesh only
210 attribute |type |default
211 -------------|------------------|----------------
212 \c x |fixed-point number|—
213 \c y |fixed-point number|—
214 \c radius |fixed-point number|—
215 \c startangle|integer |—
216 \c sweepangle|integer |—
217 \c color |color value |<tt>graphic</tt>
219 <i>+ line attributes</i>
223 attribute|type |default
224 ---------|------------------|----------------
225 \c x |fixed-point number|—
226 \c y |fixed-point number|—
227 \c width |fixed-point number|—
228 \c height|fixed-point number|—
229 \c color |color value |<tt>graphic</tt>
231 <i>+ line attributes</i>
232 <i>+ fill attributes</i>
236 attribute |type |default
237 -------------|------------------|----------------
238 \c x |fixed-point number|—
239 \c y |fixed-point number|—
240 \c radius |fixed-point number|—
241 \c color |color value |<tt>graphic</tt>
243 <i>+ line attributes</i>
244 <i>+ fill attributes</i>
246 ## <tt>component</tt>
248 attribute |type |default
249 -------------|------------------|-------
250 \c x |fixed-point number|—
251 \c y |fixed-point number|—
252 \c selectable|boolean value |\c yes
253 \c angle |0, 90, 180 or 270 |\c 0
254 \c mirror |boolean value |\c no
255 \c symbol |symbol ID |—
257 Contains a \c text or \c attribute child element for each attached
262 attribute|type |default
263 ---------|------------------|-------
264 \c x0 |fixed-point number|—
265 \c y0 |fixed-point number|—
266 \c x1 |fixed-point number|—
267 \c y1 |fixed-point number|—
268 \c color |color value |<tt>graphic</tt>
270 <i>+ line attributes</i>
272 ## <tt>net</tt> and <tt>pin</tt>
274 attribute |type |default |applies to
275 -----------|------------------|---------------------------------------|-------------------
276 \c x0 |fixed-point number|— |all
277 \c y0 |fixed-point number|— |all
278 \c x1 |fixed-point number|— |all
279 \c y1 |fixed-point number|— |all
280 \c color |color value |\c net, \c bus, or \c pin, respectively|all
281 \c type |net/pin type value|\c normal |all
282 \c inverted|boolean value |\c no |\c pin element only
284 Contains a \c text or \c attribute child element for each attached
289 attribute|type |default
290 ---------|-----------|----------------
291 \c color |color value|<tt>graphic</tt>
293 <i>+ line attributes</i>
294 <i>+ fill attributes</i>
296 Contains the path data as character data.
297 Preserves whitespace.
301 Represents a line break inside a \c path element.
302 This has the same effect as any other whitespace but allows preserving
303 the structure of path data in a <tt>.sym/.sch</tt> file.
304 Does not have any attributes.
308 attribute |type |default
309 -----------|------------------|----------------
310 \c x |fixed-point number|—
311 \c y |fixed-point number|—
312 \c width |fixed-point number|—
313 \c height |fixed-point number|—
314 \c angle |0, 90, 180 or 270 |\c 0
315 \c mirrored|boolean value |\c no
316 \c pixmap |pixmap ID |—
318 ## <tt>text</tt> and <tt>attribute</tt>
320 Text objects which can be interpreted as attributes are represented as
321 \c attribute elements rather than \c text elements.
323 attribute |type |default |applies to
324 ------------|---------------------|----------------|-------------------------
325 \c name |string |— |\c attribute element only
326 \c x |fixed-point number |— |all
327 \c y |fixed-point number |— |all
328 \c color |color value |\c text or \c attribute, respectively|all
329 \c size |integer |— |all
330 \c visible |boolean value |\c yes (\c text element only) |all
331 \c show |show name/value value|\c name-value (\c text element only) |all
332 \c angle |0, 90, 180 or 270 |0 |all
333 \c alignment|alignment value |\c lower-left |all
335 Contains the text or attribute value, respectively, as character data.
339 Represents a line break inside a \c text or \c attribute element.
340 Does not have any attributes.
344 Represents a section of text or attribute value which should be
345 rendered with a line over the letters. (This usually indicates an
346 inverted logic level.)
347 Does not have any attributes.
387 ## Show attribute name/value
391 0|<tt>name-value</tt>
399 0|<tt>lower-left</tt>
400 1|<tt>middle-left</tt>
401 2|<tt>upper-left</tt>
402 3|<tt>lower-middle</tt>
403 4|<tt>middle-middle</tt>
404 5|<tt>upper-middle</tt>
405 6|<tt>lower-right</tt>
406 7|<tt>middle-right</tt>
407 8|<tt>upper-right</tt>
420 0|<tt>background</tt>
422 2|<tt>net-endpoint</tt>
426 6|<tt>logic-bubble</tt>
428 8|<tt>detached-attribute</tt>
432 12|<tt>boundingbox</tt>
436 16|<tt>output-background</tt>
437 17|<tt>freestyle1</tt>
438 18|<tt>freestyle2</tt>
439 19|<tt>freestyle3</tt>
440 20|<tt>freestyle4</tt>
442 --------------------------------------------------------------------------------
444 Copyright (C) 2013-2020 Roland Lutz
446 Permission is granted to copy, distribute and/or modify this document
447 under the terms of the [GNU Free Documentation License, Version 1.2]
448 (http://www.gnu.org/licenses/old-licenses/fdl-1.2.html) or any later
449 version published by the Free Software Foundation; with no Invariant
450 Sections, with no Front-Cover Texts, and with no Back-Cover Texts.