Skip to content

Commit

Permalink
[Xml] A few small cleanups. Add a test for ELEMENT tags with multiple…
Browse files Browse the repository at this point in the history
… comma-separated child types
  • Loading branch information
Whiteknight committed Apr 28, 2012
1 parent 628e09c commit ff8f286
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
31 changes: 6 additions & 25 deletions src/unstable/xml/Tag.winxed
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,11 @@ class Rosella.Xml.Tag.XmlHeader : Rosella.Xml.Tag
push(sb, "?>");
}

function add_child(var child)
{
Rosella.Error.error("XML Header tags do not have child tags");
}
function add_child(var child) { Rosella.Error.error("XML Header tags do not have child tags"); }

function add_child_text(string text)
{
Rosella.Error.error("XML Header tags may not contain raw text");
}
function add_child_text(string text) { Rosella.Error.error("XML Header tags may not contain raw text"); }

function set_end(var end_tag)
{
Rosella.Error.error("XML Header tags do not have closing tags");
}
function set_end(var end_tag) { Rosella.Error.error("XML Header tags do not have closing tags"); }
}


Expand Down Expand Up @@ -231,20 +222,11 @@ class Rosella.Xml.Tag.DtdHeader : Rosella.Xml.Tag
push(sb, ">");
}

function add_child(var child)
{
Rosella.Error.error("Inline DTD do not contain children");
}
function add_child(var child) { Rosella.Error.error("Inline DTD do not contain children"); }

function add_child_text(string text)
{
Rosella.Error.error("DTD Header tags may not contain raw text");
}
function add_child_text(string text) { Rosella.Error.error("DTD Header tags may not contain raw text"); }

function set_end(var end_tag)
{
Rosella.Error.error("DTD Header tags do not have closing tags");
}
function set_end(var end_tag) { Rosella.Error.error("DTD Header tags do not have closing tags"); }
}

class Rosella.Xml.Tag.DtdElement
Expand Down Expand Up @@ -379,7 +361,6 @@ class Rosella.Xml.Tag.DtdAttlist
}
}
}
// TODO: The rest of it
push(sb, ">");
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/unstable/xml/Text.winxed
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
/* XML Text Node
This type represents raw CDATA text in an XML document
*/
class Rosella.Xml.Text
{
var text;
function Text(string text)
{
self.text = text;
}

// Constructor
function Text(string text) { self.text = text; }

// Get the raw text string
function get_text() { return self.text; }

// Convert this node to XML
function to_xml()
{
var sb = new 'StringBuilder';
self.to_xml_sb(sb, 0);
return sb;
}

// Convert this node to XML, into the given StringBuilder
function to_xml_sb(var sb, int indent)
{
string indent_str = indent_level(indent);
Expand Down
10 changes: 10 additions & 0 deletions t/xml/Parsing.t
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ function __test_data() { return {
<bar/>
</foo>
:>>
,
"!ELEMENT with multiple children" : <<:
<?xml version='1.0'?>
<!DOCTYPE foo [
<!ELEMENT foo (#CDATA, bar, baz)>
<!ELEMENT bar (#CDATA)>
<!ELEMENT baz (#CDATA)>
]>
<foo><bar/><baz/></foo>
:>>
,
"!ATTLIST with #REQUIRED" : <<:
<?xml version='1.0'?>
Expand Down

0 comments on commit ff8f286

Please sign in to comment.