-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* correctly set a ROOT node as the first node of the dom object. set the DECL node as the first child node of ROOT. fix indent in dom:toXml(). * fix detection of an empty ELEMENT node. * XmlParser: fix parsing of a DTD element. dom handler: fix handling a DTD element. * Fix dom.lua docs * Rename people.xml to people1.xml Moves complex tags (DOCTYPE and CDATA) to people2.xml to make people1 a basic XML. * Restructure example5.lua to parse the XML files whose names are defined by an array inside the example, instead of receiving them in the STDIN. This way, the entry to run this example inside the Makefile were removed. Running a specific example inside the Makefile is too specific. If that was for test purposes, they should be inside the test files. --------- Signed-off-by: Manoel Campos <[email protected]> Co-authored-by: Sudheer Hebbale <[email protected]> Co-authored-by: Manoel Campos <[email protected]>
- Loading branch information
1 parent
f6cf04b
commit 7e36b2e
Showing
10 changed files
with
204 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env lua | ||
-- Read XML documents containing DOCTYPE and CDATA tags, | ||
-- parse with the dom parser, | ||
-- print the XML documents to STDOUT. | ||
local xml2lua = require("xml2lua") | ||
local xmlhandler = require("xmlhandler.dom") | ||
|
||
local files = {"books.xml", "people2.xml"} | ||
for _, file in ipairs(files) do | ||
print(file, "-----------------------------------------------------------") | ||
local xml = xml2lua.loadFile(file) | ||
local dom = xmlhandler:new() | ||
local parser = xml2lua.parser(dom) | ||
parser:parse(xml) | ||
if not dom.root then | ||
print("parsing ", file , " as XML failed") | ||
else | ||
print(dom:toXml(dom.root)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<people> | ||
<person type="natural"> | ||
<!-- Just an example comment that will be ignored by the tree | ||
handler and processed by the other ones. --> | ||
|
||
<name>Manoel</name> | ||
<city>Palmas-TO</city> | ||
</person> | ||
<person type="natural"> | ||
<name>Breno</name> | ||
<city>Palmas-TO</city> | ||
</person> | ||
<person type="legal"> | ||
<name>University of Brasília</name> | ||
<city>Brasília-DF</city> | ||
<empty></empty> | ||
<void/> | ||
</person> | ||
</people> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters