Comments (8)
Not yet, but this is trivial to implement in the parser. Maybe we should bail out with an error if standalone is "no"
from serde-xml-rs.
I'm looking at this right now (I'm a total rust newbie) and I don't understand why it doesn't work.
The following in inner_next
should handle it:
match r.map_err(ErrorKind::Syntax)? {
XmlEvent::StartDocument { .. } |
from serde-xml-rs.
That seems too general. You'd skip over every kind of syntax error. I also am not sure if xml-rs
even supports recovering from syntax errors. Have you checked whether xml-rs supports headers in some way?
from serde-xml-rs.
xml-rs definitely supports <?xml ...?>
if that's what you mean by headers, it's in its own test suite: https://github.com/netvl/xml-rs/blob/master/tests/documents/sample_1.xml
from serde-xml-rs.
And it's returned as StartDocument
, which we already ignore. @kjeremy please provide more details - full reproducible example and an error message you're getting would be helpful.
from serde-xml-rs.
Right it returns StartDocument
which is why I'm surprised. The following test illustrates the problem and fails with a parsing error.
#[test]
fn ignore_header() {
init_logger();
let s = r#"
<?xml version=”1.0” standalone=”yes”?>
<item name="hello" source="world.rs" />
"#;
let item: Item = from_str(s).unwrap();
assert_eq!(
item,
Item {
name: "hello".to_string(),
source: "world.rs".to_string(),
}
);
}
thread 'ignore_header' panicked at 'called
Result::unwrap()
on anErr
value: Error(Syntax(Error { pos: 3:9, kind: Syntax("Unexpected token inside attribute value: <") }), State { next_error: None, backtrace: None })', src\libcore\result.rs:906:4
from serde-xml-rs.
@kjeremy If it's literally your XML, then the problem appears to be these weird quotes you have in the test - ”
(U+201D) in <?xml ...?>
vs normal quote "
(U+0022) everywhere else. Perhaps copied incorrectly from somewhere?
from serde-xml-rs.
Ah ha! Good catch. Yes I had originally copied some XML from a word doc. Replacing the quotes fixed the issue. I will close this.
from serde-xml-rs.
Related Issues (20)
- LastElementNameNotAvailable error on writing HOT 11
- Decoding 0 elements in to a Vec gives "custom: missing field `$value`" error HOT 2
- Deserialization with custom deserializer does not work according to serde spec HOT 1
- Is there something like "from_slice"
- custom: missing field `id`
- Expose EmitterConfig/Make document declaration optional
- readme.md example broken out of the box
- readme.md example broken out of the box
- Can't serialize a struct with error 'LastElementNotAvailable'
- Error `DocumentStartAlreadyEmitted` while trying to serialize simple structure in 0.6.0
- Hoot serialize into attributes HOT 2
- Cannot add attribute id
- duplicate field `$value`'
- Does anyone have an improved fork or does any better alternative exist?
- You've found a bug in xml-rs, caused by calls to push_pos() in states that don't end up emitting events
- Regression : Fix xml-rs depencency version in Cargo.toml
- error order when serde a enum field
- Parse error whlist parsing hackernoon xml feed
- Enum/choice list does not work HOT 1
- Unable to Serialize vector struct HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serde-xml-rs.