mirror of
https://github.com/vlang/v.git
synced 2025-09-14 15:02:33 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -5,14 +5,14 @@ import encoding.xml
|
|||
fn test_node() {
|
||||
nodes := [
|
||||
xml.XMLNode{
|
||||
name: 'test'
|
||||
name: 'test'
|
||||
attributes: {
|
||||
'test:key': ' test_value '
|
||||
'test:other': '123456'
|
||||
}
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'child'
|
||||
name: 'child'
|
||||
attributes: {
|
||||
'child:key': 'child_value'
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ fn test_node() {
|
|||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 's'
|
||||
name: 's'
|
||||
attributes: {
|
||||
'k': 'v'
|
||||
}
|
||||
children: [
|
||||
'Hello, world!',
|
||||
xml.XMLNode{
|
||||
name: 'c'
|
||||
name: 'c'
|
||||
attributes: {
|
||||
'k2': 'v2'
|
||||
}
|
||||
|
@ -36,53 +36,53 @@ fn test_node() {
|
|||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'ext'
|
||||
name: 'ext'
|
||||
attributes: {
|
||||
'uri': '{B58B0392-4F1F-4190-BB64-5DF3571DCE5F}'
|
||||
'xmlns:xcalcf': 'http://schemas.microsoft.com/office/spreadsheetml/2018/calcfeatures'
|
||||
}
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:calcFeatures'
|
||||
name: 'xcalcf:calcFeatures'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:feature'
|
||||
name: 'xcalcf:feature'
|
||||
attributes: {
|
||||
'name': 'microsoft.com:RD'
|
||||
}
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:feature'
|
||||
name: 'xcalcf:feature'
|
||||
attributes: {
|
||||
'name': 'microsoft.com:Single'
|
||||
}
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:feature'
|
||||
name: 'xcalcf:feature'
|
||||
attributes: {
|
||||
'name': 'microsoft.com:FV'
|
||||
}
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:feature'
|
||||
name: 'xcalcf:feature'
|
||||
attributes: {
|
||||
'name': 'microsoft.com:CNMTM'
|
||||
}
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:feature'
|
||||
name: 'xcalcf:feature'
|
||||
attributes: {
|
||||
'name': 'microsoft.com:LET_WF'
|
||||
}
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:feature'
|
||||
name: 'xcalcf:feature'
|
||||
attributes: {
|
||||
'name': 'microsoft.com:LAMBDA_WF'
|
||||
}
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'xcalcf:feature'
|
||||
name: 'xcalcf:feature'
|
||||
attributes: {
|
||||
'name': 'microsoft.com:ARRAYTEXT_WF'
|
||||
}
|
||||
|
@ -125,14 +125,14 @@ fn test_doc() {
|
|||
docs := [
|
||||
xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'test'
|
||||
name: 'test'
|
||||
attributes: {
|
||||
'test:key': ' test_value '
|
||||
'test:other': '123456'
|
||||
}
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'child'
|
||||
name: 'child'
|
||||
attributes: {
|
||||
'child:key': 'child_value'
|
||||
}
|
||||
|
@ -143,14 +143,14 @@ fn test_doc() {
|
|||
},
|
||||
xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 's'
|
||||
name: 's'
|
||||
attributes: {
|
||||
'k': 'v'
|
||||
}
|
||||
children: [
|
||||
'Hello, world!',
|
||||
xml.XMLNode{
|
||||
name: 'c'
|
||||
name: 'c'
|
||||
attributes: {
|
||||
'k2': 'v2'
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ fn parse_doctype(mut reader io.Reader) !DocumentType {
|
|||
|
||||
return DocumentType{
|
||||
name: name
|
||||
dtd: DocumentTypeDefinition{
|
||||
dtd: DocumentTypeDefinition{
|
||||
list: items
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ fn parse_prolog(mut reader io.Reader) !(Prolog, u8) {
|
|||
mut comments := []XMLComment{}
|
||||
mut doctype := DocumentType{
|
||||
name: ''
|
||||
dtd: ''
|
||||
dtd: ''
|
||||
}
|
||||
mut found_doctype := false
|
||||
for {
|
||||
|
@ -445,9 +445,9 @@ fn parse_prolog(mut reader io.Reader) !(Prolog, u8) {
|
|||
}
|
||||
|
||||
return Prolog{
|
||||
version: version
|
||||
version: version
|
||||
encoding: encoding
|
||||
doctype: doctype
|
||||
doctype: doctype
|
||||
comments: comments
|
||||
}, ch
|
||||
}
|
||||
|
@ -509,9 +509,9 @@ fn parse_children(name string, attributes map[string]string, mut reader io.Reade
|
|||
children << collected_contents.replace('\r\n', '\n')
|
||||
}
|
||||
return XMLNode{
|
||||
name: name
|
||||
name: name
|
||||
attributes: attributes
|
||||
children: children
|
||||
children: children
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -566,7 +566,7 @@ pub fn parse_single_node(first_char u8, mut reader io.Reader) !XMLNode {
|
|||
if tag_contents.ends_with('/') {
|
||||
// We're not looking for children and inner text
|
||||
return XMLNode{
|
||||
name: name
|
||||
name: name
|
||||
attributes: parse_attributes(tag_contents[name.len..tag_contents.len - 1].trim_space())!
|
||||
}
|
||||
}
|
||||
|
@ -608,10 +608,10 @@ pub fn XMLDocument.from_reader(mut reader io.Reader) !XMLDocument {
|
|||
root := parse_single_node(first_char, mut reader)!
|
||||
|
||||
return XMLDocument{
|
||||
version: prolog.version
|
||||
version: prolog.version
|
||||
encoding: prolog.encoding
|
||||
comments: prolog.comments
|
||||
doctype: prolog.doctype
|
||||
root: root
|
||||
doctype: prolog.doctype
|
||||
root: root
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ const sample_doc = '
|
|||
|
||||
const xml_elements = [
|
||||
XMLNode{
|
||||
name: 'c'
|
||||
name: 'c'
|
||||
attributes: {
|
||||
'id': 'c1'
|
||||
}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'c'
|
||||
name: 'c'
|
||||
attributes: {
|
||||
'id': 'c2'
|
||||
}
|
||||
|
@ -36,47 +36,47 @@ const xml_elements = [
|
|||
]
|
||||
},
|
||||
XMLNode{
|
||||
name: 'empty'
|
||||
name: 'empty'
|
||||
attributes: {}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'c'
|
||||
name: 'c'
|
||||
attributes: {
|
||||
'id': 'c3'
|
||||
}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'abc'
|
||||
name: 'abc'
|
||||
attributes: {
|
||||
'id': 'c4'
|
||||
}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'xyz'
|
||||
name: 'xyz'
|
||||
attributes: {
|
||||
'id': 'c5'
|
||||
}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'c'
|
||||
name: 'c'
|
||||
attributes: {
|
||||
'id': 'c6'
|
||||
}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'cx'
|
||||
name: 'cx'
|
||||
attributes: {
|
||||
'id': 'c7'
|
||||
}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'cd'
|
||||
name: 'cd'
|
||||
attributes: {
|
||||
'id': 'c8'
|
||||
}
|
||||
},
|
||||
XMLNode{
|
||||
name: 'child'
|
||||
name: 'child'
|
||||
attributes: {
|
||||
'id': 'c9'
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ const xml_elements = [
|
|||
]
|
||||
},
|
||||
XMLNode{
|
||||
name: 'cz'
|
||||
name: 'cz'
|
||||
attributes: {
|
||||
'id': 'c10'
|
||||
}
|
||||
|
|
|
@ -31,14 +31,14 @@ fn test_large_gtk_file() ! {
|
|||
for elm in actual.get_elements_by_tag('constructor') {
|
||||
if 'c:identifier' in elm.attributes && elm.attributes['c:identifier'] == 'gtk_window_new' {
|
||||
assert elm == xml.XMLNode{
|
||||
name: 'constructor'
|
||||
name: 'constructor'
|
||||
attributes: {
|
||||
'name': 'new'
|
||||
'c:identifier': 'gtk_window_new'
|
||||
}
|
||||
children: [
|
||||
xml.XMLNodeContents(xml.XMLNode{
|
||||
name: 'doc'
|
||||
name: 'doc'
|
||||
attributes: {
|
||||
'xml:space': 'preserve'
|
||||
}
|
||||
|
@ -58,20 +58,20 @@ To delete a `GtkWindow`, call [method@Gtk.Window.destroy].'),
|
|||
]
|
||||
}),
|
||||
xml.XMLNodeContents(xml.XMLNode{
|
||||
name: 'return-value'
|
||||
name: 'return-value'
|
||||
attributes: {
|
||||
'transfer-ownership': 'none'
|
||||
}
|
||||
children: [
|
||||
xml.XMLNodeContents(xml.XMLNode{
|
||||
name: 'doc'
|
||||
name: 'doc'
|
||||
attributes: {
|
||||
'xml:space': 'preserve'
|
||||
}
|
||||
children: [xml.XMLNodeContents('a new `GtkWindow`.')]
|
||||
}),
|
||||
xml.XMLNodeContents(xml.XMLNode{
|
||||
name: 'type'
|
||||
name: 'type'
|
||||
attributes: {
|
||||
'name': 'Widget'
|
||||
'c:type': 'GtkWidget*'
|
||||
|
|
|
@ -6,10 +6,10 @@ fn test_valid_parsing() ! {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'message'
|
||||
name: 'message'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'greeting'
|
||||
name: 'greeting'
|
||||
children: [
|
||||
'Hello, World!',
|
||||
]
|
||||
|
|
|
@ -6,28 +6,28 @@ fn test_valid_parsing() ! {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'note'
|
||||
name: 'note'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'to'
|
||||
name: 'to'
|
||||
children: [
|
||||
'Tove',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'from'
|
||||
name: 'from'
|
||||
children: [
|
||||
'Jani',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'heading'
|
||||
name: 'heading'
|
||||
children: [
|
||||
'Reminder',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'body'
|
||||
name: 'body'
|
||||
children: [
|
||||
"Don't forget me this weekend!",
|
||||
]
|
||||
|
|
|
@ -6,43 +6,43 @@ fn test_valid_parsing() ! {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'CATALOG'
|
||||
name: 'CATALOG'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'CD'
|
||||
name: 'CD'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'TITLE'
|
||||
name: 'TITLE'
|
||||
children: [
|
||||
'Empire Burlesque',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'ARTIST'
|
||||
name: 'ARTIST'
|
||||
children: [
|
||||
'Bob Dylan',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COUNTRY'
|
||||
name: 'COUNTRY'
|
||||
children: [
|
||||
'USA',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COMPANY'
|
||||
name: 'COMPANY'
|
||||
children: [
|
||||
'Columbia',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'PRICE'
|
||||
name: 'PRICE'
|
||||
children: [
|
||||
'10.90',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'YEAR'
|
||||
name: 'YEAR'
|
||||
children: [
|
||||
'1985',
|
||||
]
|
||||
|
@ -50,40 +50,40 @@ fn test_valid_parsing() ! {
|
|||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'CD'
|
||||
name: 'CD'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'TITLE'
|
||||
name: 'TITLE'
|
||||
children: [
|
||||
'Hide your heart',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'ARTIST'
|
||||
name: 'ARTIST'
|
||||
children: [
|
||||
'Bonnie Tyler',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COUNTRY'
|
||||
name: 'COUNTRY'
|
||||
children: [
|
||||
'UK',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COMPANY'
|
||||
name: 'COMPANY'
|
||||
children: [
|
||||
'CBS Records',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'PRICE'
|
||||
name: 'PRICE'
|
||||
children: [
|
||||
'9.90',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'YEAR'
|
||||
name: 'YEAR'
|
||||
children: [
|
||||
'1988',
|
||||
]
|
||||
|
@ -91,40 +91,40 @@ fn test_valid_parsing() ! {
|
|||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'CD'
|
||||
name: 'CD'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'TITLE'
|
||||
name: 'TITLE'
|
||||
children: [
|
||||
'Greatest Hits',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'ARTIST'
|
||||
name: 'ARTIST'
|
||||
children: [
|
||||
'Dolly Parton',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COUNTRY'
|
||||
name: 'COUNTRY'
|
||||
children: [
|
||||
'USA',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COMPANY'
|
||||
name: 'COMPANY'
|
||||
children: [
|
||||
'RCA',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'PRICE'
|
||||
name: 'PRICE'
|
||||
children: [
|
||||
'9.90',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'YEAR'
|
||||
name: 'YEAR'
|
||||
children: [
|
||||
'1982',
|
||||
]
|
||||
|
@ -132,40 +132,40 @@ fn test_valid_parsing() ! {
|
|||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'CD'
|
||||
name: 'CD'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'TITLE'
|
||||
name: 'TITLE'
|
||||
children: [
|
||||
'Still got the blues',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'ARTIST'
|
||||
name: 'ARTIST'
|
||||
children: [
|
||||
'Gary Moore',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COUNTRY'
|
||||
name: 'COUNTRY'
|
||||
children: [
|
||||
'UK',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'COMPANY'
|
||||
name: 'COMPANY'
|
||||
children: [
|
||||
'Virgin records',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'PRICE'
|
||||
name: 'PRICE'
|
||||
children: [
|
||||
'10.20',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'YEAR'
|
||||
name: 'YEAR'
|
||||
children: [
|
||||
'1990',
|
||||
]
|
||||
|
|
|
@ -6,7 +6,7 @@ fn test_valid_parsing() ! {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'sample'
|
||||
name: 'sample'
|
||||
children: [
|
||||
'Single root element.',
|
||||
]
|
||||
|
|
|
@ -6,16 +6,16 @@ fn test_valid_parsing() ! {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'level1'
|
||||
name: 'level1'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'level2'
|
||||
name: 'level2'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'level3'
|
||||
name: 'level3'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'level4'
|
||||
name: 'level4'
|
||||
children: [
|
||||
'Deeply nested content.',
|
||||
]
|
||||
|
@ -25,10 +25,10 @@ fn test_valid_parsing() ! {
|
|||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'level2'
|
||||
name: 'level2'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'level3'
|
||||
name: 'level3'
|
||||
children: [
|
||||
'Less deeply nested content.',
|
||||
]
|
||||
|
|
|
@ -6,21 +6,21 @@ fn test_valid_parsing() ! {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'letter'
|
||||
name: 'letter'
|
||||
children: [
|
||||
'Dear Mr.',
|
||||
xml.XMLNode{
|
||||
name: 'name'
|
||||
name: 'name'
|
||||
children: ['John Smith']
|
||||
},
|
||||
'.\n Your order',
|
||||
xml.XMLNode{
|
||||
name: 'orderid'
|
||||
name: 'orderid'
|
||||
children: ['1032']
|
||||
},
|
||||
'will be shipped on',
|
||||
xml.XMLNode{
|
||||
name: 'shipdate'
|
||||
name: 'shipdate'
|
||||
children: ['2001-07-13']
|
||||
},
|
||||
'.',
|
||||
|
|
|
@ -11,24 +11,24 @@ fn test_valid_parsing() ! {
|
|||
},
|
||||
]
|
||||
root: xml.XMLNode{
|
||||
name: 'address'
|
||||
name: 'address'
|
||||
children: [
|
||||
xml.XMLComment{
|
||||
text: ' Full or first name '
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'name'
|
||||
name: 'name'
|
||||
children: ['Jones']
|
||||
},
|
||||
xml.XMLComment{
|
||||
text: ' Registered name of the company -> '
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'company'
|
||||
name: 'company'
|
||||
children: ['ABSystems']
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'phone'
|
||||
name: 'phone'
|
||||
children: [xml.XMLComment{
|
||||
text: ' Phone with country code -) '
|
||||
}, '(046) 1233-44778']
|
||||
|
|
|
@ -8,14 +8,14 @@ fn test_valid_parsing() {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'sample'
|
||||
name: 'sample'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'html'
|
||||
name: 'html'
|
||||
children: ['This is <b>bold</b>']
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'html'
|
||||
name: 'html'
|
||||
children: [xml.XMLCData{
|
||||
text: 'This is <b>bold</b>'
|
||||
}]
|
||||
|
|
|
@ -9,55 +9,55 @@ fn test_valid_parsing() {
|
|||
expected := xml.XMLDocument{
|
||||
doctype: xml.DocumentType{
|
||||
name: 'note'
|
||||
dtd: xml.DocumentTypeDefinition{
|
||||
dtd: xml.DocumentTypeDefinition{
|
||||
name: ''
|
||||
list: [
|
||||
xml.DTDElement{
|
||||
name: 'note'
|
||||
name: 'note'
|
||||
definition: ['to', 'from', 'heading', 'body']
|
||||
},
|
||||
xml.DTDElement{
|
||||
name: 'to'
|
||||
name: 'to'
|
||||
definition: ['#PCDATA']
|
||||
},
|
||||
xml.DTDElement{
|
||||
name: 'from'
|
||||
name: 'from'
|
||||
definition: ['#PCDATA']
|
||||
},
|
||||
xml.DTDElement{
|
||||
name: 'heading'
|
||||
name: 'heading'
|
||||
definition: ['#PCDATA']
|
||||
},
|
||||
xml.DTDElement{
|
||||
name: 'body'
|
||||
name: 'body'
|
||||
definition: ['#PCDATA']
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
root: xml.XMLNode{
|
||||
name: 'note'
|
||||
name: 'note'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'to'
|
||||
name: 'to'
|
||||
children: [
|
||||
'Tove',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'from'
|
||||
name: 'from'
|
||||
children: [
|
||||
'Jani',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'heading'
|
||||
name: 'heading'
|
||||
children: [
|
||||
'Reminder',
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'body'
|
||||
name: 'body'
|
||||
children: [
|
||||
"Don't forget me this weekend!",
|
||||
]
|
||||
|
|
|
@ -8,13 +8,13 @@ fn test_valid_parsing() {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'book'
|
||||
name: 'book'
|
||||
attributes: {
|
||||
'category': 'web'
|
||||
}
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'title'
|
||||
name: 'title'
|
||||
attributes: {
|
||||
'lang': 'en'
|
||||
'code:type': 'const char*'
|
||||
|
@ -22,18 +22,18 @@ fn test_valid_parsing() {
|
|||
children: ['Learning XML']
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'author'
|
||||
name: 'author'
|
||||
attributes: {
|
||||
'attr': ' surrounding spaces '
|
||||
}
|
||||
children: ['Erik T. Ray']
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'year'
|
||||
name: 'year'
|
||||
children: ['2003']
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'price'
|
||||
name: 'price'
|
||||
children: ['39.95']
|
||||
},
|
||||
]
|
||||
|
|
|
@ -8,17 +8,17 @@ fn test_valid_parsing() {
|
|||
|
||||
expected := xml.XMLDocument{
|
||||
root: xml.XMLNode{
|
||||
name: 'sst'
|
||||
name: 'sst'
|
||||
attributes: {
|
||||
'count': '5'
|
||||
'uniqueCount': '5'
|
||||
}
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 'si'
|
||||
name: 'si'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 't'
|
||||
name: 't'
|
||||
attributes: {
|
||||
'a': '1'
|
||||
}
|
||||
|
@ -27,37 +27,37 @@ fn test_valid_parsing() {
|
|||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'si'
|
||||
name: 'si'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 't'
|
||||
name: 't'
|
||||
children: ['Item 2']
|
||||
},
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'si'
|
||||
name: 'si'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 't'
|
||||
name: 't'
|
||||
children: ['Item 3']
|
||||
},
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'si'
|
||||
name: 'si'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 't'
|
||||
name: 't'
|
||||
children: ['Item 4']
|
||||
},
|
||||
]
|
||||
},
|
||||
xml.XMLNode{
|
||||
name: 'si'
|
||||
name: 'si'
|
||||
children: [
|
||||
xml.XMLNode{
|
||||
name: 't'
|
||||
name: 't'
|
||||
children: ['Item 5']
|
||||
},
|
||||
]
|
||||
|
|
|
@ -69,7 +69,7 @@ pub:
|
|||
encoding string = 'UTF-8'
|
||||
doctype DocumentType = DocumentType{
|
||||
name: ''
|
||||
dtd: ''
|
||||
dtd: ''
|
||||
}
|
||||
comments []XMLComment
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ fn (node XMLNode) validate(elements map[string]DTDElement, entities map[string]s
|
|||
}
|
||||
|
||||
return XMLNode{
|
||||
name: node.name
|
||||
name: node.name
|
||||
attributes: node.attributes
|
||||
children: children
|
||||
children: children
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,11 +80,11 @@ pub fn (doc XMLDocument) validate() !XMLDocument {
|
|||
}
|
||||
|
||||
return XMLDocument{
|
||||
version: doc.version
|
||||
encoding: doc.encoding
|
||||
doctype: doc.doctype
|
||||
comments: doc.comments
|
||||
root: new_root
|
||||
version: doc.version
|
||||
encoding: doc.encoding
|
||||
doctype: doc.doctype
|
||||
comments: doc.comments
|
||||
root: new_root
|
||||
parsed_reverse_entities: reverse_entities
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue