Merge pull request #3504 from Matt14916/xmlparser-entities
Create entity nodes with xmlparser, add a test to xmlparser
This commit is contained in:
commit
60e5a2b2f5
2 changed files with 19 additions and 11 deletions
|
|
@ -96,7 +96,7 @@ proc parse(x: var XmlParser, errors: var seq[string]): XmlNode =
|
|||
next(x)
|
||||
of xmlEntity:
|
||||
## &entity;
|
||||
errors.add(errorMsg(x, "unknown entity: " & x.entityName))
|
||||
result = newEntity(x.entityName)
|
||||
next(x)
|
||||
of xmlEof: discard
|
||||
|
||||
|
|
@ -143,7 +143,8 @@ proc loadXml*(path: string): XmlNode =
|
|||
result = loadXml(path, errors)
|
||||
if errors.len > 0: raiseInvalidXml(errors)
|
||||
|
||||
when not defined(testing) and isMainModule:
|
||||
when isMainModule:
|
||||
when not defined(testing):
|
||||
import os
|
||||
|
||||
var errors: seq[string] = @[]
|
||||
|
|
@ -156,4 +157,10 @@ when not defined(testing) and isMainModule:
|
|||
f.close()
|
||||
else:
|
||||
quit("cannot write test.txt")
|
||||
else:
|
||||
block: # correctly parse ../../tests/testdata/doc1.xml
|
||||
let filePath = "tests/testdata/doc1.xml"
|
||||
var errors: seq[string] = @[]
|
||||
var xml = loadXml(filePath, errors)
|
||||
assert(errors.len == 0, "The file tests/testdata/doc1.xml should be parsed without errors.")
|
||||
|
||||
|
|
|
|||
1
tests/testdata/doc1.xml
vendored
1
tests/testdata/doc1.xml
vendored
|
|
@ -5,6 +5,7 @@
|
|||
<test2>
|
||||
bla ah absy hsh
|
||||
hsh
|
||||
&woohoo;
|
||||
sjj
|
||||
</test2>
|
||||
<test><teh>bla</teh></test>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue