Version | : Candle 0.13 |
Published date | : Jun 13, 2013 |
{
'
and '}
'
may need to be escaped.namespace
ns:default:name:space,
sty=candle:style,
svg='http://www.w3.org/2000/svg';
ns
and separated by token ':'. Candle does not mandate domain names
to be used after the top level name ns
,
but for the names to be globally unique, you should do so. The
top level name ns
stands for namespace
;
it allows us to easily differentiate fully
expanded name from prefixed name. The other namespace form accepted is
the URI syntax. This is for backward compatibility with XML. The top
level name candle
is just a reserved prefix that expands to ns:org:candlescript
.ns
.
qname |
= |
fully-expanded-qname
| prefixed-qname | name; |
fully-expanded-qname |
= |
"ns",
(":", name)*,
":", name; |
prefixed-qname |
= |
prefix,
(":", name)*,
":", name; |
prefix |
= |
name
- ("ns" | "xmlns"); |
<foo bar=nil:baz
svg:d=(M,100,50,L,75,110,Z) sty:fee:foe=123>
ns:org:candlescript:style:
qux
</foo>
nil
namespace. So in the above example, names foo, bar, M, L, Z
are all
under namespace ns:default:name:space
;ns
,
then it is a fully expanded Qname, like the qux
in the above example;nil
and candle
).The baz, d
and foe
in the above example are prefixed names. The name baz
is using predefined prefix nil
.ns:org:candlescript:style:
qux
in Candle is mapped into namespace URI 'ns:org:candlescript:style
'
and local name
qux
in XML. The top level
name ns
can be considered as an unregistered URI scheme
name.ns
:
reserved for fully expanded namespace;nil
:
predefined prefix for the empty namespace;candle
:
predefined prefix for ns:org:candlescript
.<element !*comment*!
attribute=value/>
. This can be useful, for example, to
comment out an attribute.!!
and extends to the end of the line, and the
other is the block comment that starts with !*
and ends
with *!
. And block comments can be nested.literal |
= | empty
| boolean
| integer
| decimal
| double
| float |
measure
| string
| literal-qname
| uri
| color |
|
empty |
:= | ("(",
")") | ("'",
"'") ; |
boolean |
= |
"true"
| "false"; |
integer |
= |
("+"
| "-")?, ("0" | ((digit
- "0"), digit*)),
integer-type-indicator?; |
integer- type-indicator |
= |
"B"
| "UB" | "S" | "US" | "I" | "UI" | "L" | "UL"; |
decimal |
= |
("+"
| "-")?, ( (digits,
".", digit*
) | (".", digits)
); |
double |
= |
"nan" | "infinity" | (decimal , ("e"
| "E"), ("+" | "-")?, digits); |
float |
= |
double,
float-type-indicator; |
float-type-indicator |
= |
"F"; |
string |
= |
"&dq;",
(char-span | entity)*, "&dq;"; |
char-span |
= |
(char
- ("&" | "&dq;"))+; |
entity |
= |
"&",
(name
| ("#", digits)
| ("#x", hex-digits)),
";"; |
uri |
= |
"'",
(char
- "'")*, "'"; |
literal-qname |
= |
qname; |
measure |
= |
(integer
| decimal | double), unit;
|
unit |
= |
"px"
| "pt" | "pc" | "em" | "ex" | "cm" | "mm" | "in"
| |
color |
= |
"#", hex-digits; |
datetime |
= |
"!", (date-time
| date | time |
year-month | year | ,
"!"; !! datetime syntax is
closely based on XML Schema Datatime |
date-time |
= |
|
date |
= |
"-"?,
yyyy, "-", mo, "-", dd, timezone?; |
time |
= |
hh, ":", mm, (":", ss)?, (".", ms)?, timezone?; |
year-month |
= |
yyyy, "-", mo; |
year |
= |
yyyy, ("y" | "Y" | timezone); |
month-day |
= |
"--",
mo, "-", dd, timezone? ; |
month |
= |
"--",
mo , timezone? ; |
day |
= |
"---",
dd , timezone? ; |
timezone |
= |
(("+"
| "-") hh ":" mm) | "Z" | "z"; !!
we allow Z and z |
yyyy |
= |
digit, digit, digit, digit; |
mo |
= |
digit, digit;
!! month range
1~12 |
dd |
= |
digit, digit;
!! day range
1~31 |
hh |
= |
digit, digit;
!! hour range
0~24 |
mm |
= |
digit, digit;
!! minute range
0~59 |
ss |
= |
digit, digit;
!! second range
0~59 |
ms |
= |
digit, digit, digit;
|
binary |
= |
"!", s?, hex-digit*, s?, "!"; |
-12345L
+infinity, -infinity, nan
;10pt,
.8em
50%
!2011-05-13t15:01:00!
!2011-05-13t15:01:00z!
!2012y!
#ff00cc
bold
!12ab 56ef!
B |
- byte, i.e. 8-bit integer; |
UB |
- unsigned byte; |
S |
- short, i.e. 16-bit integer; |
US |
- unsigned short; |
I |
- int, i.e. 32-bit integer; |
UI |
- unsigned int; |
L |
- long, i.e. 64-bit integer; |
UL |
- unsigned long; |
F |
- 32-bit floating point |
"
& '
< >
&tb;
-
horizontal tab, ASCII code 9&lf;
-
line feed or new line character,
ASCII code 10&cr;
-
carriage return, ASCII code 13&dq;
-
double quote, ASCII code 34text |
= |
"&dq;",
( char-span
| entity)*,
"&dq;"; |
cdata |
= |
" <<<
",
( cdata
)*,
">>>
";
!! any char
span excluding ">>>" and not ending with ">" |
comment |
= |
"<!--",
( comment
)*,
"-->"; !! any char span excluding "--" |
data |
= |
literal; |
<element>
"this is a text node" "this is the second span of the same text node"
</element>
<![CDATA[text]]>
in Candle is <<<text>>>
.element |
:= |
start-tag, id-attr?, attribute*, ("/>"
|
(">", element-content, end-tag, ">")); |
start-tag |
= |
"<", qname; |
end-tag |
= |
"</", qname; |
attribute |
:= |
qname,
"=", attribute-value; |
id-attr |
= |
"#"
, name; |
attribute-value |
= |
literal
| literal- sequence
| literal-array | element | object | anonymous-object ; |
literal-sequence |
:= |
"(",
|
literal-array |
:= |
"[",
|
element-content |
:= |
( element
| object
| text
| cdata
| comment
| data)*; |
<path> M
100 50 L 75 110 Z </path>
To avoid syntax ambiguity, anonymous object syntax is
only allowed as attribute value but not allowed as child
node. You have to write the object name when used as child node,
e.g. element { candle:core:object { "..." } }
.(1,
(), 2)
contains 2 items, but array [1, (), 2]
contains 3 items. Array can be useful to pass a list of values as
parameters to a function, where collapsing of empty items are not
desirable. When array is used as attribute value, it cannot contain
nested array.attribute
candle:core:id
, e.g. <element candle:core:id=ident
/>
or object {
candle:core:id=
ident }
.
The value of the attribute should be a qname, and is normally under nil
namespace. <element #ident />
or object
#ident {}
. Its semantics is the same as the full ID attribute.
object |
= |
normal-object
; |
normal-object |
:= |
qname, id-attr?, ("{", attribute*, element-content,
"}") - ( "{",
"}"); |
New Object Notation | Equivalent Element Notation | Similar JavaFX Object Notation |
Customer { |
<Customer |
Customer { |
<path
d="M 100,50 L 75,110 C 123,256 23,278
245,290 Z" />
<path
d=(M, 100,50, L, 75,110, C,
123,256,23,278,245,290, Z)
/>
or as element content<path> M
100 50 L 75 110 C 123 256 23 278 245 290 Z
</path>
(this
element syntax is just for illustration purpose, not actually used in
Candle Style markup)
<div
style="width:56; padding:1 1 2 2;
border-width:1;
border-color:#fff #fff #999 #999;
border-style:solid;" />
<div
style={width=56
padding=(1,1,2,2)
border-width=1
border-color=(c:'fff',c:'fff',c:'999',c:'999')
border-style=solid} />
d
or style
attribute use an
abstract syntax that can only be understood by the SVG or CSS
application,
but not by the general XQuery or XML Schema processors. Whereas in
Candle, the d
and style
attribute use a general syntax and have a well-defined data
model that can be processed by general Candle query and schema
processor.anonymous-object |
:= |
"{", attribute*, element-content,
"}") - ( "{",
"}"; |
candle:core:object
.root |
:= |
markup-signature, namespace-declaration?, element-content ; |
markup -signature |
= |
"<?cmk1.0?>"; |
<?cmk1.0?>
.
Candle
markup documents are normally stored with extension ".cmk
",
but this is not required. The MIME type to be used for Candle Markup
should be 'text/x-candle
'.XML | JSON | YAML | JavaFX Literal Object | Candle | |
Specific Features | |||||
Unicode Support | yes | yes | yes | yes | yes |
Whitespace non-ambiguity | no | yes | yes | yes | yes |
Strongly typed literal values | needs Schema | yes | yes | yes | yes |
Extended literal values (like datetime, uri, qname) |
needs Schema | no | needs type annotation | needs to use object constructor | yes |
Namespace support | yes (but messy) |
no | partial (only the type annotation is namspaced) |
yes (clean hierarchical ns) |
yes (clean hierarchical ns) |
Complex attribute content | no (XML Schema defines a general value list syntax, but is highly ambiguous, and not usable at all) |
yes | yes | yes | yes |
Child node support | yes | no (no direct support) |
no (no direct support) |
no (no direct support) |
yes |
Formal data model | yes (but messy) |
yes | yes | yes | yes |
Schema language | yes (XML Schema is over-complicated; RELAX NG is cleaner, but less used) |
no | no | yes (attribute only, no child content model support) |
yes (similar to RELAX NG) |
Embeddable in programming
languages (as structured nodes not as quoted string) |
yes (.Net, Scala, etc.) |
yes (JavaScript) |
no | yes (JavaFx) |
yes (Candle) |
Advanced processing (path language, query and update language) |
yes (but with overlapping and conflicting features) |
no | no | limited (not as high-level as XPath, XQuery) |
yes (unified query language) |
General Features | |||||
Readability | good for mixed text
content, but verbose for structured data |
good for structured data | good for structured data | good for structured data | good for both (you have object notation; and literal values do not need to be quoted) |
Cross platform | yes | yes | yes | yes | yes |
Open source | yes | yes | yes | promised (but not delivered yet) |
yes |
Lightweight runtime | yes (if you only uses
XML); no (if you starts to use XML Schema, XSLT, XQuery, WS, etc.) |
yes | yes | no | yes (entire runtime is only 2MB when compressed) |
Standards status | W3C standard | RFC standard | no | Oracle only (might become Java standard in future) |
not yet |
Good for structured data | no | yes | yes | yes | yes |
Good for mixed text content | yes | no | no | no | yes |