The current repository is:
netvl / xml-rs Goto Github PK
View Code? Open in Web Editor NEWAn XML library in Rust
License: MIT License
An XML library in Rust
License: MIT License
The current repository is:
Getting warnings like these:
src/common.rs:222:11: 222:16 warning: \U00ABCD12 and \uABCD escapes are deprecated
src/common.rs:222 '\u00C0'...'\u00D6' | '\u00D8'...'\u00F6' | '\u00F8'...'\u02FF' |
^~~~~
src/common.rs:222:11: 222:16 help: use \u{ABCD12} escapes instead
src/common.rs:222 '\u00C0'...'\u00D6' | '\u00D8'...'\u00F6' | '\u00F8'...'\u02FF' |
^~~~~
After updating to 0.2 parsing this file fails with an error:
Unexpected token '--' before ' ' in gir-files/GLib-2.0.gir:165:8
The problematic piece:
<alias name="Time" c:type="GTime">
<doc xml:space="preserve">Simply a replacement for time_t. It has been deprecated
since it is not equivalent to time_t on 64-bit platforms
with a 64-bit time_t. Unrelated to #GTimer.
Note that #GTime is defined to always be a 32-bit integer,
unlike time_t which may be 64-bit on some systems. Therefore,
#GTime will overflow in the year 2038, and you cannot use the
address of a #GTime variable as argument to the UNIX time()
function.
Instead, do the following:
|[<!-- language="C" -->
time_t ttime;
GTime gtime;
time (&ttime);
gtime = (GTime)ttime;
]|</doc>
<type name="gint32" c:type="gint32"/>
</alias>
xml-rs is accepting documents with multiple root nodes while the XML specifications says that a document must have a unique root.
For instance, the following program
extern crate xml;
use xml::reader::{EventReader, XmlEvent};
fn main() {
for e in EventReader::new(&b"<a/><a/>"[..]) {
match e {
Ok(XmlEvent::StartElement { name, .. }) => {
println!("start: {}", name);
}
Err(e) => {
println!("error: {}", e);
break;
}
_ => {}
}
}
}
will print
start: a
start: a
instead of an error.
The issue exists both in 0.3
and master
.
This is needed to update gl-rs.
C:\msys64\home\Alex.cargo\registry\src\github.com-1ecc6299db9ec823\xml-rs-0.1.13\src\common.rs:67:5: 67:71 error: method detail
is not a member of trait error::Error
C:\msys64\home\Alex.cargo\registry\src\github.com-1ecc6299db9ec823\xml-rs-0.1.13\src\common.rs:67 fn detail(&self) -> Option { Some(format!("{:?}", self)) }
My machine on Windows 8 64
Currently the parser occupies a single module file. It is really inconvenient since it is has more than thousand lines of code and hence is very unwieldy for navigation and modification. It was written before I knew how to split large implementations across different modules. This has to be refactored.
Basically, I want to split parser implementation into several submodules, each responsible for different part of XML grammar. Each module should provide a method or a couple of methods to parse the corresponding grammar part, and these methods should then be called from the parent module - essentially the same thing I did in md.rs.
This has to be done ASAP as this prevents easy modifications in the parser.
Hi, I noticed this library is also yours, was it the predecessor to xml-rs? Can you somehow mark it obsolete, or delete it and leave only xml-rs?
It seems that there are problems with bitflags package compatibility with Rust versions, which causes various issues in downstream crates. xml-rs uses bitflags in a very limited way internally, so it should not be hard to drop the dependency on it altogether and just use custom bit flags.
gl_generator needs a fresh version :)
Right now the library doesn't error when an attribute occurs twice per element.
<el name="a" name="b"></el>
should trigger an error.
I need to finish the XML writer and add proper namespaces support to it. It currently does work, but only in basic cases. Also its configuration is mostly unused.
The writer should consume slice-based objects, and the reader must return owned objects.
Ideally I would like to base it on the existing Cow
infrastructure which looks like a natural choice for this, but it is really tied to unsized types, and I don't see any way to use it for complex structures like Name
which represents namespaced XML names with various components.
When a document is received in chunks (on XMPP for example), it makes sense to initialize the parser on the first chunk, and then feed it data as it comes.
xml::ParserConfig
would get a new streaming
boolean that would make it never emit xml::XmlEvent::EndDocument
before the root tag is closed, a feed
method to xml::EventReader
, taking a string and emitting newer xml::XmlEvent
s as they are parsed, and finally add a method to abort the stream.
It's not currently implemented for OwnedAttribute, but it is implemented for Attribute. That seems inconsistent?
When an element defines another namespace for the same prefix, for example <a xmlns="a"><b xmlns="b"/></a>
, the inner element gets its xmlns
“attribute” skipped, leading to a wrong document.
Here is a minimal example reproducing this issue: http://linkmauve.fr/files/xml.rs
I tried using perform_indent
when writing a document, but the outputted document is not indented. Seems like that config is never read in the xml-rs code from a quick code search.
Hi!
I have tried to build small 'helloworld' code with gl-rs dependency (https://github.com/bjz/gl-rs) and get error:
Compiling rust-xml v0.1.0 (https://github.com/netvl/rust-xml#d6c57380)
src\namespace.rs:67:36: 67:45 error: type bool
does not implement any method in scope named is_none
src\namespace.rs:67 self.0.insert(prefix, uri).is_none()
error: aborting due to previous error
Could not compile rust-xml
.
I am using Rust version 0.13.0-nightly (0a5e7f359 2014-11-03 23:16:55 +0000) on Windows 8.1
$ cargo build
Compiling rust-xml v0.1.0 (...)
src/writer/emitter.rs:28:54: 28:63 error: type `core::option::Option<std::io::IoError>` does not implement any method in scope named `get_ref`
src/writer/emitter.rs:28 write!(f, "; caused by: {}", *self.cause.get_ref())
^~~~~~~~~
error: aborting due to previous error
Could not compile `rust-xml`.
To learn more, run the command again with --verbose.
$ cargo --version
cargo 0.0.1-pre-nightly (481a433 2014-10-20 05:14:53 +0000)
$ rustc --version
rustc 0.13.0-nightly (6ef8392b3 2014-10-20 22:17:49 +0000)
It looks like get_ref was removed yesterday.
It seems like the library doesn't remove XML-indentation.
<description summary="core global object">
The core global object. This is a special singleton object. It
is used for internal Wayland protocol features.
</description>
The characters event here seems to have the indentation in it. Is there a way to automatically have it be removed?
I get the following error messages when I read a DOS-UTF8 XML file in a Rust program that uses rust-xml, on Windows 7:
Running `target\rust-xml-w`
Error: 1:2: Unexpected characters outside the root element:
If I convert the XML file to ANSI LATIN 1, the issue disappears.
My version of rustc is
rustc 0.12.0-pre-nightly (0bdac78da 2014-09-01 21:31:00 +0000)
#27 breaks the build for mac, I get:
error: enum struct variants are experimental and possibly buggy.
It's nice when structs implement Debug
- it would be awesome if namespace implemented Debug
.
Hello,
because when you have a fixed version of a lib, it's easier to have the possibilities to check the sources on the repository. Adding the tag of version give this possibilities.
Can you do it?
thanks
#![feature(plugin)]
#![plugin(afl_coverage_plugin)]
extern crate afl_coverage;
extern crate xml;
use std::io::{self, Read};
fn main() {
let mut input = String::new();
let result = io::stdin().read_to_string(&mut input);
if result.is_ok() {
let mut reader = xml::reader::EventReader::from_str(&input);
let _: Vec<_> = reader.events().collect();
}
}
&𤶼;
or as base64:
JvCktrw7
root@afl-rust:~/afl-staging-area# cargo run --verbose < new-file
Fresh gcc v0.3.5
Fresh bitflags v0.1.1
Fresh afl-coverage-plugin v0.0.1 (https://github.com/kmcallister/afl.rs#845bdff0)
Fresh afl-coverage v0.0.1 (https://github.com/kmcallister/afl.rs#845bdff0)
Fresh xml-rs v0.1.24 (file:///root/afl-staging-area)
Fresh afl-staging-area v0.1.0 (file:///root/afl-staging-area)
Running `target/debug/afl-staging-area`
thread '<main>' panicked at 'index 0 and/or 2 in `𤶼` do not lie on character boundary', /root/rust/src/libcore/str/mod.rs:1528
stack backtrace:
1: 0x7f003c964039 - sys::backtrace::write::hb34cb0734f7a3c97uhs
2: 0x7f003c9674f1 - panicking::on_panic::h82f65b9161b1f8deGXw
3: 0x7f003c960c62 - rt::unwind::begin_unwind_inner::h9f6dd38aeb9ea42dQCw
4: 0x7f003c961247 - rt::unwind::begin_unwind_fmt::h44a1d6134651f778WBw
5: 0x7f003c966e46 - rust_begin_unwind
6: 0x7f003c999ee4 - panicking::panic_fmt::h063af2dc79b71461c0B
7: 0x7f003c99b0ff - str::slice_error_fail::h6b062fef7704c76aLMJ
8: 0x7f003c955b0b - str::traits::str.ops..Index<ops..Range<usize>>::index::hd5dc3805dd71586eEBJ
at /root/rust/src/libcore/str/mod.rs:1408
9: 0x7f003c955812 - string::String.ops..Index<ops..Range<usize>>::index::h6e06879e88a080d5wHh
at /root/rust/src/libcollections/string.rs:941
10: 0x7f003c953f27 - reader::parser::inside_reference::PullParser::inside_reference::h50d494c95b4dfa3fPzc
at /root/xml-rs/src/reader/parser/inside_reference.rs:30
11: 0x7f003c95d470 - reader::parser::PullParser::dispatch_token::ha2333453eaa89eedJcd
at /root/xml-rs/src/reader/parser/mod.rs:329
12: 0x7f003c8cfa86 - reader::parser::PullParser::next::h6163686924289215835
at /root/xml-rs/src/reader/parser/mod.rs:256
13: 0x7f003c8cf34e - reader::EventReader<B>::next::h1752267722971489844
at /root/xml-rs/src/reader/mod.rs:44
14: 0x7f003c8cf0a2 - reader::Events<'a, B>.Iterator::next::h5762463174033631403
at /root/xml-rs/src/reader/mod.rs:78
15: 0x7f003c8c85dc - vec::Vec<T>.FromIterator<T>::from_iter::h16810629610021855622
at /root/rust/src/libcollections/vec.rs:1501
16: 0x7f003c8c7a9e - iter::Iterator::collect::h15266764030729070866
at /root/rust/src/libcore/iter.rs:567
17: 0x7f003c8c38d8 - main::ha4318abb77b31c89jaa
at src/main.rs:16
18: 0x7f003c96bff8 - rust_try_inner
19: 0x7f003c96bfe5 - rust_try
20: 0x7f003c968d43 - rt::lang_start::he6efc8b28021b078bSw
21: 0x7f003c8eb622 - main
22: 0x7f003baaba3f - __libc_start_main
23: 0x7f003c8c33b8 - _start
24: 0x0 - <unknown>
Process didn't exit successfully: `target/debug/afl-staging-area` (signal: 4)
This bug was found using https://github.com/kmcallister/afl.rs 👍
Have you considered making EventReader::next()
return Result<XmlEvent, Error>
and removing the Error
variant? It seems this could make bubbling up errors from recursive handlers a lot easier (with try!
).
Hello,
when building the project with Cargo 0.0.1 (rustc 0.12.0) on Windows 7, I get the following error messages:
Updating git repository `https://github.com/netvl/rust-xml`
Compiling rust-xml v0.1.0 (https://github.com/netvl/rust-xml#418a3776)
Could not compile `rust-xml`.
--- stderr
src\reader\mod.rs:58:26: 58:28 error: only the 'static lifetime is accepted here.
src\reader\mod.rs:58 pub struct Events<'a, B: 'a> {
^~
error: aborting due to previous error
How to create a "start_element" from a variable that stores the "local name"?
Thanks.
Michael
Unable to build on Windows 7 64 bits.
Here is the output of a simple cargo build --verbose
:
Compiling rust-xml v0.1.2-pre (https://github.com/netvl/rust-xml#2d9df326)
Running `rustc src\lib.rs --crate-name xml --crate-type lib -g -C metadata=9f7de8ee6433c876 -C extra-filename=-9f7de8ee6433c876 --out-dir D:\Code\Rust\testxml\target\deps --dep-info D:\Code\Rust\testxml\target\.fingerprint\rust-xml-9f7de8ee6433c876\dep-lib-xml -L D:\Code\Rust\testxml\target\deps -L D:\Code\Rust\testxml\target\deps -Awarnings`
src\reader\events.rs:19:5: 38:6 error: enum struct variants are experimental and possibly buggy
src\reader\events.rs:19 StartDocument {
src\reader\events.rs:20 /// XML version.
src\reader\events.rs:21 ///
src\reader\events.rs:22 /// If XML declaration is not present, defaults to `Version10`.
src\reader\events.rs:23 version: XmlVersion,
src\reader\events.rs:24
...
src\reader\events.rs:19:5: 38:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\reader\events.rs:19 StartDocument {
src\reader\events.rs:20 /// XML version.
src\reader\events.rs:21 ///
src\reader\events.rs:22 /// If XML declaration is not present, defaults to `Version10`.
src\reader\events.rs:23 version: XmlVersion,
src\reader\events.rs:24
...
src\reader\events.rs:50:5: 56:6 error: enum struct variants are experimental and possibly buggy
src\reader\events.rs:50 ProcessingInstruction {
src\reader\events.rs:51 /// Processing instruction target.
src\reader\events.rs:52 name: String,
src\reader\events.rs:53
src\reader\events.rs:54 /// Processing instruction content.
src\reader\events.rs:55 data: Option<String>
...
src\reader\events.rs:50:5: 56:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\reader\events.rs:50 ProcessingInstruction {
src\reader\events.rs:51 /// Processing instruction target.
src\reader\events.rs:52 name: String,
src\reader\events.rs:53
src\reader\events.rs:54 /// Processing instruction content.
src\reader\events.rs:55 data: Option<String>
...
src\reader\events.rs:62:5: 73:6 error: enum struct variants are experimental and possibly buggy
src\reader\events.rs:62 StartElement {
src\reader\events.rs:63 /// Qualified name of the element.
src\reader\events.rs:64 name: Name,
src\reader\events.rs:65
src\reader\events.rs:66 /// A list of attributes associated with the element.
src\reader\events.rs:67 ///
...
src\reader\events.rs:62:5: 73:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\reader\events.rs:62 StartElement {
src\reader\events.rs:63 /// Qualified name of the element.
src\reader\events.rs:64 name: Name,
src\reader\events.rs:65
src\reader\events.rs:66 /// A list of attributes associated with the element.
src\reader\events.rs:67 ///
...
src\reader\events.rs:79:5: 82:6 error: enum struct variants are experimental and possibly buggy
src\reader\events.rs:79 EndElement {
src\reader\events.rs:80 /// Qualified name of the element.
src\reader\events.rs:81 name: Name
src\reader\events.rs:82 },
src\reader\events.rs:79:5: 82:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\reader\events.rs:79 EndElement {
src\reader\events.rs:80 /// Qualified name of the element.
src\reader\events.rs:81 name: Name
src\reader\events.rs:82 },
src\writer\events.rs:13:5: 24:6 error: enum struct variants are experimental and possibly buggy
src\writer\events.rs:13 StartDocument {
src\writer\events.rs:14 /// XML version.
src\writer\events.rs:15 ///
src\writer\events.rs:16 /// If XML declaration is not present, defaults to `Version10`.
src\writer\events.rs:17 version: XmlVersion,
src\writer\events.rs:18
...
src\writer\events.rs:13:5: 24:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\writer\events.rs:13 StartDocument {
src\writer\events.rs:14 /// XML version.
src\writer\events.rs:15 ///
src\writer\events.rs:16 /// If XML declaration is not present, defaults to `Version10`.
src\writer\events.rs:17 version: XmlVersion,
src\writer\events.rs:18
...
src\writer\events.rs:30:5: 36:6 error: enum struct variants are experimental and possibly buggy
src\writer\events.rs:30 ProcessingInstruction {
src\writer\events.rs:31 /// Processing instruction target.
src\writer\events.rs:32 name: &'a str,
src\writer\events.rs:33
src\writer\events.rs:34 /// Processing instruction content.
src\writer\events.rs:35 data: Option<&'a str>
...
src\writer\events.rs:30:5: 36:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\writer\events.rs:30 ProcessingInstruction {
src\writer\events.rs:31 /// Processing instruction target.
src\writer\events.rs:32 name: &'a str,
src\writer\events.rs:33
src\writer\events.rs:34 /// Processing instruction content.
src\writer\events.rs:35 data: Option<&'a str>
...
src\writer\events.rs:45:5: 56:6 error: enum struct variants are experimental and possibly buggy
src\writer\events.rs:45 StartElement {
src\writer\events.rs:46 /// Qualified name of the element.
src\writer\events.rs:47 name: &'a Name,
src\writer\events.rs:48
src\writer\events.rs:49 /// A list of attributes associated with the element.
src\writer\events.rs:50 ///
...
src\writer\events.rs:45:5: 56:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\writer\events.rs:45 StartElement {
src\writer\events.rs:46 /// Qualified name of the element.
src\writer\events.rs:47 name: &'a Name,
src\writer\events.rs:48
src\writer\events.rs:49 /// A list of attributes associated with the element.
src\writer\events.rs:50 ///
...
src\writer\events.rs:62:5: 65:6 error: enum struct variants are experimental and possibly buggy
src\writer\events.rs:62 EndElement {
src\writer\events.rs:63 /// Qualified name of the element.
src\writer\events.rs:64 name: &'a Name
src\writer\events.rs:65 },
src\writer\events.rs:62:5: 65:6 note: add #![feature(struct_variant)] to the crate attributes to enable
src\writer\events.rs:62 EndElement {
src\writer\events.rs:63 /// Qualified name of the element.
src\writer\events.rs:64 name: &'a Name
src\writer\events.rs:65 },
error: aborting due to 8 previous errors
Could not compile `rust-xml`.
Caused by:
Process didn't exit successfully: `rustc src\lib.rs --crate-name xml --crate-type lib -g -C metadata=9f7de8ee6433c876 -C extra-filename=-9f7de8ee6433c876 --out-dir D:\Code\Rust\testxml\target\deps --dep-info D:\Code\Rust\testxml\target\.fingerprint\rust-xml-9f7de8ee6433c876\dep-lib-xml -L D:\Code\Rust\testxml\target\deps -L D:\Code\Rust\testxml\target\deps -Awarnings` (status=101)
Sorry for the long log or if I posted to the wrong place.
As the title says, a ;
inside an attribute value triggers an error.
Example program:
extern crate xml = "rust-xml";
use std::io::MemReader;
fn main() {
let value = "<hello test=\"5;3\">hello</hello>";
let mut reader = xml::reader::EventReader::new(MemReader::new(value.as_bytes().to_vec()));
for ev in reader.events() {
match ev {
xml::reader::events::Error(e) => fail!("{}", e),
_ => ()
}
}
}
Fails with:
task '<main>' failed at '1:17: Unexpected token inside attribute value: ;', /home/tomaka/projects/test-xml/src/main.rs:12
When trying to compile piston, the build fails when it attempts to compile the xml-rs crate with the following error:
.cargo\registry\src\github.com-0a35038f75765ae4\xml-rs-0.2.2\src\reader\events.rs:136:50: 136:60 error: no method named
joinfound for type
collections::vec::Veccollections::string::Stringin the current scope
I build and maintain a library for parsing property list files in Rust, plist-rs, and I created benchmarks to compare it to the other common plist parsing libraries:
$ rustup run nightly cargo bench --features libplist
Running target/release/comparison-1b39fc719adbc926
running 6 tests
test foundation::bench_binary ... bench: 2,214,275 ns/iter (+/- 785,637)
test foundation::bench_xml ... bench: 7,600,543 ns/iter (+/- 1,284,842)
test libplist::bench_binary ... bench: 4,147,479 ns/iter (+/- 1,656,727)
test libplist::bench_xml ... bench: 13,847,505 ns/iter (+/- 6,601,819)
test rust::bench_binary ... bench: 2,303,294 ns/iter (+/- 1,778,663)
test rust::bench_xml ... bench: 32,686,229 ns/iter (+/- 5,390,257)
test result: ok. 0 passed; 0 failed; 0 ignored; 6 measured
The XML property list parser in plist-rs
is based on xml-rs
, and as you can see it is twice as slow as libplist which uses libxml
and four times as slow as NSPropertyListSerialization (Apple's implementation) which uses a custom XML parser.
Just wanted to open this as a tracking issue to investigate where the issues are.
i took the usage example from the project main page and apply it to my 3 MB xml file with this result:
python: 00.968 sec (CPython/xml.etree, i have Java parser that are ~10x faster that this one)
rust: 04.310 sec (without prints traversing only!)
For cases when the document has zero-length, add a separate ErrorKind.
This will simplify the error handling.
Georges-MBP-2:rust-xml georgeburton$ cargo build
Compiling rust-xml v0.1.0 (file:///Users/georgeburton/Downloads/rust-xml)
src/namespace.rs:41:23: 41:29 error: cannot infer an appropriate lifetime for pattern due to conflicting requirements
src/namespace.rs:41 let Namespace(ref hm) = *self;
^~~~~~
src/namespace.rs:43:20: 43:21 note: first, the lifetime cannot outlive the expression at 43:19...
src/namespace.rs:43 match (k.as_ref().map(|k| k.as_slice()), v.as_slice()) {
^
src/namespace.rs:43:20: 43:21 note: ...so that pointer is not dereferenced outside its lifetime
src/namespace.rs:43 match (k.as_ref().map(|k| k.as_slice()), v.as_slice()) {
^
src/namespace.rs:42:23: 42:25 note: but, the lifetime must be valid for the expression at 42:22...
src/namespace.rs:42 for (k, v) in hm.iter() {
^~
src/namespace.rs:42:23: 42:25 note: ...so that pointer is not dereferenced outside its lifetime
src/namespace.rs:42 for (k, v) in hm.iter() {
^~
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile `rust-xml`.
Compiling xml-rs v0.1.18 (file:///home/ben/xml-rs)
src/util.rs:1:5: 1:28 error: unresolved import `std::borrow::BorrowFrom`. There is no `BorrowFrom` in `std::borrow`
src/util.rs:1 use std::borrow::BorrowFrom;
^~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `xml-rs`.
To learn more, run the command again with --verbose.
xml-rs fails to parse valid UTF-8 encoded XML documents that start with a Byte Order Mark:
Unexpected characters outside the root element: \u{feff}
It would be very useful if Attribute
implemented Show
.
With rustc version 0.12.0-nightly (136ab3c6b 2014-10-04 00:17:04 +0000) rust-xml will no longer build. It gives this error:
<std macros>:12:21: 12:42 error: allow(non_uppercase_statics) overruled by outer forbid(non_uppercase_statics)
<std macros>:12 #[allow(non_uppercase_statics)]
^~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 138:2 note: in expansion of bitflags!
src/writer/emitter.rs:111:1: 117:2 note: expansion site
<std macros>:12:21: 12:42 error: allow(non_uppercase_statics) overruled by outer forbid(non_uppercase_statics)
<std macros>:12 #[allow(non_uppercase_statics)]
^~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 138:2 note: in expansion of bitflags!
src/writer/emitter.rs:111:1: 117:2 note: expansion site
<std macros>:12:21: 12:42 error: allow(non_uppercase_statics) overruled by outer forbid(non_uppercase_statics)
<std macros>:12 #[allow(non_uppercase_statics)]
It appears that the ![forbid(non_uppercase_statics)]
in src/lib.rs conflicts with a #[allow(non_uppercase_statics)]
in the bitflags!
macro. Removing the forbid from src/lib.rs fixes it but I don't know if that's something you actually want to do.
Currently I/O errors are silently consumed and treated like EOF.
Unfortunately, proper solution would require breaking change in xml::reader::Error
.
Getting this error as of rust nightly 12-23:
src/namespace.rs:2:5: 2:23 error: unresolved import `core::slice::Items`. There is no `Items` in `core::slice`
src/namespace.rs:2 use core::slice::Items;
^~~~~~~~~~~~~~~~~~
Changed as of this commit: rust-lang/rust@f8cfd24#diff-91f9d2237c7851d61911b0ca64792a88
This would be very helpful to construct error messages when figuring out where in a multi-megabyte XML monstrosity a parser goes off the tracks. It looks like it should be a relatively straightforward change too.
When building on ARM, I got the following error:
Compiling xml-rs v0.1.26
error: could not exec the linker `cc`: No such file or directory (os error 2)
Build failed, waiting for other jobs to finish...
error: could not exec the linker `cc`: No such file or directory (os error 2)
Could not compile `advapi32-sys`.
Then I tried latest revision on branch master
and I got the "same" error: error: could not exec the linker cc
: No such file or directory (os error 2).
It already implements next()
, why not make it implement Iterator
?
This library still needs a way to construct a Document Object Model tree.
I have been experimenting with the library and looking for ways to implement it. My initial idea was to have an enumeration (XmlObject
), similar to the reader::events::XmlEvent
enumeration, but with the StartDocument
and EndDocument
events removed, and the XmlEvent::StartElement
and XmlEvent::EndElement
events merged into one object (XmlObject::Element
).
Every element-object part of a DOM tree would then contain all data that XmlEvent::StartElement
currently contains, plus another DOM tree object. This would allow for easy inserting DOM trees inside eachother.
A DOM tree could be as simple as an alternate type definiton for std::vec::Vec<XmlObject>
.
The problem with this approach is that there is a lot of redundancy, as almost everything inside XmlEvent
would have to be redefined inside XmlObject
. It could be better to simply make the XmlObject
enumeration a wrapper over XmlEvent
so that instead of every child basically storing a copy of what used to be inside the event, it contains the event. For people using the library that could however become annoying fast: you'd end up with code like: xml_element_object.start_element_event.name.local_name
just to get the name of an XML element out of the DOM tree.
I think we should use this issue to discuss how the DOM tree will be implemeted.
since it doesn't build using the latest rust nightly.
Why does this library use a Buffer as opposed to a Reader? Seems like Reader would be able to do the job.
Attempting to parse the following valid xml document:
<root>
<x><![CDATA[Foo]]></x>
<y><![CDATA[Foo [Bar]]]></y>
<z><![CDATA[Quux]]></z>
</root>
With the example program (slightly modified to print out the contents of the CData tags) gives the following:
+root
+x
cdata: Foo
-x
+y
cdata: Foo [Bar]]]></y>
<z><![CDATA[Quux
Error: 4:25 Unexpected closing tag: z, expected y
Seems parser is not reading the ]]]> as a close for the cdata and reading on until the next cdata tag.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.