Skip to content
Browse files

updated to pub format and naming conventions.

  • Loading branch information...
1 parent 2f023e4 commit 226af35ac4bec1d273f643262ba9027cd18c20f7 @prujohn committed Aug 31, 2012
View
2 .children
@@ -1,2 +0,0 @@
-tests/xmltests.dart
-lib/xml.dart
View
17 .project
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>xml</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.google.dart.tools.core.dartBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.google.dart.tools.core.dartNature</nature>
- </natures>
-</projectDescription>
View
1 LICENSE.txt → LICENSE
@@ -1,6 +1,5 @@
Copyright (c) 2012, John Evans
-http://www.lucastudios.com/contact
John: https://plus.google.com/u/0/115427174005651655317/about
Licensed under the Apache License, Version 2.0 (the "License");
View
32 lib/XmlAttribute.dart
@@ -1,32 +0,0 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
-* Represents an attribute component of an XML element.
-*/
-class XmlAttribute extends XmlNode
-{
- final String name;
- final String value;
-
- XmlAttribute(this.name, this.value)
- :
- super(XmlNodeType.Attribute);
-
- String toString() =>
- value.contains('"') ? " $name='$value'" : ' $name="$value"';
-}
View
30 lib/XmlCDATA.dart
@@ -1,30 +0,0 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
-* Represents a CDATA node of an XML tree.
-*/
-class XmlCDATA extends XmlNode
-{
- final String text;
-
- XmlCDATA(this.text)
- :
- super(XmlNodeType.CDATA);
-
- String toString() =>'<![CDATA[\r$text\r]]>';
-}
View
47 lib/XmlException.dart
@@ -1,47 +0,0 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-class XmlException implements Exception
-{
- final String msg;
- final String debugXml;
- final int errorLocation;
-
- const XmlException(this.msg)
- :
- debugXml = '',
- errorLocation = 0;
-
- const XmlException.withDebug(this.msg, this.debugXml, this.errorLocation);
-
- String toString() {
- if (debugXml == '') return 'Xml Exception: $msg';
-
- StringBuffer s = new StringBuffer();
- s.add('Xml Exception: $msg');
- s.add('\r');
-
- int bLoc = (errorLocation < 41) ? 0 : errorLocation - 40;
- int aLoc = (errorLocation > debugXml.length - 41)
- ? debugXml.length - 1
- : errorLocation + 40;
-
- s.add(debugXml.substring(bLoc, aLoc));
- return s.toString();
-
- }
-}
View
29 lib/XmlNamespace.dart
@@ -1,29 +0,0 @@
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
-* Represents an namespace declaration of an XML element.
-*/
-class XmlNamespace extends XmlNode
-{
- final String name;
- final String uri;
-
- XmlNamespace(this.name, this.uri)
- :
- super(XmlNodeType.Namespace);
-
- String toString() =>
- uri.contains('"') ? " xmlns:$name='$uri'" : ' xmlns:$name="$uri"';
-}
View
34 lib/XmlNodeType.dart
@@ -1,34 +0,0 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
-* Enumerates [XmlNode] types.
-*/
-class XmlNodeType{
- final String _type;
-
- const XmlNodeType(this._type);
-
- static final Element = const XmlNodeType('Element');
- static final Attribute = const XmlNodeType('Attribute');
- static final Text = const XmlNodeType('Text');
- static final Namespace = const XmlNodeType('Namespace');
- static final CDATA = const XmlNodeType('CDATA');
- static final PI = const XmlNodeType('PI'); //Processing Instruction
-
- String toString() => _type;
-}
View
27 lib/XmlProcessingInstruction.dart
@@ -1,27 +0,0 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/** Represents and XML Processing Instruction (PI) node. */
-class XmlProcessingInstruction extends XmlNode {
- final String text;
-
- XmlProcessingInstruction(this.text)
- :
- super(XmlNodeType.PI);
-
- String toString() => '<?\r$text\r?>';
-}
View
30 lib/XmlText.dart
@@ -1,30 +0,0 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
-* Represents a text node component of XML.
-*/
-class XmlText extends XmlNode
-{
- final String text;
-
- XmlText(this.text)
- :
- super(XmlNodeType.Text);
-
- String toString() => text;
-}
View
15 lib/attribute.dart
@@ -0,0 +1,15 @@
+/**
+* Represents an attribute component of an XML element.
+*/
+class XmlAttribute extends XmlNode
+{
+ final String name;
+ final String value;
+
+ XmlAttribute(this.name, this.value)
+ :
+ super(XmlNodeType.Attribute);
+
+ String toString() =>
+ value.contains('"') ? " $name='$value'" : ' $name="$value"';
+}
View
13 lib/cdata.dart
@@ -0,0 +1,13 @@
+/**
+* Represents a CDATA node of an XML tree.
+*/
+class XmlCDATA extends XmlNode
+{
+ final String text;
+
+ XmlCDATA(this.text)
+ :
+ super(XmlNodeType.CDATA);
+
+ String toString() =>'<![CDATA[\r$text\r]]>';
+}
View
17 lib/XmlCollection.dart → lib/collection.dart
@@ -1,20 +1,3 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
/**
* Represents a queryable collection of [XmlNode] elements.
*/
View
18 lib/XmlElement.dart → lib/element.dart
@@ -1,21 +1,3 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
/**
* Represents an element node of XML.
*/
View
30 lib/exception.dart
@@ -0,0 +1,30 @@
+class XmlException implements Exception
+{
+ final String msg;
+ final String debugXml;
+ final int errorLocation;
+
+ const XmlException(this.msg)
+ :
+ debugXml = '',
+ errorLocation = 0;
+
+ const XmlException.withDebug(this.msg, this.debugXml, this.errorLocation);
+
+ String toString() {
+ if (debugXml == '') return 'Xml Exception: $msg';
+
+ StringBuffer s = new StringBuffer();
+ s.add('Xml Exception: $msg');
+ s.add('\r');
+
+ int bLoc = (errorLocation < 41) ? 0 : errorLocation - 40;
+ int aLoc = (errorLocation > debugXml.length - 41)
+ ? debugXml.length - 1
+ : errorLocation + 40;
+
+ s.add(debugXml.substring(bLoc, aLoc));
+ return s.toString();
+
+ }
+}
View
15 lib/namespace.dart
@@ -0,0 +1,15 @@
+/**
+* Represents an namespace declaration of an XML element.
+*/
+class XmlNamespace extends XmlNode
+{
+ final String name;
+ final String uri;
+
+ XmlNamespace(this.name, this.uri)
+ :
+ super(XmlNodeType.Namespace);
+
+ String toString() =>
+ uri.contains('"') ? " xmlns:$name='$uri'" : ' xmlns:$name="$uri"';
+}
View
18 lib/XmlNode.dart → lib/node.dart
@@ -1,21 +1,3 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
/**
* Represents a base class for XML nodes. This node is essentially
* read-only. Use [XmlElement] for manipulating attributes
View
17 lib/node_type.dart
@@ -0,0 +1,17 @@
+/**
+* Enumerates [XmlNode] types.
+*/
+class XmlNodeType{
+ final String _type;
+
+ const XmlNodeType(this._type);
+
+ static final Element = const XmlNodeType('Element');
+ static final Attribute = const XmlNodeType('Attribute');
+ static final Text = const XmlNodeType('Text');
+ static final Namespace = const XmlNodeType('Namespace');
+ static final CDATA = const XmlNodeType('CDATA');
+ static final PI = const XmlNodeType('PI'); //Processing Instruction
+
+ String toString() => _type;
+}
View
17 lib/XmlParser.dart → lib/parser.dart
@@ -1,20 +1,3 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
/**
* ## XML Parser ##
*
View
10 lib/processing_instruction.dart
@@ -0,0 +1,10 @@
+/** Represents and XML Processing Instruction (PI) node. */
+class XmlProcessingInstruction extends XmlNode {
+ final String text;
+
+ XmlProcessingInstruction(this.text)
+ :
+ super(XmlNodeType.PI);
+
+ String toString() => '<?\r$text\r?>';
+}
View
13 lib/text.dart
@@ -0,0 +1,13 @@
+/**
+* Represents a text node component of XML.
+*/
+class XmlText extends XmlNode
+{
+ final String text;
+
+ XmlText(this.text)
+ :
+ super(XmlNodeType.Text);
+
+ String toString() => text;
+}
View
17 lib/XmlTokenizer.dart → lib/tokenizer.dart
@@ -1,20 +1,3 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
/**
* Returns tokenized parts of Xml document.
*/
View
60 lib/xml.dart
@@ -1,60 +0,0 @@
-// Copyright (c) 2012, John Evans
-//
-// http://www.lucastudios.com/contact
-// John: https://plus.google.com/u/0/115427174005651655317/about
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-// A lightweight, XML parser and emitter.
-// See README.md for more info on features and limitations.
-
-#library('Xml');
-#source('XmlElement.dart');
-#source('XmlParser.dart');
-#source('XmlTokenizer.dart');
-#source('XmlNode.dart');
-#source('XmlNodeType.dart');
-#source('XmlText.dart');
-#source('XmlAttribute.dart');
-#source('XmlException.dart');
-#source('XmlCDATA.dart');
-#source('XmlProcessingInstruction.dart');
-#source('XmlCollection.dart');
-#source('XmlNamespace.dart');
-
-/**
-* Utility class to work with XML data.
-*/
-class XML
-{
-
- /**
- * Returns a [XmlElement] tree representing the raw XML fragment [String].
- *
- * Optional parameter [withQuirks] will allow the following when set to true:
- *
- * * Optional quotes for simple attribute values (no spaces).
- */
- static XmlElement parse(String xml, [withQuirks = false]) =>
- XmlParser._parse(xml.trim(), withQuirks);
-
- /**
- * Returns a stringified version of an [XmlElement] tree.
- * You can also call .toString() on any [XmlElement].
- */
- static String stringify(XmlElement element) => element.toString();
-
-}
-
-
View
6 pubspec.yaml
@@ -0,0 +1,6 @@
+name: dart_xml
+description: A lightweight XML Parser.
+version: 0.0.1
+dependencies:
+ unittest:
+ sdk: unittest
View
6 tests/xmltests.dart
@@ -1,8 +1,8 @@
// point this to wherever your copy of the dart source code is
-#import('../../../src/lib/unittest/unittest.dart');
-#import('../../../src/lib/unittest/html_enhanced_config.dart');
+#import('package:unittest/unittest.dart');
+#import('package:unittest/html_enhanced_config.dart');
-#import('../lib/xml.dart');
+#import('../xml.dart');
#source('parserTests.dart');
#source('queryTests.dart');
View
42 xml.dart
@@ -0,0 +1,42 @@
+// A lightweight, XML parser and emitter.
+// See README.md for more info on features and limitations.
+
+#library('xml_utils_prujohn');
+#source('lib/element.dart');
+#source('lib/parser.dart');
+#source('lib/tokenizer.dart');
+#source('lib/node.dart');
+#source('lib/node_type.dart');
+#source('lib/text.dart');
+#source('lib/attribute.dart');
+#source('lib/exception.dart');
+#source('lib/cdata.dart');
+#source('lib/processing_instruction.dart');
+#source('lib/collection.dart');
+#source('lib/namespace.dart');
+
+/**
+* Utility class to work with XML data.
+*/
+class XML
+{
+
+ /**
+ * Returns a [XmlElement] tree representing the raw XML fragment [String].
+ *
+ * Optional parameter [withQuirks] will allow the following when set to true:
+ *
+ * * Optional quotes for simple attribute values (no spaces).
+ */
+ static XmlElement parse(String xml, [withQuirks = false]) =>
+ XmlParser._parse(xml.trim(), withQuirks);
+
+ /**
+ * Returns a stringified version of an [XmlElement] tree.
+ * You can also call .toString() on any [XmlElement].
+ */
+ static String stringify(XmlElement element) => element.toString();
+
+}
+
+

0 comments on commit 226af35

Please sign in to comment.
Something went wrong with that request. Please try again.