You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/AcuteML.jl
+34-3Lines changed: 34 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,14 @@ export Node, Document
24
24
@aml
25
25
26
26
# Type Definition
27
-
Use `@aml` macro to define a Julia type, and then the package automatically creates a xml or html associated with the defined type.
27
+
Use `@aml` macro to define a Julia type, and then the package automatically creates a xml or html associated with the defined type. The general syntax would look like this:
28
+
```julia
29
+
@aml mutable struct mybody "body"
30
+
myh1, "h1"
31
+
p::Vector{String}, "~"
32
+
end
33
+
```
34
+
Now, we go into the details:
28
35
29
36
### Document Definition
30
37
* Use doc literal before the root name to define a HTML or XML document. For HTML documents root should always be "html".
@@ -40,7 +47,7 @@ end
40
47
```
41
48
42
49
### Nodes (Elements) Definition
43
-
* Specify the html/xml struct name as a string after the struct name after a space
50
+
* Specify the html/xml name of struct as a string after the struct name (after a space)
44
51
```julia
45
52
@aml mutable struct Person "person"
46
53
# add fields (elements) here
@@ -63,6 +70,29 @@ field, "study-field"
63
70
age::UInt, "~"
64
71
```
65
72
73
+
!!! warning
74
+
The field names of a struct should not be the same as other defined types. This error happens when you use the same name of a type for a field name. For example, the follwing is an **error**:
75
+
```julia
76
+
@aml struct person "~"
77
+
name, "~"
78
+
end
79
+
@aml struct myxml doc"~"
80
+
person::person, "~"
81
+
end
82
+
```
83
+
Another example of this error:
84
+
```julia
85
+
@aml struct myxml doc"~"
86
+
Int, "myint"
87
+
end
88
+
```
89
+
However, you can choose any xml/html name. The xml/html name of the fields isn't related to the types defined in Julia. So the following is a **valid** syntax:
90
+
```julia
91
+
@aml struct myxml doc"~"
92
+
myint, "Int"
93
+
end
94
+
```
95
+
66
96
### Attributes
67
97
* If the value is going to be an attribute put `att` before its name
0 commit comments