Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
fix(parse-collada): correctly interpret xs:anyURI type
Browse files Browse the repository at this point in the history
Add a new AnyUri type to use for parsing attributes with the xs:anyURI
type. Change InstangeGeometry::url to be of type AnyUri to be more
correct.

BREAKING CHANGES: Any usage of InstanceGeometry::url will be broken now
that it is an enum type.
  • Loading branch information
randomPoison committed Dec 9, 2015
1 parent d7efe8f commit a138504
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/parse_collada/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,23 @@ collada_element!("animation", Animation => {

collada_element!("annotate", Annotate => {});

#[derive(Debug, Clone)]
pub enum AnyUri {
Local(UriFragment),
External(String),
}

impl ColladaAttribute for AnyUri {
fn parse(text: &str) -> Result<AnyUri> {
if text.starts_with("#") {
let uri_fragment = try!(parse_attrib(text));
Ok(AnyUri::Local(uri_fragment))
} else {
Ok(AnyUri::External(String::from(text)))
}
}
}

#[derive(Debug, Clone)]
pub enum ArrayElement {
Idref(IdrefArray),
Expand Down Expand Up @@ -945,7 +962,7 @@ collada_element!("instance_effect", InstanceEffect => {
});

collada_element!("instance_geometry", InstanceGeometry => {
req attrib "url" => url: String
req attrib "url" => url: AnyUri
opt attrib "sid" => sid: String,
opt attrib "name" => name: String

Expand Down Expand Up @@ -1658,7 +1675,7 @@ impl ColladaElement for UpAxis {
}

#[derive(Debug, Clone)]
pub struct UriFragment(String);
pub struct UriFragment(pub String);

impl Deref for UriFragment {
type Target = String;
Expand Down

0 comments on commit a138504

Please sign in to comment.