repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/pereference.rs
src/parser/xml/dtd/pereference.rs
use crate::item::Node; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::tag::tag; use crate::parser::combinators::take::take_until; use crate::parser::xml::dtd::extsubset::extsubsetdecl; use crate::parser::{ParseError, ParseInput}; pub(crate) fn pereference<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| { let e = delimited(tag("%"), take_until(";"), tag(";"))((input, state)); match e { Err(e) => Err(e), Ok(((input1, state1), entitykey)) => { //match state1.currentlyexternal { // /* Are we in an external DTD? Param entities not allowed anywhere else. */ // false => Err(ParseError::NotWellFormed), // true => { match state1.clone().dtd.paramentities.get(&entitykey as &str) { Some((entval, _)) => { if state1.currententitydepth >= state1.maxentitydepth { //attempting to exceed expansion depth Err(ParseError::EntityDepth { col: state1.currentcol, row: state1.currentrow, }) } else { //Parse the entity, using the parserstate which has information on namespaces let mut tempstate = state1.clone(); tempstate.currententitydepth += 1; let e2 = entval.clone(); match extsubsetdecl()((e2.as_str(), tempstate)) { Ok(((outstr, _), _)) => { if !outstr.is_empty() { Err(ParseError::NotWellFormed(outstr.to_string())) } else { Ok(((input1, state1), ())) } } Err(_) => Err(ParseError::NotWellFormed(e2)), } } } None => Err(ParseError::MissingParamEntity { col: state1.currentcol, row: state1.currentrow, }), } // } //} } } } } pub(crate) fn petextreference<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| { let e = delimited(tag("%"), take_until(";"), tag(";"))((input, state)); match e { Err(e) => Err(e), Ok(((input1, state1), entitykey)) => { match state1.currentlyexternal { /* Are we in an external DTD? Param entities not allowed anywhere else. */ false => Err(ParseError::NotWellFormed(String::from( "parameter entity not allowed outside of external DTD", ))), true => { match state1.clone().dtd.paramentities.get(&entitykey as &str) { Some((entval, _)) => { if state1.currententitydepth >= state1.maxentitydepth { //attempting to exceed expansion depth Err(ParseError::EntityDepth { col: state1.currentcol, row: state1.currentrow, }) } else { //Parse the entity, using the parserstate which has information on namespaces let mut tempstate = state1.clone(); tempstate.currententitydepth += 1; Ok(((input1, state1), entval.clone())) } } None => Err(ParseError::MissingParamEntity { col: state1.currentcol, row: state1.currentrow, }), } } } } } } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/mod.rs
src/parser/xml/dtd/mod.rs
mod attlistdecl; mod conditionals; mod elementdecl; mod enumerated; mod externalid; pub(crate) mod extsubset; mod gedecl; mod intsubset; mod misc; mod notation; mod pedecl; pub(crate) mod pereference; mod textdecl; use crate::item::Node; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::opt::opt; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple8; use crate::parser::combinators::whitespace::{whitespace0, whitespace1}; use crate::parser::xml::dtd::externalid::externalid; use crate::parser::xml::dtd::extsubset::extsubset; use crate::parser::xml::dtd::intsubset::intsubset; use crate::parser::xml::qname::name; use crate::parser::xml::reference::reference; use crate::parser::{ParseError, ParseInput}; use crate::qname::QualifiedName; use crate::xmldecl::{AttType, DTDPattern, DefaultDecl}; #[derive(Clone)] pub(crate) enum Occurances { ZeroOrMore, OneOrMore, One, ZeroOrOne, } pub(crate) fn doctypedecl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |input| match tuple8( tag("<!DOCTYPE"), whitespace1(), name(), whitespace1(), opt(externalid()), whitespace0(), opt(delimited(tag("["), intsubset(), tag("]"))), tag(">"), )(input) { Ok(((input1, mut state1), (_, _, n, _, _, _, _inss, _))) => { let q: QualifiedName = if n.contains(':') { let mut nameparts = n.split(':'); QualifiedName::new( None, Some(nameparts.next().unwrap().parse().unwrap()), nameparts.next().unwrap(), ) } else { QualifiedName::new(None, None, n) }; state1.dtd.name = Some(q); /* We're doing nothing with the below, just evaluating the external entity to check its well formed */ let exdtd = state1.ext_entities_to_parse.clone().pop(); match exdtd { None => {} Some(s) => match state1.clone().resolve(state1.docloc.clone(), s) { Err(_) => return Err(ParseError::ExtDTDLoadError), Ok(s) => { if let Err(e) = extsubset()((s.as_str(), state1.clone())) { return Err(e); } } }, } /* Same again, with Internal subset */ for (k, (v, _)) in state1.clone().dtd.generalentities { if v != *"<" { /* A single < on its own will generate an error if used, but doesn't actually generate a not well formed error! */ if let Err(ParseError::NotWellFormed(v)) = reference()(( ["&".to_string(), k, ";".to_string()].join("").as_str(), state1.clone(), )) { return Err(ParseError::NotWellFormed(v)); } } } for (elname, eldecl) in &state1.dtd.elements { match &state1.dtd.attlists.get(elname) { None => { state1.dtd.patterns.insert( elname.clone(), DTDPattern::Element(elname.clone(), Box::new(eldecl.clone())), ); } Some(attlist) => { let mut attpat = None; for (attname, (at, dd, _)) in attlist.iter() { let mut ap = match at { AttType::CDATA => DTDPattern::Text, AttType::ID => DTDPattern::Text, AttType::IDREF => DTDPattern::Text, AttType::IDREFS => DTDPattern::Text, AttType::ENTITY => DTDPattern::Text, AttType::ENTITIES => DTDPattern::Text, AttType::NMTOKEN => DTDPattern::Text, AttType::NMTOKENS => DTDPattern::Text, AttType::NOTATION(_) => DTDPattern::Text, AttType::ENUMERATION(el) => { let mut enumers = el.iter(); let mut pat = DTDPattern::Value(enumers.next().unwrap().clone()); for s in enumers { pat = DTDPattern::Group( Box::new(pat), Box::new(DTDPattern::Value(s.clone())), ) } pat } }; match dd { DefaultDecl::Implied => { ap = DTDPattern::Choice( Box::new(DTDPattern::Attribute( attname.clone(), Box::new(ap), )), Box::new(DTDPattern::Empty), ) } _ => ap = DTDPattern::Attribute(attname.clone(), Box::new(ap)), } match attpat { None => { attpat = Some(ap); } Some(ap2) => { attpat = Some(DTDPattern::Group(Box::new(ap), Box::new(ap2))); } } } state1.dtd.patterns.insert( elname.clone(), DTDPattern::Element( elname.clone(), Box::new(DTDPattern::Group( Box::new(eldecl.clone()), Box::new(attpat.unwrap()), )), ), ); } } } //println!("{:?}", patternrefs); Ok(((input1, state1), ())) } Err(err) => Err(err), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/gedecl.rs
src/parser/xml/dtd/gedecl.rs
use crate::item::Node; use crate::parser::combinators::alt::{alt3, alt4}; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::take::{take_until, take_until_either_or_min1, take_until_end}; use crate::parser::combinators::tuple::{tuple2, tuple7}; use crate::parser::combinators::wellformed::{wellformed, wellformed_ver}; use crate::parser::combinators::whitespace::{whitespace0, whitespace1}; use crate::parser::common::{is_char10, is_char11, is_unrestricted_char11}; use crate::parser::xml::chardata::chardata_unicode_codepoint; use crate::parser::xml::dtd::externalid::textexternalid; use crate::parser::xml::dtd::intsubset::intsubset; use crate::parser::xml::dtd::pereference::petextreference; use crate::parser::xml::qname::qualname; use crate::parser::{ParseError, ParseInput}; pub(crate) fn gedecl<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |input| match wellformed_ver( tuple7( tag("<!ENTITY"), whitespace1(), wellformed(qualname(), |n| !n.to_string().contains(':')), whitespace1(), alt3( textexternalid(), delimited(tag("'"), take_until("'"), tag("'")), delimited(tag("\""), take_until("\""), tag("\"")), ), whitespace0(), tag(">"), ), |(_, _, _, _, s, _, _)| !s.contains(|c: char| !is_char10(&c)), //XML 1.0 |(_, _, _, _, s, _, _)| !s.contains(|c: char| !is_unrestricted_char11(&c)), //XML 1.1 )(input) { Ok(((input2, mut state2), (_, _, n, _, s, _, _))) => { /* Numeric and other entities expanded immediately, since there'll be namespaces and the like to deal with later, after that we just store the entity as a string and parse again when called. */ if !state2.currentlyexternal && s.contains('%') { return Err(ParseError::NotWellFormed(s)); } let entityparse = map( tuple2( map( many0(alt4( //we leave the &#13; or #xD; as is, as it will be converted later if needed and we don't want the \r character stripped later. map( wellformed_ver(chardata_unicode_codepoint(), is_char10, is_char11), |c| { if c == '\r' { "&#13;".to_string() } else { c.to_string() } }, ), petextreference(), //General entity is ignored. map(delimited(tag("&"), take_until(";"), tag(";")), |s| { ["&".to_string(), s, ";".to_string()].concat() }), take_until_either_or_min1("&", "%"), )), |ve| ve.concat(), ), wellformed(take_until_end(), |s| !s.contains('&') && !s.contains('%')), ), |(a, b)| [a, b].concat(), )((s.as_str(), state2.clone())); match entityparse { Ok(((_, _), res)) => { if !state2.currentlyexternal { match intsubset()((res.as_str(), state2.clone())) { Ok(_) => {} Err(_) => return Err(ParseError::NotWellFormed(res)), } }; /* Entities should always bind to the first value */ let replaceable = state2.currentlyexternal; match state2.dtd.generalentities.get(n.to_string().as_str()) { None => { state2 .dtd .generalentities .insert(n.to_string(), (res, replaceable)); Ok(((input2, state2), ())) } Some((_, true)) => { state2 .dtd .generalentities .entry(n.to_string()) .or_insert((res, replaceable)); Ok(((input2, state2), ())) } _ => Ok(((input2, state2), ())), } //state2.dtd // .generalentities.entry(n.to_string()) // .or_insert(res); } Err(e) => Err(e), } } Err(err) => Err(err), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/intsubset.rs
src/parser/xml/dtd/intsubset.rs
use crate::item::Node; use crate::parser::combinators::alt::alt9; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::whitespace::whitespace1; use crate::parser::xml::dtd::attlistdecl::attlistdecl; use crate::parser::xml::dtd::elementdecl::elementdecl; use crate::parser::xml::dtd::gedecl::gedecl; use crate::parser::xml::dtd::notation::notation_decl; use crate::parser::xml::dtd::pedecl::pedecl; use crate::parser::xml::dtd::pereference::pereference; use crate::parser::xml::misc::comment; use crate::parser::xml::misc::processing_instruction; use crate::parser::{ParseError, ParseInput}; pub(crate) fn intsubset<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<()>), ParseError> { many0(alt9( elementdecl(), attlistdecl(), pedecl(), gedecl(), notation_decl(), whitespace1(), map(comment(), |_| ()), map(processing_instruction(), |_| ()), pereference(), )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/elementdecl.rs
src/parser/xml/dtd/elementdecl.rs
use crate::item::Node; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple7; use crate::parser::combinators::whitespace::{whitespace0, whitespace1}; use crate::parser::xml::dtd::misc::contentspec; use crate::parser::xml::qname::qualname; use crate::parser::{ParseError, ParseInput}; //elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>' pub(crate) fn elementdecl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |input| match tuple7( tag("<!ELEMENT"), whitespace1(), qualname(), whitespace1(), contentspec(), //contentspec - TODO Build out. whitespace0(), tag(">"), )(input) { Ok(((input2, mut state2), (_, _, n, _, s, _, _))) => { state2.dtd.elements.insert(n, s); Ok(((input2, state2), ())) } Err(err) => Err(err), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/attlistdecl.rs
src/parser/xml/dtd/attlistdecl.rs
use crate::item::Node; use crate::parser::combinators::alt::{alt2, alt3, alt9}; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::tag::tag; use crate::parser::combinators::take::take_while; use crate::parser::combinators::tuple::{tuple2, tuple6}; use crate::parser::combinators::value::value; use crate::parser::combinators::whitespace::{whitespace0, whitespace1}; use crate::parser::common::{is_ncnamechar, is_ncnamestartchar}; use crate::parser::xml::chardata::chardata_unicode_codepoint; use crate::parser::xml::dtd::enumerated::enumeratedtype; use crate::parser::xml::qname::{name, qualname}; use crate::parser::xml::reference::textreference; use crate::parser::{ParseError, ParseInput}; use crate::qname::QualifiedName; use crate::xmldecl::{AttType, DefaultDecl}; use std::collections::HashMap; //AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>' pub(crate) fn attlistdecl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| match tuple6( tag("<!ATTLIST"), whitespace1(), qualname(), many0(attdef()), whitespace0(), tag(">"), )((input, state)) { Ok(((input2, mut state2), (_, _, n, ats, _, _))) => { /* "3.3 Attribute-List Declarations When more than one AttlistDecl is provided for a given element type, the contents of all those provided are merged. When more than one definition is provided for the same attribute of a given element type, the first declaration is binding and later declarations are ignored." So we're going to do some checks for existing ATTLIST declarations, but each one has a boolean flag to confirm if it was created by an external or internal DTD. If its external we can happily overwrite, but not for internal. */ /* Entities should always bind to the first value */ let replaceable = state2.currentlyexternal; let mut atts = HashMap::new(); let mut count_id_attrs = 0; for (qn, att, dfd) in ats { match &dfd { //We need to make sure that the default is valid, even if its not used. DefaultDecl::FIXED(s) | DefaultDecl::Default(s) => { match att { AttType::ID => { count_id_attrs += 1; let mut ch = s.chars(); match ch.next() { None => {} Some(c) => { if is_ncnamestartchar(&c) { for cha in ch { if !is_ncnamechar(&cha) { return Err(ParseError::NotWellFormed( String::from( "DTD Attvalue default is invalid", ), )); } } } else { return Err(ParseError::NotWellFormed(String::from( "DTD Attvalue default is invalid", ))); } } } } AttType::IDREF => { let mut ch = s.chars(); match ch.next() { None => {} Some(c) => { if is_ncnamestartchar(&c) { for cha in ch { if !is_ncnamechar(&cha) { return Err(ParseError::NotWellFormed( String::from( "DTD Attvalue default is invalid", ), )); } } } else { return Err(ParseError::NotWellFormed(String::from( "DTD Attvalue default is invalid", ))); } } } } AttType::IDREFS => { let names = s.split(' '); for name in names { let mut ch = name.chars(); match ch.next() { None => {} Some(c) => { if is_ncnamestartchar(&c) { for cha in ch { if !is_ncnamechar(&cha) { return Err(ParseError::NotWellFormed( String::from( "DTD Attvalue default is invalid", ), )); } } } else { return Err(ParseError::NotWellFormed( String::from("DTD Attvalue default is invalid"), )); } } } } } AttType::ENTITY => { let mut ch = s.chars(); match ch.next() { None => {} Some(c) => { if is_ncnamestartchar(&c) { for cha in ch { if !is_ncnamechar(&cha) { return Err(ParseError::NotWellFormed( String::from( "DTD Attvalue default is invalid", ), )); } } } else { return Err(ParseError::NotWellFormed(String::from( "DTD Attvalue default is invalid", ))); } } } } AttType::ENTITIES => { let entities = s.split(' '); for entity in entities { let mut ch = entity.chars(); match ch.next() { None => {} Some(c) => { if is_ncnamestartchar(&c) { for cha in ch { if !is_ncnamechar(&cha) { return Err(ParseError::NotWellFormed( String::from( "DTD Attvalue default is invalid", ), )); } } } else { return Err(ParseError::NotWellFormed( String::from("DTD Attvalue default is invalid"), )); } } } } } _ => { /*TODO complete the rest of these */ } } } //else do nothing _ => {} } //xml:id datatype checking if qn == QualifiedName::new(None, Some("xml".to_string()), "id".to_string()) && att != AttType::ID { return Err(ParseError::IDError( "xml:id declaration in the DTD does not have type ID".to_string(), )); } atts.insert(qn, (att, dfd, replaceable)); } if count_id_attrs > 1 { return Err(ParseError::NotWellFormed(String::from( "Duplicate ID attribute declarations", ))); } if !atts.is_empty() { match state2.dtd.attlists.get(&n) { None => { state2.dtd.attlists.insert(n, atts); } Some(al) => { let mut newal = al.clone(); for (attname, (atttype, defaultdecl, is_editable)) in atts.iter() { match newal.get(attname) { None => { newal.insert( attname.clone(), (atttype.clone(), defaultdecl.clone(), *is_editable), ); } Some((_, _, existing_is_editable)) => { if *existing_is_editable { newal.insert( attname.clone(), (atttype.clone(), defaultdecl.clone(), *is_editable), ); } } } } state2.dtd.attlists.insert(n, newal); } } } Ok(((input2, state2), ())) } Err(err) => Err(err), } } //AttDef ::= S Name S AttType S DefaultDecl fn attdef<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (QualifiedName, AttType, DefaultDecl)), ParseError> { map( tuple6( whitespace1(), name(), whitespace1(), atttype(), whitespace1(), defaultdecl(), ), |(_, an, _, at, _, dd)| { let qn = if an.contains(':') { let mut attnamesplit = an.split(':'); let prefix = Some(attnamesplit.next().unwrap().to_string()); let local = attnamesplit.collect::<String>(); QualifiedName::new(None, prefix, local) } else { QualifiedName::new(None, None, an) }; (qn, at, dd) }, ) } //AttType ::= StringType | TokenizedType | EnumeratedType fn atttype<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, AttType), ParseError> { alt9( //map(petextreference(), |_| {}), //TODO value(tag("CDATA"), AttType::CDATA), //Stringtype //tokenizedtype value(tag("IDREFS"), AttType::IDREFS), value(tag("IDREF"), AttType::IDREF), value(tag("ID"), AttType::ID), value(tag("ENTITY"), AttType::ENTITY), value(tag("ENTITIES"), AttType::ENTITIES), value(tag("NMTOKENS"), AttType::NMTOKENS), value(tag("NMTOKEN"), AttType::NMTOKEN), enumeratedtype(), ) } //DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue) fn defaultdecl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, DefaultDecl), ParseError> { alt3( value(tag("#REQUIRED"), DefaultDecl::Required), value(tag("#IMPLIED"), DefaultDecl::Implied), map( tuple2( opt(tuple2( value(tag("#FIXED"), "#FIXED".to_string()), whitespace1(), )), attvalue(), ), |(x, y)| match x { None => DefaultDecl::Default(y), Some(_) => DefaultDecl::FIXED(y), }, ), ) } //AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'" fn attvalue<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { alt2( delimited( tag("\'"), map( many0(alt3( map(chardata_unicode_codepoint(), |c| c.to_string()), take_while(|c| !"&\'<".contains(c)), textreference(), )), |v| v.join(""), ), tag("\'"), ), delimited( tag("\""), map( many0(alt3( map(chardata_unicode_codepoint(), |c| c.to_string()), take_while(|c| !"&\"<".contains(c)), textreference(), )), |v| v.join(""), ), tag("\""), ), ) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/textdecl.rs
src/parser/xml/dtd/textdecl.rs
use crate::item::Node; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::{tuple2, tuple5, tuple6}; use crate::parser::combinators::whitespace::{whitespace0, whitespace1}; use crate::parser::xml::strings::delimited_string; use crate::parser::xml::xmldecl::encodingdecl; use crate::parser::{ParseError, ParseInput}; use crate::xmldecl::XMLDecl; fn xmldeclversion<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| match tuple5( tag("version"), whitespace0(), tag("="), whitespace0(), delimited_string(), )((input, state)) { Ok(((input1, state1), (_, _, _, _, v))) => { if v == *"1.1" { if state1.xmlversion == "1.0" { return Err(ParseError::NotWellFormed(String::from("version mismatch"))); } Ok(((input1, state1), v)) } else if v.starts_with("1.") { Ok(((input1, state1), "1.0".to_string())) } else { Err(ParseError::Notimplemented) } } Err(err) => Err(err), } } pub(crate) fn textdecl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, XMLDecl), ParseError> { //This is NOT the same as the XML declaration in XML documents. //There is no standalone, and the version is optional. map( tuple6( tag("<?xml"), opt(tuple2(whitespace1(), xmldeclversion())), encodingdecl(), whitespace0(), tag("?>"), whitespace0(), ), |(_, ver, enc, _, _, _)| { if ver == Some(((), "1.1".to_string())) { XMLDecl { version: "1.1".to_string(), encoding: Some(enc), standalone: None, } } else { XMLDecl { version: "1.0".to_string(), encoding: Some(enc), standalone: None, } } }, ) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/enumerated.rs
src/parser/xml/dtd/enumerated.rs
use crate::item::Node; use crate::parser::combinators::alt::alt2; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::{tuple4, tuple6}; use crate::parser::combinators::whitespace::whitespace0; use crate::parser::xml::dtd::misc::nmtoken; use crate::parser::xml::dtd::notation::notationtype; use crate::parser::{ParseError, ParseInput}; use crate::xmldecl::AttType; //EnumeratedType ::= NotationType | Enumeration pub(crate) fn enumeratedtype<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, AttType), ParseError> { alt2(notationtype(), enumeration()) } //Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' fn enumeration<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, AttType), ParseError> { map( tuple6( tag("("), whitespace0(), nmtoken(), many0(map( tuple4(whitespace0(), tag("|"), whitespace0(), nmtoken()), |(_, _, _, nmt)| nmt, )), whitespace0(), tag(")"), ), |(_, _, nm, mut nms, _, _)| { nms.push(nm); AttType::ENUMERATION(nms) }, ) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/notation.rs
src/parser/xml/dtd/notation.rs
use crate::item::Node; use crate::parser::combinators::alt::{alt2, alt3}; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::take::{take_until, take_while}; use crate::parser::combinators::tuple::{tuple3, tuple4, tuple5, tuple7, tuple8}; use crate::parser::combinators::wellformed::wellformed; use crate::parser::combinators::whitespace::{whitespace0, whitespace1}; use crate::parser::common::{is_pubid_char, is_pubid_charwithapos}; use crate::parser::xml::qname::{name, qualname}; use crate::parser::{ParseError, ParseInput}; use crate::xmldecl::{AttType, DTDDecl}; //NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' pub(crate) fn notationtype<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, AttType), ParseError> { map( tuple8( tag("NOTATION"), whitespace1(), tag("("), whitespace0(), name(), many0(map( tuple4(whitespace0(), tag("|"), whitespace0(), name()), |(_, _, _, n)| n, )), whitespace0(), tag(")"), ), |(_, _, _, _, nm, mut nms, _, _)| { nms.push(nm); AttType::NOTATION(nms) }, ) } pub(crate) fn notationpublicid<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { alt3( map( tuple3( tag("SYSTEM"), whitespace1(), alt2( delimited(tag("'"), take_until("'"), tag("'")), delimited(tag("\""), take_until("\""), tag("\"")), ), //SystemLiteral ), |(_, _, sid)| sid, //(sid, None), ), map( tuple5( tag("PUBLIC"), whitespace1(), alt2( delimited(tag("'"), take_while(|c| is_pubid_char(&c)), tag("'")), delimited( tag("\""), take_while(|c| is_pubid_charwithapos(&c)), tag("\""), ), ), //PubidLiteral TODO validate chars here (PubidChar from spec). whitespace1(), alt2( delimited(tag("'"), take_until("'"), tag("'")), delimited(tag("\""), take_until("\""), tag("\"")), ), //SystemLiteral ), |(_, _, _pid, _, sid)| sid, ), //(sid, Some(pid)), map( tuple3( tag("PUBLIC"), whitespace1(), alt2( delimited(tag("'"), take_while(|c| is_pubid_char(&c)), tag("'")), delimited( tag("\""), take_while(|c| is_pubid_charwithapos(&c)), tag("\""), ), ), ), |_| "".to_string(), ), ) } pub(crate) fn notation_decl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |input| match tuple7( tag("<!NOTATION"), whitespace1(), wellformed(qualname(), |n| !n.to_string().contains(':')), whitespace1(), notationpublicid(), //contentspec(), //take_until(">"), //contentspec - TODO Build out. whitespace0(), tag(">"), )(input) { Ok(((input2, mut state2), (_, _, n, _, s, _, _))) => { state2 .dtd .notations .insert(n.to_string(), DTDDecl::Notation(n, s)); Ok(((input2, state2), ())) } Err(err) => Err(err), } } #[allow(dead_code)] pub(crate) fn ndatadecl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { map( tuple4(whitespace1(), tag("NDATA"), whitespace1(), name()), |(_, _, _, notation)| notation, ) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/externalid.rs
src/parser/xml/dtd/externalid.rs
use crate::parser::combinators::alt::alt2; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::tag::tag; use crate::parser::combinators::take::{take_until, take_while}; use crate::parser::combinators::tuple::{tuple3, tuple5}; use crate::parser::combinators::whitespace::{whitespace0, whitespace1}; use crate::parser::common::{is_pubid_char, is_pubid_charwithapos}; use crate::parser::xml::dtd::extsubset::extsubset; use crate::parser::xml::dtd::textdecl::textdecl; use crate::parser::{ParseError, ParseInput}; use crate::Node; pub(crate) fn externalid<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| { match alt2( map( tuple3( tag("SYSTEM"), whitespace0(), alt2( delimited(tag("'"), take_until("'"), tag("'")), delimited(tag("\""), take_until("\""), tag("\"")), ), //SystemLiteral ), |(_, _, sid)| (sid, None), ), map( tuple5( tag("PUBLIC"), whitespace0(), alt2( delimited(tag("'"), take_while(|c| is_pubid_char(&c)), tag("'")), delimited( tag("\""), take_while(|c| is_pubid_charwithapos(&c)), tag("\""), ), ), //PubidLiteral TODO validate chars here (PubidChar from spec). whitespace1(), alt2( delimited(tag("'"), take_until("'"), tag("'")), delimited(tag("\""), take_until("\""), tag("\"")), ), //SystemLiteral ), |(_, _, pid, _, sid)| (sid, Some(pid)), ), )((input, state)) { Err(e) => Err(e), Ok(((input2, mut state2), (sid, _))) => { if !state2.currentlyexternal { state2.ext_entities_to_parse.push(sid); Ok(((input2, state2), ())) } else { match state2.clone().resolve(state2.docloc.clone(), sid) { Err(_) => Err(ParseError::ExtDTDLoadError), Ok(s) => match extsubset()((s.as_str(), state2)) { Err(e) => Err(e), Ok(((_, state3), _)) => Ok(((input2, state3), ())), }, } } } } } } pub(crate) fn textexternalid<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| { match alt2( map( tuple3( tag("SYSTEM"), whitespace0(), alt2( delimited(tag("'"), take_until("'"), tag("'")), delimited(tag("\""), take_until("\""), tag("\"")), ), //SystemLiteral ), |(_, _, sid)| (sid, None), ), map( tuple5( tag("PUBLIC"), whitespace1(), alt2( delimited(tag("'"), take_while(|c| is_pubid_char(&c)), tag("'")), delimited( tag("\""), take_while(|c| is_pubid_charwithapos(&c)), tag("\""), ), ), //PubidLiteral TODO validate chars here (PubidChar from spec). whitespace1(), alt2( delimited(tag("'"), take_until("'"), tag("'")), delimited(tag("\""), take_until("\""), tag("\"")), ), //SystemLiteral ), |(_, _, pid, _, sid)| (sid, Some(pid)), ), )((input, state)) { Err(e) => Err(e), Ok(((input2, state2), (sid, _pid))) => { match state2.clone().resolve(state2.docloc.clone(), sid) { Err(_) => Err(ParseError::ExtDTDLoadError), Ok(s) => { if state2.xmlversion == "1.1" { s.replace("\r\n", "\n") .replace("\r\u{85}", "\n") .replace("\u{85}", "\n") .replace("\u{2028}", "\n") .replace("\r", "\n") } else { s.replace("\r\n", "\n").replace('\r', "\n") }; match opt(textdecl())((s.as_str(), state2.clone())) { Err(_) => Ok(((input2, state2), s)), Ok(((i3, _), _)) => Ok(((input2, state2), i3.to_string())), } } } } } } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/conditionals.rs
src/parser/xml/dtd/conditionals.rs
use crate::item::Node; use crate::parser::combinators::alt::alt3; use crate::parser::combinators::many::many0; use crate::parser::combinators::tag::tag; use crate::parser::combinators::take::{take_until, take_until_either_or}; use crate::parser::combinators::tuple::{tuple2, tuple3, tuple5}; use crate::parser::combinators::value::value; use crate::parser::combinators::whitespace::whitespace0; use crate::parser::xml::dtd::extsubset::extsubsetdecl; use crate::parser::xml::dtd::pereference::petextreference; use crate::parser::{ParseError, ParseInput}; pub(crate) fn conditionalsect<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| match tuple5( tag("<!["), whitespace0(), alt3( petextreference(), value(tag("INCLUDE"), "INCLUDE".to_string()), value(tag("IGNORE"), "IGNORE".to_string()), ), whitespace0(), tag("["), )((input, state)) { Ok(((input2, state2), (_, _, ii, _, _))) => match ii.as_str() { "INCLUDE" => includesect()((input2, state2)), "IGNORE" => ignoresect()((input2, state2)), _ => Err(ParseError::Combinator), }, Err(e) => Err(e), } } pub(crate) fn includesect<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| match tuple2(extsubsetdecl(), tag("]]>"))((input, state)) { Ok(((input2, state2), (_, _))) => Ok(((input2, state2), ())), Err(e) => Err(e), } } pub(crate) fn ignoresect<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| match tuple2(ignoresectcontents(), tag("]]>"))((input, state.clone())) { Ok(((input2, _), (_, _))) => Ok(((input2, state), ())), Err(e) => Err(e), } } fn ignoresectcontents<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| match tuple2( many0(tuple2( take_until_either_or("<![", "]]>"), tuple3(tag("<!["), ignoresectcontents(), tag("]]>")), )), take_until("]]>"), )((input, state.clone())) { Ok(((input2, _), (_, _))) => Ok(((input2, state), ())), Err(e) => Err(e), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xml/dtd/extsubset.rs
src/parser/xml/dtd/extsubset.rs
use crate::item::Node; use crate::parser::combinators::alt::alt10; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::tuple::tuple2; use crate::parser::combinators::whitespace::whitespace1; use crate::parser::xml::dtd::attlistdecl::attlistdecl; use crate::parser::xml::dtd::conditionals::conditionalsect; use crate::parser::xml::dtd::elementdecl::elementdecl; use crate::parser::xml::dtd::gedecl::gedecl; use crate::parser::xml::dtd::notation::notation_decl; use crate::parser::xml::dtd::pedecl::pedecl; use crate::parser::xml::dtd::pereference::pereference; use crate::parser::xml::dtd::textdecl::textdecl; use crate::parser::xml::misc::{comment, processing_instruction}; use crate::parser::{ParseError, ParseInput}; pub(crate) fn extsubset<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, mut state)| { if state.standalone { Ok(((input, state), ())) } else { state.currentlyexternal = true; match tuple2(opt(textdecl()), extsubsetdecl())((input, state)) { Ok(((input2, mut state2), (_, _))) => { if !input2.is_empty() { Err(ParseError::NotWellFormed(input2.to_string())) } else { state2.currentlyexternal = false; Ok(((input2, state2), ())) } } Err(e) => Err(e), } } } } pub(crate) fn extsubsetdecl<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<()>), ParseError> { many0(alt10( conditionalsect(), elementdecl(), attlistdecl(), pedecl(), gedecl(), notation_decl(), whitespace1(), map(comment(), |_| ()), map(processing_instruction(), |_| ()), pereference(), )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/alt.rs
src/parser/combinators/alt.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub fn alt2<P1, P2, A, N: Node>( parser1: P1, parser2: P2, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser2((input, state)) { Ok(parse_result2) => Ok(parse_result2), Err(err) => Err(err), } } Err(err) => Err(err), } } pub fn alt3<P1, P2, P3, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser3((input, state)) { Ok(parse_result3) => Ok(parse_result3), Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), } } pub fn alt4<P1, P2, P3, P4, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser4((input, state)) { Ok(parse_result4) => Ok(parse_result4), Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), } } pub(crate) fn alt5<P1, P2, P3, P4, P5, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser4((input, state.clone())) { Ok(parse_result4) => Ok(parse_result4), Err(ParseError::Combinator) | Err(ParseError::NotWellFormed(_)) => { match parser5((input, state)) { Ok(parse_result5) => Ok(parse_result5), Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), } } pub(crate) fn alt6<P1, P2, P3, P4, P5, P6, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) => match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) => match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) => match parser4((input, state.clone())) { Ok(parse_result4) => Ok(parse_result4), Err(ParseError::Combinator) => match parser5((input, state.clone())) { Ok(parse_result5) => Ok(parse_result5), Err(ParseError::Combinator) => match parser6((input, state.clone())) { Ok(parse_result6) => Ok(parse_result6), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } #[allow(dead_code)] pub(crate) fn alt7<P1, P2, P3, P4, P5, P6, P7, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) => match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) => match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) => match parser4((input, state.clone())) { Ok(parse_result4) => Ok(parse_result4), Err(ParseError::Combinator) => match parser5((input, state.clone())) { Ok(parse_result5) => Ok(parse_result5), Err(ParseError::Combinator) => match parser6((input, state.clone())) { Ok(parse_result6) => Ok(parse_result6), Err(ParseError::Combinator) => match parser7((input, state)) { Ok(parse_result7) => Ok(parse_result7), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } /* #[allow(clippy::too_many_arguments)] pub(crate) fn alt8<P1, P2, P3, P4, P5, P6, P7, P8, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, parser8: P8, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P8: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) => match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) => match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) => match parser4((input, state.clone())) { Ok(parse_result4) => Ok(parse_result4), Err(ParseError::Combinator) => match parser5((input, state.clone())) { Ok(parse_result5) => Ok(parse_result5), Err(ParseError::Combinator) => match parser6((input, state.clone())) { Ok(parse_result6) => Ok(parse_result6), Err(ParseError::Combinator) => match parser7((input, state.clone())) { Ok(parse_result7) => Ok(parse_result7), Err(ParseError::Combinator) => match parser8((input, state)) { Ok(parse_result8) => Ok(parse_result8), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } */ #[allow(clippy::too_many_arguments)] pub(crate) fn alt9<P1, P2, P3, P4, P5, P6, P7, P8, P9, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, parser8: P8, parser9: P9, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P8: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P9: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) => match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) => match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) => match parser4((input, state.clone())) { Ok(parse_result4) => Ok(parse_result4), Err(ParseError::Combinator) => match parser5((input, state.clone())) { Ok(parse_result5) => Ok(parse_result5), Err(ParseError::Combinator) => match parser6((input, state.clone())) { Ok(parse_result6) => Ok(parse_result6), Err(ParseError::Combinator) => match parser7((input, state.clone())) { Ok(parse_result7) => Ok(parse_result7), Err(ParseError::Combinator) => { match parser8((input, state.clone())) { Ok(parse_result8) => Ok(parse_result8), Err(ParseError::Combinator) => { match parser9((input, state)) { Ok(parse_result9) => Ok(parse_result9), Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } #[allow(clippy::too_many_arguments)] pub(crate) fn alt10<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, parser8: P8, parser9: P9, parser10: P10, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P8: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P9: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P10: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) => match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) => match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) => match parser4((input, state.clone())) { Ok(parse_result4) => Ok(parse_result4), Err(ParseError::Combinator) => match parser5((input, state.clone())) { Ok(parse_result5) => Ok(parse_result5), Err(ParseError::Combinator) => match parser6((input, state.clone())) { Ok(parse_result6) => Ok(parse_result6), Err(ParseError::Combinator) => match parser7((input, state.clone())) { Ok(parse_result7) => Ok(parse_result7), Err(ParseError::Combinator) => { match parser8((input, state.clone())) { Ok(parse_result8) => Ok(parse_result8), Err(ParseError::Combinator) => { match parser9((input, state.clone())) { Ok(parse_result9) => Ok(parse_result9), Err(ParseError::Combinator) => { match parser10((input, state)) { Ok(parse_result10) => Ok(parse_result10), Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), } } Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } /* #[allow(clippy::too_many_arguments)] pub(crate) fn alt11<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, A, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, parser8: P8, parser9: P9, parser10: P10, parser11: P11 ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P8: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P9: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P10: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P11: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, { move |(input, state)| match parser1((input, state.clone())) { Ok(parse_result) => Ok(parse_result), Err(ParseError::Combinator) => match parser2((input, state.clone())) { Ok(parse_result2) => Ok(parse_result2), Err(ParseError::Combinator) => match parser3((input, state.clone())) { Ok(parse_result3) => Ok(parse_result3), Err(ParseError::Combinator) => match parser4((input, state.clone())) { Ok(parse_result4) => Ok(parse_result4), Err(ParseError::Combinator) => match parser5((input, state.clone())) { Ok(parse_result5) => Ok(parse_result5), Err(ParseError::Combinator) => match parser6((input, state.clone())) { Ok(parse_result6) => Ok(parse_result6), Err(ParseError::Combinator) => match parser7((input, state.clone())) { Ok(parse_result7) => Ok(parse_result7), Err(ParseError::Combinator) => match parser8((input, state.clone())) { Ok(parse_result8) => Ok(parse_result8), Err(ParseError::Combinator) => match parser9((input, state.clone())) { Ok(parse_result9) => Ok(parse_result9), Err(ParseError::Combinator) => match parser10((input, state.clone())) { Ok(parse_result10) => Ok(parse_result10), Err(ParseError::Combinator) => match parser11((input, state)) { Ok(parse_result11) => Ok(parse_result11), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } */
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/support.rs
src/parser/combinators/support.rs
//! Supporting functions. use crate::item::Node; use crate::parser::{ParseError, ParseInput}; /// Return zero or more digits from the input stream. Be careful not to consume non-digit input. pub(crate) fn digit0<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| { match input.find(|c| !('0'..='9').contains(&c)) { Some(0) => Err(ParseError::Combinator), Some(pos) => { //let result = (&mut input).take(pos).collect::<String>(); Ok(((&input[pos..], state), input[..pos].to_string())) } None => { if input.is_empty() { Err(ParseError::Combinator) } else { Ok((("", state), input.to_string())) } } } } } /// Return one or more digits from the input stream. pub(crate) fn digit1<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| { if input.starts_with(|c| ('0'..='9').contains(&c)) { match input.find(|c| !('0'..='9').contains(&c)) { Some(0) => Ok(((&input[1..], state), input[..1].to_string())), Some(pos) => Ok(((&input[pos..], state), input[..pos].to_string())), None => Ok((("", state), input.to_string())), } } else { Err(ParseError::Combinator) } } } /// Return the next character if it is not from the given set pub(crate) fn none_of<N: Node>( s: &str, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, char), ParseError> + '_ { move |(input, state)| { if input.is_empty() { Err(ParseError::Combinator) } else { let a = input.chars().next().unwrap(); match s.find(|b| a == b) { Some(_) => Err(ParseError::Combinator), None => Ok(((&input[1..], state), a)), } } } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/wellformed.rs
src/parser/combinators/wellformed.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub(crate) fn wellformed<P, F, A, N: Node>( parser: P, validate_fn: F, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, F: Fn(&A) -> bool, { move |input| match parser(input) { Ok(((input2, state2), result)) => { if validate_fn(&result) { Ok(((input2, state2), result)) } else { Err(ParseError::NotWellFormed(input2.to_string())) } } Err(err) => Err(err), } } pub(crate) fn wellformed_ver<P, F10, F11, A, N: Node>( parser: P, validate_fn10: F10, validate_fn11: F11, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, F10: Fn(&A) -> bool, F11: Fn(&A) -> bool, { /* Some well formed constraints (specifically character checks) are dependant on XML versions. This just selects the constraint based on the version in the state. */ move |input| match parser(input) { Ok(((input2, state2), result)) => { if state2.xmlversion == "1.1" { if validate_fn11(&result) { Ok(((input2, state2), result)) } else { Err(ParseError::NotWellFormed(input2.to_string())) } } else if validate_fn10(&result) { Ok(((input2, state2), result)) } else { Err(ParseError::NotWellFormed(input2.to_string())) } } Err(err) => Err(err), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/take.rs
src/parser/combinators/take.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub(crate) fn take_one<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, char), ParseError> { move |(input, state)| { let c = input.chars().next(); match c { None => Err(ParseError::Combinator), Some(ind) => Ok(((&input[ind.len_utf8()..], state), ind)), } } } pub(crate) fn take_until<N: Node>( s: &'static str, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| match input.find(s) { None => Err(ParseError::Combinator), Some(ind) => Ok(((&input[ind..], state), input[0..ind].to_string())), } } pub(crate) fn take_until_either_or<N: Node>( s1: &'static str, s2: &'static str, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| { let r1 = input.find(s1); let r2 = input.find(s2); match (r1, r2) { (Some(i1), Some(i2)) => Ok(( (&input[i1.min(i2)..], state), input[0..i1.min(i2)].to_string(), )), (Some(i1), None) => Ok(((&input[i1..], state), input[0..i1].to_string())), (None, Some(i2)) => Ok(((&input[i2..], state), input[0..i2].to_string())), (None, None) => Err(ParseError::Combinator), } } } pub(crate) fn take_until_either_or_min1<N: Node>( s1: &'static str, s2: &'static str, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| { let r1 = input.find(s1); let r2 = input.find(s2); match (r1, r2) { (Some(i1), Some(i2)) => { if i1 == 0 || i2 == 0 { Err(ParseError::Combinator) } else { Ok(( (&input[i1.min(i2)..], state), input[0..i1.min(i2)].to_string(), )) } } (Some(i1), None) => { if i1 == 0 { Err(ParseError::Combinator) } else { Ok(((&input[i1..], state), input[0..i1].to_string())) } } (None, Some(i2)) => { if i2 == 0 { Err(ParseError::Combinator) } else { Ok(((&input[i2..], state), input[0..i2].to_string())) } } (None, None) => Err(ParseError::Combinator), } } } pub(crate) fn take_until_end<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> { move |(input, state)| Ok((("", state), input.to_string())) } /// Take characters from the input while the condition is true. /// If there is no character that fails the condition, /// then if the input is empty returns ParseError::Combinator (i.e. no match), /// otherwise returns the input. pub(crate) fn take_while<F, N: Node>( condition: F, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> //TODO REPLACE WITH ORDINARY TAKE_WHILE where F: Fn(char) -> bool, { move |(input, state)| match input.find(|c| !condition(c)) { None => { if input.is_empty() { Err(ParseError::Combinator) } else { Ok((("", state), input.to_string())) } } Some(0) => Err(ParseError::Combinator), Some(pos) => Ok(((&input[pos..], state), input[0..pos].to_string())), } } /// Take characters from the input while the condition is true. /// If there is no character that fails the condition, /// then if the input is empty returns ParseError::Combinator (i.e. no match), /// otherwise returns the input. #[allow(dead_code)] pub(crate) fn take_while_m_n<F, N: Node>( min: usize, max: usize, condition: F, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> where F: Fn(char) -> bool, { move |(input, state)| match input.find(|c| !condition(c)) { None => { if input.is_empty() { Err(ParseError::Combinator) } else { Ok(((&input[max..], state), input[0..max].to_string())) } } Some(pos) => { if pos >= min { if pos > max { Ok(((&input[max..], state), input[0..max].to_string())) } else { Ok(((&input[pos..], state), input[0..pos].to_string())) } } else { Err(ParseError::Combinator) } } } } #[cfg(test)] mod tests { use crate::parser::combinators::take::{ take_until, take_until_either_or, take_while, take_while_m_n, }; use crate::parser::{ParseError, ParserState}; use crate::trees::nullo::Nullo; #[test] fn parser_take_until_test1() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until(">"); assert_eq!( Ok(( (">", ParserState::new(None, None, None)), "<doc".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_until_test2() { let testdoc = "<document"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until(">"); assert_eq!(Err(ParseError::Combinator), parse_doc((testdoc, teststate))); } #[test] fn parser_take_until_test3() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until("oc"); assert_eq!( Ok(( ("oc>", ParserState::new(None, None, None)), "<d".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_until_test4() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until("doc"); assert_eq!( Ok(( ("doc>", ParserState::new(None, None, None)), "<".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_while_test1() { let testdoc = "AAAAABCCCCC"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_while(|c| c != 'B'); assert_eq!( Ok(( ("BCCCCC", ParserState::new(None, None, None)), "AAAAA".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_while_test2() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_while(|c| c != 'B' && c != 'C'); assert_eq!( Ok(( ("BCDEFGH", ParserState::new(None, None, None)), "A".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_while_test3() { let testdoc = "v1\"></doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_while(|c| c != '&' && c != '"'); assert_eq!( Ok(( ("\"></doc>", ParserState::new(None, None, None)), "v1".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_until_either_or1() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until_either_or("DE", "FG"); assert_eq!( Ok(( ("DEFGH", ParserState::new(None, None, None)), "ABC".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_until_either_or2() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until_either_or("AA", "BB"); assert_eq!(Err(ParseError::Combinator), parse_doc((testdoc, teststate))); } #[test] fn parser_take_until_either_or3() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until_either_or("EF", "FF"); assert_eq!( Ok(( ("EFGH", ParserState::new(None, None, None)), "ABCD".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_until_either_or4() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until_either_or("ABD", "GH"); assert_eq!( Ok(( ("GH", ParserState::new(None, None, None)), "ABCDEF".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_until_either_or5() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_until_either_or("BC", "BC"); assert_eq!( Ok(( ("BCDEFGH", ParserState::new(None, None, None)), "A".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_while_m_n_1() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_while_m_n(2, 4, |c| c.is_uppercase()); assert_eq!( Ok(( ("EFGH", ParserState::new(None, None, None)), "ABCD".to_string() )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_take_while_m_n_2() { let testdoc = "ABCDEFGH"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = take_while_m_n(2, 4, |c| c.is_lowercase()); assert_eq!(Err(ParseError::Combinator), parse_doc((testdoc, teststate))); } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/list.rs
src/parser/combinators/list.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub fn separated_list0<P1, P2, R1, N: Node>( sep: P1, f: P2, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<R1>), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, { move |mut input| { let mut res = Vec::new(); match f(input.clone()) { Err(_e) => { return Ok((input, res)); } Ok((i1, o)) => { res.push(o); input = i1; } } loop { match sep(input.clone()) { Err(ParseError::Combinator) => { return Ok((input, res)); } Err(e) => return Err(e), Ok((i1, _)) => { // infinite loop check: the parser must always consume // SRB: not sure if this check is necessary with this parser, since input is an iterator // if i1.input_len() == len { // return Err(ParseError::Combinator); // } match f(i1) { Err(ParseError::Combinator) => return Ok((input, res)), Err(e) => return Err(e), Ok((i2, o)) => { res.push(o); input = i2; } } } } } } } pub(crate) fn separated_list1<P1, P2, R1, N: Node>( sep: P1, f: P2, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<R1>), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, { move |mut input| { let mut res = Vec::new(); match f(input.clone()) { Err(e) => return Err(e), Ok((i1, o)) => { res.push(o); input = i1; } } loop { match sep(input.clone()) { Err(ParseError::Combinator) => { return Ok((input, res)); } Err(e) => return Err(e), Ok((i1, _)) => { // infinite loop check: the parser must always consume // SRB: not sure if this check is necessary with this parser, since input is an iterator // if i1.input_len() == len { // return Err(ParseError::Combinator); // } match f(i1) { Err(ParseError::Combinator) => { return Ok((input, res)); } Err(e) => return Err(e), Ok((i2, o)) => { res.push(o); input = i2; } } } } } } } #[cfg(test)] mod tests { use crate::parser::combinators::alt::alt4; use crate::parser::combinators::list::{separated_list0, separated_list1}; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::ParserState; use crate::trees::nullo::Nullo; #[test] fn parser_separated_list0_test1() { let testdoc = "b"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = separated_list0(tag(","), map(tag("a"), |_| "a")); assert_eq!( Ok((("b", ParserState::new(None, None, None)), vec![])), parse_doc((testdoc, teststate)) ); } #[test] fn parser_separated_list0_test2() { let testdoc = "a"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = separated_list0(tag(","), map(tag("a"), |_| "a")); assert_eq!( Ok((("", ParserState::new(None, None, None)), vec!["a"])), parse_doc((testdoc, teststate)) ); } #[test] fn parser_separated_list0_test3() { let testdoc = "a,b,c,d"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = separated_list1( tag(","), alt4( map(tag("a"), |_| "1"), map(tag("b"), |_| "2"), map(tag("c"), |_| "3"), map(tag("d"), |_| "4"), ), ); assert_eq!( Ok(( ("", ParserState::new(None, None, None)), vec!["1", "2", "3", "4"] )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_separated_list1_test1() { let testdoc = "a"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = separated_list1(tag(","), map(tag("a"), |_| "a")); assert_eq!( Ok((("", ParserState::new(None, None, None)), vec!["a"])), parse_doc((testdoc, teststate)) ); } #[test] fn parser_separated_list1_test2() { let testdoc = "a,b,c,d"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = separated_list1( tag(","), alt4( map(tag("a"), |_| "1"), map(tag("b"), |_| "2"), map(tag("c"), |_| "3"), map(tag("d"), |_| "4"), ), ); assert_eq!( Ok(( ("", ParserState::new(None, None, None)), vec!["1", "2", "3", "4"] )), parse_doc((testdoc, teststate)) ); } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/value.rs
src/parser/combinators/value.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub(crate) fn value<P1, R1, V: Clone, N: Node>( parser1: P1, val: V, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, V), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, { move |input| match parser1(input) { Ok((input1, _)) => Ok((input1, val.clone())), Err(err) => Err(err), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/pair.rs
src/parser/combinators/pair.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub(crate) fn pair<P1, P2, A, B, N: Node>( parser1: P1, parser2: P2, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (A, B)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, B), ParseError>, { move |input| match parser1(input) { Ok((input1, parse1_result)) => match parser2(input1) { Ok((input2, parse2_result)) => Ok((input2, (parse1_result, parse2_result))), Err(err) => Err(err), }, Err(err) => Err(err), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/whitespace.rs
src/parser/combinators/whitespace.rs
use std::cmp::Ordering; use crate::item::Node; use crate::parser::combinators::alt::alt4; use crate::parser::combinators::many::{many0, many1}; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple3; use crate::parser::{ParseError, ParseInput}; pub fn whitespace0<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { //TODO add support for xml:space map( many0(alt4(tag(" "), tag("\t"), tag("\r"), tag("\n"))), |_| (), ) } pub(crate) fn whitespace1<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { //TODO add support for xml:space map( many1(alt4(tag(" "), tag("\t"), tag("\r"), tag("\n"))), |_| (), ) } pub(crate) fn xpwhitespace<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { map( tuple3( whitespace0(), take_until_balanced("(:", ":)"), whitespace0(), ), |_| (), ) } /// Parse nested input. /// /// Inspired by 'take_until_unbalanced' from parse_hyperlinks crate. /// We can't use the parse_hyperlinks version since it only takes character delimiters. /// Also, this function does not need to consider escaped brackets. /// The function assumes that the open and close delimiters are the same length. /// /// This function consumes the delimiters. /// The start delimiter must be the first token in the input. Finding this sets the bracket count to 1. /// After that there are 4 scenarios: /// /// * The close delimiter is not found. This is an error. /// * There is no open delimiter. In this case, consume up to and including the close delimiter. If the bracket count is 1 then return Ok, otherwise error. /// * There is an open delimiter. If the open occurs after the close, then consume up to and including the close delimiter. If the bracket count is 1 then return Ok, otherwise error. /// * The open delimiter occurs before the close. In this case, increment the bracket count and continue after the open delimiter. fn take_until_balanced<N: Node>( open: &'static str, close: &'static str, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| { let mut pos = 0; let mut counter = 0; let mut bracket_counter = 0; loop { counter += 1; if counter > 1000 { return Err(ParseError::EntityDepth { row: 0, col: counter, }); } match (input[pos..].find(open), input[pos..].find(close)) { (Some(0), _) => { bracket_counter += 1; pos += open.len(); //let _: Vec<_> = (&mut input).take(open.len()).collect(); match (input[pos..].find(open), input[pos..].find(close)) { (_, None) => { // Scenario 1 return Err(ParseError::Unbalanced); } (Some(o), Some(c)) => { // Scenario 3/4 if o > c { // Scenario 3 if bracket_counter == 1 { //let _: Vec<_> = (&mut input).take(c + close.len()).collect(); pos += c + close.len(); return Ok(((&input[pos..], state), ())); } else { return Err(ParseError::Unbalanced); } } else { // Scenario 4 bracket_counter += 1; //let _: Vec<_> = (&mut input).take(o + open.len()).collect(); pos += o + close.len(); } } (_, Some(c)) => { // Scenario 2 match bracket_counter.cmp(&1) { Ordering::Greater => { bracket_counter -= 1; //let _: Vec<_> = (&mut input).take(c + close.len()).collect(); pos += c + close.len(); } Ordering::Equal => { //let _: Vec<_> = (&mut input).take(c + close.len()).collect(); pos += c + close.len(); return Ok(((&input[pos..], state), ())); } Ordering::Less => { return Err(ParseError::Unbalanced); } } } } } (None, Some(c)) => { // Scenario 2 match bracket_counter.cmp(&1) { Ordering::Greater => { bracket_counter -= 1; //let _: Vec<_> = (&mut input).take(c + close.len()).collect(); pos += c + close.len(); } Ordering::Equal => { //let _: Vec<_> = (&mut input).take(c + close.len()).collect(); pos += c + close.len(); return Ok(((&input[pos..], state), ())); } Ordering::Less => { return Err(ParseError::Unbalanced); } } } _ => return Ok(((&input[pos..], state), ())), } } } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/debug.rs
src/parser/combinators/debug.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; /// Emits a message to stderr from within the parser combinator. This can be useful for debugging. #[allow(dead_code)] pub fn inspect<'a, P1, A, N: Node>( msg: &'a str, parser: P1, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> + 'a where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> + 'a, { move |(input, state)| { eprintln!( "inspect pre: {} - input: \"{}\"", msg, input.chars().take(80).collect::<String>() ); let result = parser((input, state.clone())); let errmsg = format!( "error: {:?}", result .as_ref() .map_or_else(|e| e, |_| &ParseError::Notimplemented) ); eprintln!( "inspect post: {} - input is now \"{}\"", msg, result .as_ref() .map_or_else(|_| errmsg, |((r, _), _)| r.to_string()) .chars() .take(80) .collect::<String>() ); result } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/map.rs
src/parser/combinators/map.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput, ParserState}; pub fn map<P, F, A, B, N: Node>( parser: P, map_fn: F, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, B), ParseError> //-> impl Fn(ParseInput<N>)-> Result<(String, usize, B), usize> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, F: Fn(A) -> B, { move |input| match parser(input) { Ok((input2, result)) => Ok((input2, map_fn(result))), Err(err) => Err(err), } } pub fn map_ver<P, F, G, A, B, N: Node>( parser: P, map_fn10: F, map_fn11: G, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, B), ParseError> //-> impl Fn(ParseInput<N>)-> Result<(String, usize, B), usize> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, F: Fn(A) -> B, G: Fn(A) -> B, { move |input| match parser(input) { Ok(((input2, state2), result)) => { if state2.xmlversion == "1.1" { Ok(((input2, state2), map_fn11(result))) } else { Ok(((input2, state2), map_fn10(result))) } } Err(err) => Err(err), } } pub fn map_with_state<P, F, A, B, N: Node>( parser: P, map_fn: F, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, B), ParseError> //-> impl Fn(ParseInput<N>)-> Result<(String, usize, B), usize> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError>, F: Fn(A, ParserState<N>) -> B, { move |input| match parser(input) { Ok((input2, result)) => Ok((input2.clone(), map_fn(result, input2.1))), Err(err) => Err(err), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/tuple.rs
src/parser/combinators/tuple.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub fn tuple2<P1, P2, R1, R2, N: Node>( parser1: P1, parser2: P2, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => Ok((input2, (result1, result2))), Err(err) => Err(err), }, Err(err) => Err(err), } } pub fn tuple3<P1, P2, P3, R1, R2, R3, N: Node>( parser1: P1, parser2: P2, parser3: P3, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2, R3)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => Ok((input3, (result1, result2, result3))), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } pub fn tuple4<P1, P2, P3, P4, R1, R2, R3, R4, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2, R3, R4)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R4), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => match parser4(input3) { Ok((input4, result4)) => Ok((input4, (result1, result2, result3, result4))), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } pub(crate) fn tuple5<P1, P2, P3, P4, P5, R1, R2, R3, R4, R5, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2, R3, R4, R5)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R4), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R5), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => match parser4(input3) { Ok((input4, result4)) => match parser5(input4) { Ok((input5, result5)) => { Ok((input5, (result1, result2, result3, result4, result5))) } Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } pub(crate) fn tuple6<P1, P2, P3, P4, P5, P6, R1, R2, R3, R4, R5, R6, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2, R3, R4, R5, R6)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R4), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R5), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R6), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => match parser4(input3) { Ok((input4, result4)) => match parser5(input4) { Ok((input5, result5)) => match parser6(input5) { Ok((input6, result6)) => Ok(( input6, (result1, result2, result3, result4, result5, result6), )), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } pub(crate) fn tuple7<P1, P2, P3, P4, P5, P6, P7, R1, R2, R3, R4, R5, R6, R7, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2, R3, R4, R5, R6, R7)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R4), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R5), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R6), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R7), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => match parser4(input3) { Ok((input4, result4)) => match parser5(input4) { Ok((input5, result5)) => match parser6(input5) { Ok((input6, result6)) => match parser7(input6) { Ok((input7, result7)) => Ok(( input7, ( result1, result2, result3, result4, result5, result6, result7, ), )), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } #[allow(clippy::too_many_arguments)] pub(crate) fn tuple8<P1, P2, P3, P4, P5, P6, P7, P8, R1, R2, R3, R4, R5, R6, R7, R8, N: Node>( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, parser8: P8, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2, R3, R4, R5, R6, R7, R8)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R4), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R5), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R6), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R7), ParseError>, P8: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R8), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => match parser4(input3) { Ok((input4, result4)) => match parser5(input4) { Ok((input5, result5)) => match parser6(input5) { Ok((input6, result6)) => match parser7(input6) { Ok((input7, result7)) => match parser8(input7) { Ok((input8, result8)) => Ok(( input8, ( result1, result2, result3, result4, result5, result6, result7, result8, ), )), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } #[allow(clippy::too_many_arguments)] pub(crate) fn tuple9< P1, P2, P3, P4, P5, P6, P7, P8, P9, R1, R2, R3, R4, R5, R6, R7, R8, R9, N: Node, >( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, parser8: P8, parser9: P9, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, (R1, R2, R3, R4, R5, R6, R7, R8, R9)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R4), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R5), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R6), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R7), ParseError>, P8: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R8), ParseError>, P9: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R9), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => match parser4(input3) { Ok((input4, result4)) => match parser5(input4) { Ok((input5, result5)) => match parser6(input5) { Ok((input6, result6)) => match parser7(input6) { Ok((input7, result7)) => match parser8(input7) { Ok((input8, result8)) => match parser9(input8) { Ok((input9, result9)) => Ok(( input9, ( result1, result2, result3, result4, result5, result6, result7, result8, result9, ), )), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } #[allow(clippy::too_many_arguments)] pub(crate) fn tuple10< P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, N: Node, >( parser1: P1, parser2: P2, parser3: P3, parser4: P4, parser5: P5, parser6: P6, parser7: P7, parser8: P8, parser9: P9, parser10: P10, ) -> impl Fn( ParseInput<N>, ) -> Result<(ParseInput<N>, (R1, R2, R3, R4, R5, R6, R7, R8, R9, R10)), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, P4: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R4), ParseError>, P5: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R5), ParseError>, P6: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R6), ParseError>, P7: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R7), ParseError>, P8: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R8), ParseError>, P9: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R9), ParseError>, P10: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R10), ParseError>, { move |input| match parser1(input) { Ok((input1, result1)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, result3)) => match parser4(input3) { Ok((input4, result4)) => match parser5(input4) { Ok((input5, result5)) => match parser6(input5) { Ok((input6, result6)) => match parser7(input6) { Ok((input7, result7)) => match parser8(input7) { Ok((input8, result8)) => match parser9(input8) { Ok((input9, result9)) => match parser10(input9) { Ok((input10, result10)) => Ok(( input10, ( result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, ), )), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } #[cfg(test)] mod tests { use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple3; use crate::parser::ParserState; use crate::trees::nullo::Nullo; #[test] fn parser_tuple3_test1() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = tuple3(tag("<"), tag("doc"), tag(">")); assert_eq!( Ok((("", ParserState::new(None, None, None)), ((), (), ()))), parse_doc((testdoc, teststate)) ); } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/mod.rs
src/parser/combinators/mod.rs
pub mod alt; pub(crate) mod delimited; pub mod list; pub mod many; pub mod map; pub(crate) mod pair; pub mod tag; pub(crate) mod take; pub mod tuple; //pub(crate) mod expander; pub(crate) mod opt; pub(crate) mod value; pub(crate) mod wellformed; pub mod whitespace; pub mod debug; pub(crate) mod support;
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/opt.rs
src/parser/combinators/opt.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub(crate) fn opt<P1, R1, N: Node>( parser1: P1, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Option<R1>), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, { move |input| match parser1(input.clone()) { Ok((input1, result1)) => Ok((input1, Some(result1))), Err(ParseError::Combinator) => Ok((input, None)), Err(err) => Err(err), } } #[cfg(test)] mod tests { use crate::parser::combinators::opt::opt; use crate::parser::combinators::tag::tag; use crate::parser::ParserState; use crate::trees::nullo::Nullo; #[test] fn parser_opt_test1() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = opt(tag("<")); assert_eq!( Ok((("doc>", ParserState::new(None, None, None)), Some(()))), parse_doc((testdoc, teststate)) ); } #[test] fn parser_opt_test2() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = opt(tag(">")); assert_eq!( Ok((("<doc>", ParserState::new(None, None, None)), None)), parse_doc((testdoc, teststate)) ); } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/many.rs
src/parser/combinators/many.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub fn many0<P, R, N: Node>( parser: P, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<R>), ParseError> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R), ParseError>, { //TODO ERROR IF ANY ERROR OTHER THAN COMBINATOR RETURNED. move |mut input| { let mut result = Vec::new(); while let Ok((input2, next_item)) = parser(input.clone()) { result.push(next_item); input = input2; } Ok((input, result)) } } ///This is a special combinator, it will reset namespaces on the parser state between iterations ///It is only intended for use when parsing the children of an element node. pub fn many0nsreset<P, R, N: Node>( parser: P, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<R>), ParseError> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R), ParseError>, { //TODO ERROR IF ANY ERROR OTHER THAN COMBINATOR RETURNED. move |(mut input, mut state)| { let mut result = Vec::new(); let namespaces = state.namespace.clone(); while let Ok(((input2, mut state2), next_item)) = parser((input, state.clone())) { result.push(next_item); input = input2; state2.namespace = namespaces.clone(); state = state2; } Ok(((input, state), result)) } } pub fn many1<P, R, N: Node>( parser: P, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<R>), ParseError> where P: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R), ParseError>, { //TODO ERROR IF ANY ERROR OTHER THAN COMBINATOR RETURNED. move |mut input| { let mut result = Vec::new(); match parser(input) { Err(err) => Err(err), Ok((input1, result1)) => { input = input1; result.push(result1); while let Ok((input2, next_item)) = parser(input.clone()) { input = input2; result.push(next_item); } Ok((input, result)) } } } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/delimited.rs
src/parser/combinators/delimited.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub(crate) fn delimited<P1, P2, P3, R1, R2, R3, N: Node>( parser1: P1, parser2: P2, parser3: P3, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError> where P1: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R1), ParseError>, P2: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R2), ParseError>, P3: Fn(ParseInput<N>) -> Result<(ParseInput<N>, R3), ParseError>, { move |input| match parser1(input) { Ok((input1, _)) => match parser2(input1) { Ok((input2, result2)) => match parser3(input2) { Ok((input3, _)) => Ok((input3, result2)), Err(err) => Err(err), }, Err(err) => Err(err), }, Err(err) => Err(err), } } #[cfg(test)] mod tests { use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::tag::tag; use crate::parser::ParserState; use crate::trees::nullo::Nullo; #[test] fn parser_delimited_test1() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = delimited(tag("<"), tag("doc"), tag(">")); assert_eq!( Ok((("", ParserState::new(None, None, None)), ())), parse_doc((testdoc, teststate)) ); } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/tag.rs
src/parser/combinators/tag.rs
use crate::item::Node; use crate::parser::{ParseError, ParseInput}; pub fn tag<N: Node>( expected: &str, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> + '_ { move |(input, state)| match input.get(0..expected.len()) { None => Err(ParseError::Combinator), Some(chars) => { if chars == expected { Ok(((&input[expected.len()..], state), ())) } else { Err(ParseError::Combinator) } } } } /// Return the longest possible of one of the given tags. /// If there are multiple tags of the same length, the first one that matches will be returned. pub(crate) fn anytag<N: Node>( s: Vec<&str>, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> + '_ { move |(input, state)| { // NB. this algorithm could probably be optimised let u = s.iter().fold("", |result, t| { if t.len() > result.len() { // Since this tag is longer, it is a candidate match input.get(0..t.len()) { None => result, Some(chars) => { if chars == *t { t } else { result } } } } else { result } }); if u.is_empty() { Err(ParseError::Combinator) } else { Ok(((&input[u.len()..], state), u.to_string())) } } } pub(crate) fn anychar<N: Node>( expected: char, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, ()), ParseError> { move |(input, state)| { if input.starts_with(expected) { Ok(((&input[1..], state), ())) } else { Err(ParseError::Combinator) } } } #[cfg(test)] mod tests { use crate::parser::combinators::tag::{anychar, anytag, tag}; use crate::parser::{ParseError, ParserState}; use crate::trees::nullo::Nullo; #[test] fn parser_tag_test1() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = tag("<"); assert_eq!( Ok((("doc>", ParserState::new(None, None, None)), ())), parse_doc((testdoc, teststate)) ); } #[test] fn parser_tag_test2() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = tag(">"); assert_eq!(Err(ParseError::Combinator), parse_doc((testdoc, teststate))); } #[test] fn parser_tag_test3() { let testdoc = "<?ProcessingInstruction?>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = tag("<?"); assert_eq!( Ok(( ( "ProcessingInstruction?>", ParserState::new(None, None, None) ), () )), parse_doc((testdoc, teststate)) ); } #[test] fn parser_char_test1() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = anychar('<'); assert_eq!( Ok((("doc>", ParserState::new(None, None, None)), ())), parse_doc((testdoc, teststate)) ) } #[test] fn parser_char_test2() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = anychar('>'); assert_eq!(Err(ParseError::Combinator), parse_doc((testdoc, teststate))) } #[test] fn parser_anytag_test1() { let testdoc = "<doc>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = anytag(vec![">", ">=", "<=", "<"]); assert_eq!( Ok(( ("doc>", ParserState::new(None, None, None)), "<".to_string() )), parse_doc((testdoc, teststate)) ) } #[test] fn parser_anytag_test2() { let testdoc = "<=>"; let teststate: ParserState<Nullo> = ParserState::new(None, None, None); let parse_doc = anytag(vec![">", ">=", "<=", "<"]); assert_eq!( Ok(((">", ParserState::new(None, None, None)), "<=".to_string())), parse_doc((testdoc, teststate)) ) } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/combinators/expander.rs
src/parser/combinators/expander.rs
use std::string::ParseError; use crate::item::Node; use crate::xmldecl::DTDDecl; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::tag::tag; use crate::parser::combinators::take::take_until; use crate::parser::{ParseError, ParseInput, ParseResult}; pub(crate) fn geexpander(inp: RNode) -> RNode{ } pub(crate) fn genentityexpander<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> + 'static { move |input| { let e = delimited(tag("&"), take_until(";"), tag(";"))(input); match e { Err(usize) => Err(usize), Ok((mut input1, entitykey)) => { match input1.dtd.generalentities.get(&entitykey as &str) { Some(DTDDecl::GeneralEntity(_, v)) => { if input1.currententitydepth >= input1.maxentitydepth { //attempting to exceed expansion depth Err(ParseError::EntityDepth { col: input1.currentcol, row: input1.currentrow, }) } else { for ch in v.chars().rev() { input1.entityfeed.push(ch); } input1.currententitydepth += 1; Ok((input1, "".to_string())) } } None => Err(ParseError::MissingGenEntity { col: input1.currentcol, row: input1.currentrow, }), _ => Err(ParseError::Unknown { col: input1.currentcol, row: input1.currentrow, }), } } } } } pub(crate) fn paramentityexpander<N: Node>() -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, String), ParseError> + 'static { move |input| { let e = delimited(tag("%"), take_until(";"), tag(";"))(input); match e { Err(err) => Err(err), Ok((mut input1, entitykey)) => { match input1.dtd.paramentities.get(&entitykey as &str) { Some(DTDDecl::ParamEntity(_, v)) => { if input1.currententitydepth >= input1.maxentitydepth { //attempting to exceed expansion depth Err(ParseError::EntityDepth { col: input1.currentcol, row: input1.currentrow, }) } else { for ch in v.chars().rev() { input1.entityfeed.push(ch); } input1.currententitydepth += 1; Ok((input1, "".to_string())) } } None => Err(ParseError::MissingParamEntity { col: input1.currentcol, row: input1.currentrow, }), _ => Err(ParseError::Unknown { col: input1.currentcol, row: input1.currentrow, }), } } } } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/variables.rs
src/parser/xpath/variables.rs
//! Functions for handling variables. use crate::item::Node; use crate::parser::combinators::map::map_with_state; use crate::parser::combinators::pair::pair; use crate::parser::combinators::tag::tag; //use crate::parser::combinators::debug::inspect; use crate::parser::xpath::nodetests::qualname_test; use crate::parser::xpath::support::get_nt_localname; use crate::parser::{ParseError, ParseInput}; use crate::transform::{in_scope_namespaces, Transform}; // VarRef ::= '$' VarName pub(crate) fn variable_reference<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map_with_state( pair(tag("$"), qualname_test()), |(_, qn), state| { Transform::VariableReference( get_nt_localname(&qn), in_scope_namespaces(state.cur.clone()), ) }, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/support.rs
src/parser/xpath/support.rs
//! Supporting functions. use crate::item::Node; use crate::parser::{ParseError, ParseInput}; use crate::transform::{NameTest, NodeTest, Transform, WildcardOrName}; pub(crate) fn get_nt_localname(nt: &NodeTest) -> String { match nt { NodeTest::Name(NameTest { name: Some(WildcardOrName::Name(localpart)), ns: None, prefix: None, }) => localpart.to_string(), _ => String::from("invalid qname"), } } pub(crate) fn noop<N: Node>( ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> { move |_| Err(ParseError::Combinator) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/nodetests.rs
src/parser/xpath/nodetests.rs
//! Functions that produce tests for nodes. use crate::item::Node; use crate::parser::combinators::alt::{alt2, alt5}; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple3; use crate::parser::{ParseError, ParseInput}; use crate::transform::{KindTest, NameTest, NodeTest, WildcardOrName}; use std::rc::Rc; //use crate::parser::combinators::debug::inspect; use crate::parser::xml::qname::{ncname, qualname}; use crate::value::Value; pub(crate) fn qualname_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(alt2(prefixed_name(), unprefixed_name())) } fn unprefixed_name<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map(ncname(), |localpart| { NodeTest::Name(NameTest { ns: None, prefix: None, name: Some(WildcardOrName::Name(Rc::new(Value::from(localpart)))), }) })) } fn prefixed_name<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map( tuple3(ncname(), tag(":"), ncname()), |(prefix, _, localpart)| { NodeTest::Name(NameTest { ns: None, prefix: Some(Rc::new(Value::from(prefix))), name: Some(WildcardOrName::Name(Rc::new(Value::from(localpart)))), }) }, )) } // NodeTest ::= KindTest | NameTest // NameTest ::= EQName | Wildcard pub(crate) fn nodetest<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(alt2(kindtest(), nametest())) } // KindTest ::= DocumentTest | ElementTest | AttributeTest | SchemaElementTest | SchemaAttributeTest | PITest | CommentTest | TextTest | NamespaceNodeTest | AnyKindTest pub(crate) fn kindtest<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { // Need alt10 Box::new(alt2( alt5( document_test(), element_test(), attribute_test(), schema_element_test(), schema_attribute_test(), ), alt5( pi_test(), comment_test(), text_test(), namespace_node_test(), any_kind_test(), ), )) } // DocumentTest ::= "document-node" "(" ElementTest | SchemaElementTest ")" fn document_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { // TODO: ElementTest|SchemaElementTest Box::new(map(tag("document-node()"), |_| { NodeTest::Kind(KindTest::Document) })) } // ElementTest ::= "element" "(" (ElementNameOrWildcard ("," TypeName)?)? ")" fn element_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { // TODO: ElementTest|SchemaElementTest Box::new(map( tuple3( tag("element("), opt(map( alt2(map(qualname(), |_| ()), map(tag("*"), |_| ())), |_| (), )), tag(")"), ), |_| NodeTest::Kind(KindTest::Element), )) } // SchemaElementTest ::= "schema-element" "(" ElementNameDeclaration ")" fn schema_element_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { // TODO: ElementTest|SchemaElementTest Box::new(map( tuple3(tag("schema-element("), qualname(), tag(")")), |_| NodeTest::Kind(KindTest::SchemaElement), )) } // AttributeTest ::= "attribute" "(" (AttribNameOrWildcard ("," TypeName))? ")" fn attribute_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map( tuple3( tag("attribute("), opt(map( alt2(map(qualname(), |_| ()), map(tag("*"), |_| ())), |_| (), )), tag(")"), ), |_| NodeTest::Kind(KindTest::Attribute), )) } // SchemaAttributeTest ::= "attribute" "(" AttributeDeclaration ")" fn schema_attribute_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { // TODO: AttributeDeclaration Box::new(map( tuple3(tag("schema-attribute("), qualname(), tag(")")), |_| NodeTest::Kind(KindTest::SchemaAttribute), )) } // PITest ::= "processing-instruction" "(" (NCName | StringLiteral)? ")" fn pi_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { // TODO: NCName | StringLiteral Box::new(map(tag("processing-instruction()"), |_| { NodeTest::Kind(KindTest::PI) })) } // CommentTest ::= "comment" "(" ")" fn comment_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map(tag("comment()"), |_| NodeTest::Kind(KindTest::Comment))) } // TextTest ::= "text" "(" ")" fn text_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map(tag("text()"), |_| NodeTest::Kind(KindTest::Text))) } // NamespaceNodeTest ::= "namespace-node" "(" ")" fn namespace_node_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map(tag("namespace-node()"), |_| { NodeTest::Kind(KindTest::Namespace) })) } // NamespaceNodeTest ::= "namespace-node" "(" ")" fn any_kind_test<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map(tag("node()"), |_| NodeTest::Kind(KindTest::Any))) } // NameTest ::= EQName | Wildcard // TODO: allow EQName rather than QName fn nametest<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(alt2(qualname_test(), wildcard())) } // Wildcard ::= '*' | (NCName ':*') | ('*:' NCName) | (BracedURILiteral '*') // TODO: more specific wildcards fn wildcard<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, NodeTest), ParseError> + 'a> { Box::new(map(tag("*"), |_| { NodeTest::Name(NameTest { ns: Some(WildcardOrName::Wildcard), prefix: None, name: Some(WildcardOrName::Wildcard), }) })) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/functions.rs
src/parser/xpath/functions.rs
//! Functions for functions. use crate::item::Node; use crate::parser::combinators::alt::alt2; use crate::parser::combinators::list::separated_list0; use crate::parser::combinators::map::{map, map_with_state}; use crate::parser::combinators::opt::opt; use crate::parser::combinators::pair::pair; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::{tuple3, tuple6}; use crate::parser::combinators::whitespace::xpwhitespace; use std::rc::Rc; //use crate::parser::combinators::debug::inspect; use crate::parser::xml::qname::qualname; use crate::parser::xpath::expr_single_wrapper; use crate::parser::xpath::expressions::parenthesized_expr; use crate::parser::xpath::nodetests::qualname_test; use crate::parser::xpath::numbers::unary_expr; use crate::parser::{ParseError, ParseInput}; use crate::qname::QualifiedName; use crate::transform::callable::ActualParameters; use crate::transform::{in_scope_namespaces, NameTest, NodeTest, Transform, WildcardOrName}; use crate::xdmerror::ErrorKind; // ArrowExpr ::= UnaryExpr ( '=>' ArrowFunctionSpecifier ArgumentList)* pub(crate) fn arrow_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( unary_expr::<N>(), opt(tuple6( xpwhitespace(), tag("=>"), xpwhitespace(), arrowfunctionspecifier::<N>(), xpwhitespace(), opt(argumentlist::<N>()), )), ), |(v, o)| { if o.is_none() { v } else { Transform::NotImplemented("arrow_expr".to_string()) } }, )) } // ArrowFunctionSpecifier ::= EQName | VarRef | ParenthesizedExpr // TODO: finish this parser with EQName and VarRef fn arrowfunctionspecifier<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( alt2( map(qualname(), |_| ()), map(parenthesized_expr::<N>(), |_| ()), ), |_| Transform::NotImplemented("arrowfunctionspecifier".to_string()), )) } // FunctionCall ::= EQName ArgumentList pub(crate) fn function_call<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map_with_state( pair(qualname_test(), argumentlist::<N>()), |(qn, mut a), state| match qn { NodeTest::Name(NameTest { name: Some(WildcardOrName::Name(ref localpart)), ns: None, prefix: None, }) => match localpart.to_string().as_str() { "current" => Transform::CurrentItem, "position" => Transform::Position, "last" => Transform::Last, "count" => { if a.is_empty() { Transform::Count(Box::new(Transform::Empty)) } else if a.len() == 1 { Transform::Count(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "local-name" => { if a.is_empty() { Transform::LocalName(None) } else if a.len() == 1 { Transform::LocalName(Some(Box::new(a.pop().unwrap()))) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "name" => { if a.is_empty() { Transform::Name(None) } else if a.len() == 1 { Transform::Name(Some(Box::new(a.pop().unwrap()))) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "string" => { if a.len() == 1 { Transform::String(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "concat" => Transform::Concat(a), "starts-with" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::StartsWith(Box::new(c), Box::new(b)) } else { // Incorrect arguments Transform::Error(ErrorKind::ParseError, String::from("incorrect arguments")) } } "contains" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::Contains(Box::new(c), Box::new(b)) } else { // Incorrect arguments Transform::Error(ErrorKind::ParseError, String::from("incorrect arguments")) } } "substring" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::Substring(Box::new(c), Box::new(b), None) } else if a.len() == 3 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); let d = a.pop().unwrap(); Transform::Substring(Box::new(d), Box::new(c), Some(Box::new(b))) } else { // Wrong number of arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "substring-before" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::SubstringBefore(Box::new(c), Box::new(b)) } else { // Incorrect arguments Transform::Error(ErrorKind::ParseError, String::from("incorrect arguments")) } } "substring-after" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::SubstringAfter(Box::new(c), Box::new(b)) } else { // Incorrect arguments Transform::Error(ErrorKind::ParseError, String::from("incorrect arguments")) } } "normalize-space" => { if a.is_empty() { Transform::NormalizeSpace(None) } else if a.len() == 1 { Transform::NormalizeSpace(Some(Box::new(a.pop().unwrap()))) } else { // Wrong number of arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "translate" => { if a.len() == 3 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); let d = a.pop().unwrap(); Transform::Translate(Box::new(d), Box::new(c), Box::new(b)) } else { // Wrong number of arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "generate-id" => { if a.is_empty() { Transform::GenerateId(None) } else if a.len() == 1 { Transform::GenerateId(Some(Box::new(a.pop().unwrap()))) } else { // Wrong number of arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "boolean" => { if a.len() == 1 { Transform::Boolean(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "not" => { if a.len() == 1 { Transform::Not(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "true" => { if a.is_empty() { Transform::True } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "false" => { if a.is_empty() { Transform::False } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "number" => { if a.len() == 1 { Transform::Number(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "sum" => { if a.len() == 1 { Transform::Sum(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "avg" => { if a.len() == 0 { Transform::Empty } else if a.len() == 1 { Transform::Avg(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "min" => { if a.len() == 0 { Transform::Empty } else if a.len() == 1 { Transform::Min(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "max" => { if a.len() == 0 { Transform::Empty } else if a.len() == 1 { Transform::Max(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "floor" => { if a.len() == 1 { Transform::Floor(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "ceiling" => { if a.len() == 1 { Transform::Ceiling(Box::new(a.pop().unwrap())) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "round" => { if a.len() == 1 { let b = a.pop().unwrap(); Transform::Round(Box::new(b), None) } else if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::Round(Box::new(c), Some(Box::new(b))) } else { // Wrong number of arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "current-date-time" => { if a.is_empty() { Transform::CurrentDateTime } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "current-date" => { if a.is_empty() { Transform::CurrentDate } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "current-time" => { if a.is_empty() { Transform::CurrentTime } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "format-date-time" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::FormatDateTime(Box::new(c), Box::new(b), None, None, None) } else if a.len() == 5 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); let d = a.pop().unwrap(); let e = a.pop().unwrap(); let f = a.pop().unwrap(); Transform::FormatDateTime( Box::new(f), Box::new(e), Some(Box::new(d)), Some(Box::new(c)), Some(Box::new(b)), ) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "format-date" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::FormatDate(Box::new(c), Box::new(b), None, None, None) } else if a.len() == 5 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); let d = a.pop().unwrap(); let e = a.pop().unwrap(); let f = a.pop().unwrap(); Transform::FormatDate( Box::new(f), Box::new(e), Some(Box::new(d)), Some(Box::new(c)), Some(Box::new(b)), ) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "format-time" => { if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::FormatTime(Box::new(c), Box::new(b), None, None, None) } else if a.len() == 5 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); let d = a.pop().unwrap(); let e = a.pop().unwrap(); let f = a.pop().unwrap(); Transform::FormatTime( Box::new(f), Box::new(e), Some(Box::new(d)), Some(Box::new(c)), Some(Box::new(b)), ) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "format-number" => { if a.is_empty() || a.len() == 1 { // Too few arguments Transform::Error(ErrorKind::ParseError, String::from("too few arguments")) } else if a.len() == 2 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); Transform::FormatNumber(Box::new(c), Box::new(b), None) } else if a.len() == 3 { let b = a.pop().unwrap(); let c = a.pop().unwrap(); let d = a.pop().unwrap(); Transform::FormatNumber(Box::new(d), Box::new(c), Some(Box::new(b))) } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "current-group" => { if a.is_empty() { Transform::CurrentGroup } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "current-grouping-key" => { if a.is_empty() { Transform::CurrentGroupingKey } else { // Too many arguments Transform::Error(ErrorKind::ParseError, String::from("too many arguments")) } } "key" => { if a.len() == 2 { let m = a.pop().unwrap(); let name = a.pop().unwrap(); Transform::Key( Box::new(name), Box::new(m), None, in_scope_namespaces(state.cur.clone()), ) } else if a.len() == 3 { let u = a.pop().unwrap(); let m = a.pop().unwrap(); let name = a.pop().unwrap(); Transform::Key( Box::new(name), Box::new(m), Some(Box::new(u)), in_scope_namespaces(state.cur.clone()), ) } else { // Wrong # arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "system-property" => { if a.len() == 1 { let p = a.pop().unwrap(); Transform::SystemProperty( Box::new(p), in_scope_namespaces(state.cur.clone()), ) } else { // Wrong # arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "available-system-properties" => { if a.is_empty() { Transform::AvailableSystemProperties } else { // Wrong # arguments Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ) } } "document" => match a.len() { 0 => Transform::Document(Box::new(Transform::Empty), None), 1 => { let u = a.pop().unwrap(); Transform::Document(Box::new(u), None) } 2 => { let b = a.pop().unwrap(); let u = a.pop().unwrap(); Transform::Document(Box::new(u), Some(Box::new(b))) } _ => Transform::Error( ErrorKind::ParseError, String::from("wrong number of arguments"), ), }, _ => Transform::Error( ErrorKind::ParseError, format!("undefined function \"{}\"", qn), ), // TODO: user-defined functions }, NodeTest::Name(NameTest { name: Some(WildcardOrName::Name(localpart)), ns: Some(WildcardOrName::Name(nsuri)), prefix: p, }) => Transform::Invoke( Rc::new(QualifiedName::new_from_values(Some(nsuri), p, localpart)), ActualParameters::Positional(a), in_scope_namespaces(state.cur.clone()), ), NodeTest::Name(NameTest { name: Some(WildcardOrName::Name(localpart)), ns: None, prefix: p, }) => Transform::Invoke( Rc::new(QualifiedName::new_from_values(None, p, localpart)), ActualParameters::Positional(a), in_scope_namespaces(state.cur.clone()), ), _ => Transform::Error(ErrorKind::Unknown, format!("unknown function \"{}\"", qn)), }, )) } // ArgumentList ::= '(' (Argument (',' Argument)*)? ')' // TODO: finish this parser with actual arguments fn argumentlist<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<Transform<N>>), ParseError> + 'a> { Box::new(map( tuple3( tag("("), separated_list0( map(tuple3(xpwhitespace(), tag(","), xpwhitespace()), |_| ()), argument::<N>(), ), tag(")"), ), |(_, a, _)| a, )) } // Argument ::= ExprSingle | ArgumentPlaceHolder // TODO: ArgumentPlaceHolder fn argument<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(expr_single_wrapper::<N>(true)) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/predicates.rs
src/parser/xpath/predicates.rs
//! Support for predicates use crate::item::Node; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple3; use crate::parser::combinators::whitespace::xpwhitespace; use crate::parser::{ParseError, ParseInput}; use crate::transform::Transform; //use crate::parser::combinators::debug::inspect; use crate::parser::xpath::expr_wrapper; // PredicateList ::= Predicate* pub(crate) fn predicate_list<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(many0(predicate::<N>()), |v| Transform::Compose(v))) } // Predicate ::= "[" expr "]" fn predicate<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( tuple3( map(tuple3(xpwhitespace(), tag("["), xpwhitespace()), |_| ()), expr_wrapper::<N>(true), map(tuple3(xpwhitespace(), tag("]"), xpwhitespace()), |_| ()), ), |(_, e, _)| Transform::Filter(Box::new(e)), )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/types.rs
src/parser/xpath/types.rs
//! Functions that manipulate type information use crate::item::Node; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::pair::pair; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple6; use crate::parser::combinators::whitespace::xpwhitespace; use crate::parser::xpath::functions::arrow_expr; use crate::parser::xpath::nodetests::qualname_test; use crate::parser::{ParseError, ParseInput}; use crate::transform::Transform; // InstanceOfExpr ::= TreatExpr ( 'instance' 'of' SequenceType)? pub(crate) fn instanceof_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( treat_expr::<N>(), opt(tuple6( xpwhitespace(), tag("instance"), xpwhitespace(), tag("of"), xpwhitespace(), sequencetype_expr::<N>(), )), ), |(v, o)| { if o.is_none() { v } else { Transform::NotImplemented("instanceof_expr".to_string()) } }, )) } // SequenceType ::= ( 'empty-sequence' '(' ')' | (ItemType OccurrenceIndicator?) // TODO: implement this parser fully fn sequencetype_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(tag("empty-sequence()"), |_| { Transform::NotImplemented("sequencetype_expr".to_string()) })) } // TreatExpr ::= CastableExpr ( 'treat' 'as' SequenceType)? fn treat_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( castable_expr::<N>(), opt(tuple6( xpwhitespace(), tag("treat"), xpwhitespace(), tag("as"), xpwhitespace(), sequencetype_expr::<N>(), )), ), |(v, o)| { if o.is_none() { v } else { Transform::NotImplemented("treat_expr".to_string()) } }, )) } // CastableExpr ::= CastExpr ( 'castable' 'as' SingleType)? fn castable_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( cast_expr::<N>(), opt(tuple6( xpwhitespace(), tag("castable"), xpwhitespace(), tag("as"), xpwhitespace(), singletype_expr::<N>(), )), ), |(v, o)| { if o.is_none() { v } else { Transform::NotImplemented("castable_expr".to_string()) } }, )) } // SingleType ::= SimpleTypeName '?'? // SimpleTypeName ::= TypeName // TypeName ::= EQName // EQName ::= QName | URIQualifiedName // URIQualifiedName ::= BracedURILiteral NCName // QName ::= PrefixedName | UnprefixedName // PrefixedName ::= Prefix ':' LocalPart // UnprefixedName ::= LocalPart // Prefix ::= NCName // LocalPart ::= NCName // NCName ::= Name - (Char* ':' Char*) // Char ::= #x9 | #xA |#xD | [#x20-#xD7FF] | [#xE000-#xFFFD | [#x10000-#x10FFFF] // TODO: implement this parser fully fn singletype_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(pair(qualname_test(), tag("?")), |_| { Transform::NotImplemented("singletype_expr".to_string()) })) } // CastExpr ::= ArrowExpr ( 'cast' 'as' SingleType)? fn cast_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( arrow_expr::<N>(), opt(tuple6( xpwhitespace(), tag("cast"), xpwhitespace(), tag("as"), xpwhitespace(), singletype_expr::<N>(), )), ), |(v, o)| { if o.is_none() { v } else { Transform::NotImplemented("cast_expr".to_string()) } }, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/mod.rs
src/parser/xpath/mod.rs
/*! # Parse XPath expressions An XPath expression parser using the xrust parser combinator that produces a xrust transformation. ```rust use xrust::parser::xpath::parse; # use xrust::item::Node; # fn do_parse<N: Node>() { let t = parse::<N>("/child::A/child::B/child::C", None).expect("unable to parse XPath expression"); # } ``` "t" now contains a [Transform] that will return "C" elements that have a "B" parent and an "A" grandparent in the source document. To evaluate the transformation we need a Context with a source document as its current item. ```rust # use std::rc::Rc; # use xrust::xdmerror::{Error, ErrorKind}; use xrust::item::{Sequence, SequenceTrait, Item, Node, NodeType}; use xrust::trees::smite::RNode; use xrust::parser::xml::parse as xmlparse; use xrust::parser::xpath::parse; use xrust::transform::context::{Context, ContextBuilder, StaticContext, StaticContextBuilder}; let t = parse("/child::A/child::B/child::C", None) .expect("unable to parse XPath expression"); let source = RNode::new_document(); xmlparse(source.clone(), "<A><B><C/></B><B><C/></B></A>", None) .expect("unable to parse XML"); let mut static_context = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Ok(String::new())) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let context = ContextBuilder::new() .context(vec![Item::Node(source)]) .build(); let sequence = context.dispatch(&mut static_context, &t) .expect("evaluation failed"); assert_eq!(sequence.len(), 2); assert_eq!(sequence.to_xml(), "<C></C><C></C>") ``` */ mod compare; mod context; mod expressions; mod flwr; mod functions; pub(crate) mod literals; mod logic; mod nodes; pub(crate) mod nodetests; mod numbers; pub(crate) mod predicates; mod strings; pub(crate) mod support; mod types; pub(crate) mod variables; use crate::parser::combinators::alt::alt4; use crate::parser::combinators::list::separated_list1; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple3; use crate::parser::combinators::whitespace::xpwhitespace; //use crate::parser::combinators::debug::inspect; use crate::parser::xpath::flwr::{for_expr, if_expr, let_expr}; use crate::parser::xpath::logic::or_expr; use crate::parser::xpath::support::noop; use crate::parser::{ParseError, ParseInput, ParserState}; use crate::item::Node; use crate::transform::Transform; use crate::xdmerror::{Error, ErrorKind}; /// Parse an XPath expression to produce a [Transform]. The optional [Node] is used to resolve XML Namespaces. pub fn parse<N: Node>(input: &str, n: Option<N>) -> Result<Transform<N>, Error> { // Shortcut for empty if input.is_empty() { return Ok(Transform::Empty); } let state = ParserState::new(None, n, None); match xpath_expr((input, state)) { Ok((_, x)) => Ok(x), Err(err) => match err { ParseError::Combinator => Err(Error::new( ErrorKind::ParseError, format!( "Unrecoverable parser error while parsing XPath expression \"{}\"", input ), )), ParseError::NotWellFormed(e) => Err(Error::new( ErrorKind::ParseError, format!("Unrecognised extra characters: \"{}\"", e), )), ParseError::MissingNameSpace => Err(Error::new( ErrorKind::ParseError, "Missing namespace declaration.".to_string(), )), ParseError::Notimplemented => Err(Error::new( ErrorKind::ParseError, "Unimplemented feature.".to_string(), )), _ => Err(Error::new(ErrorKind::Unknown, "Unknown error".to_string())), }, } } fn xpath_expr<N: Node>(input: ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> { match expr::<N>()(input) { Err(err) => Err(err), Ok(((input1, state1), e)) => { //Check nothing remaining in iterator, nothing after the end of the root node. if input1.is_empty() { Ok(((input1, state1), e)) } else { Err(ParseError::NotWellFormed(format!( "Unrecognised extra characters: \"{}\"", input1 ))) } } } } // Implementation note: cannot use opaque type because XPath expressions are recursive, and Rust *really* doesn't like recursive opaque types. Dynamic trait objects aren't ideal, but compiling XPath expressions is a one-off operation so that shouldn't cause a major performance issue. // Implementation note 2: since XPath is recursive, must lazily evaluate arguments to avoid stack overflow. pub fn expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( separated_list1( map(tuple3(xpwhitespace(), tag(","), xpwhitespace()), |_| ()), expr_single::<N>(), ), |mut v| { if v.len() == 1 { v.pop().unwrap() } else { Transform::SequenceItems(v) } }, )) } pub(crate) fn expr_wrapper<N: Node>( b: bool, ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError>> { Box::new(move |input| { if b { expr::<N>()(input) } else { noop::<N>()(input) } }) } // ExprSingle ::= ForExpr | LetExpr | QuantifiedExpr | IfExpr | OrExpr fn expr_single<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt4(let_expr(), for_expr(), if_expr(), or_expr())) } pub(crate) fn expr_single_wrapper<N: Node>( b: bool, ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError>> { Box::new(move |input| { if b { expr_single::<N>()(input) } else { noop::<N>()(input) } }) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/numbers.rs
src/parser/xpath/numbers.rs
//! Functions that produce numbers. use crate::item::Node; use crate::parser::combinators::alt::{alt2, alt4}; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::pair::pair; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::{tuple2, tuple3}; use crate::parser::combinators::whitespace::xpwhitespace; use crate::parser::xpath::nodes::{path_expr, union_expr}; use crate::parser::{ParseError, ParseInput}; use crate::transform::{ArithmeticOperand, ArithmeticOperator, Transform}; // RangeExpr ::= AdditiveExpr ( 'to' AdditiveExpr)? pub(crate) fn range_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( additive_expr::<N>(), opt(tuple2( tuple3(xpwhitespace(), tag("to"), xpwhitespace()), additive_expr::<N>(), )), ), |(v, o)| match o { None => v, Some((_, u)) => Transform::Range(Box::new(v), Box::new(u)), }, )) } // AdditiveExpr ::= MultiplicativeExpr ( ('+' | '-') MultiplicativeExpr)* fn additive_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( multiplicative_expr::<N>(), many0(tuple2( alt2( map( tuple3( xpwhitespace(), map(tag("+"), |_| ArithmeticOperator::Add), xpwhitespace(), ), |(_, x, _)| x, ), map( tuple3( xpwhitespace(), map(tag("-"), |_| ArithmeticOperator::Subtract), xpwhitespace(), ), |(_, x, _)| x, ), ), multiplicative_expr::<N>(), )), ), |(mut a, b)| { if b.is_empty() { if a.len() == 1 { let c: ArithmeticOperand<N> = a.pop().unwrap(); c.operand } else { Transform::Arithmetic(a) } } else { let mut e: Vec<ArithmeticOperand<N>> = b .iter() .map(|(c, d)| ArithmeticOperand::new(*c, Transform::Arithmetic(d.clone()))) .collect(); a.append(&mut e); Transform::Arithmetic(a) } }, )) } // MultiplicativeExpr ::= UnionExpr ( ('*' | 'div' | 'idiv' | 'mod') UnionExpr)* fn multiplicative_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<ArithmeticOperand<N>>), ParseError> + 'a> { Box::new(map( pair( union_expr::<N>(), many0(tuple2( alt4( tuple3(xpwhitespace(), map(tag("*"), |_| "*"), xpwhitespace()), tuple3(xpwhitespace(), map(tag("div"), |_| "div"), xpwhitespace()), tuple3(xpwhitespace(), map(tag("idiv"), |_| "idiv"), xpwhitespace()), tuple3(xpwhitespace(), map(tag("mod"), |_| "mod"), xpwhitespace()), ), union_expr::<N>(), )), ), |(a, b)| { if b.is_empty() { vec![ArithmeticOperand::new(ArithmeticOperator::Noop, a)] } else { // The arguments to the constructor are the items to be summed // These are pair-wise items: first is the operator, // second is the combinator for the value let mut r: Vec<ArithmeticOperand<N>> = Vec::new(); r.push(ArithmeticOperand::new(ArithmeticOperator::Noop, a)); for ((_, c, _), d) in b { r.push(ArithmeticOperand::new(ArithmeticOperator::from(c), d)) } r } }, )) } // UnaryExpr ::= ('-' | '+')* ValueExpr pub(crate) fn unary_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair(many0(alt2(tag("-"), tag("+"))), value_expr::<N>()), |(u, v)| { if u.is_empty() { v } else { Transform::NotImplemented("unary_expr".to_string()) } }, )) } // ValueExpr (SBox<dyneMapExpr) ::= PathExpr ('!' PathExpr)* fn value_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair(path_expr::<N>(), many0(tuple2(tag("!"), path_expr::<N>()))), |(u, v)| { if v.is_empty() { u } else { Transform::NotImplemented("value_expr".to_string()) } }, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/nodes.rs
src/parser/xpath/nodes.rs
//! Functions that produces nodes, or sets of nodes. use crate::item::Node; use crate::parser::combinators::alt::{alt2, alt3, alt4, alt5}; use crate::parser::combinators::debug::inspect; use crate::parser::combinators::list::separated_list1; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::pair::pair; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::{tuple2, tuple3}; use crate::parser::combinators::whitespace::xpwhitespace; use crate::parser::xpath::expressions::postfix_expr; use crate::parser::xpath::nodetests::{kindtest, nodetest}; use crate::parser::xpath::predicates::predicate_list; use crate::parser::xpath::types::instanceof_expr; use crate::parser::{ParseError, ParseInput}; use crate::transform::{Axis, KindTest, NameTest, NodeMatch, NodeTest, Transform, WildcardOrName}; // UnionExpr ::= IntersectExceptExpr ( ('union' | '|') IntersectExceptExpr)* pub(crate) fn union_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( separated_list1( map( tuple3(xpwhitespace(), alt2(tag("union"), tag("|")), xpwhitespace()), |_| (), ), intersectexcept_expr::<N>(), ), |mut v| { if v.len() == 1 { v.pop().unwrap() } else { Transform::Union(v) } }, )) } // IntersectExceptExpr ::= InstanceOfExpr ( ('intersect' | 'except') InstanceOfExpr)* fn intersectexcept_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( instanceof_expr::<N>(), many0(tuple2( tuple3( xpwhitespace(), alt2(tag("intersect"), tag("except")), xpwhitespace(), ), instanceof_expr::<N>(), )), ), |(v, o)| { if o.is_empty() { v } else { Transform::NotImplemented("intersectexcept_expr".to_string()) } }, )) } pub(crate) fn path_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt3( absolutedescendant_expr::<N>(), absolutepath_expr::<N>(), relativepath_expr::<N>(), )) } // ('//' RelativePathExpr?) fn absolutedescendant_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(pair(tag("//"), relativepath_expr::<N>()), |(_, r)| { Transform::Compose(vec![ Transform::Step(NodeMatch { axis: Axis::DescendantOrSelfOrRoot, nodetest: NodeTest::Name(NameTest { ns: None, prefix: None, name: Some(WildcardOrName::Wildcard), }), }), r, ]) })) } // ('/' RelativePathExpr?) fn absolutepath_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair(tag("/"), opt(relativepath_expr::<N>())), |(_, r)| match r { Some(a) => Transform::Compose(vec![Transform::Root, a]), None => Transform::Root, }, )) } // RelativePathExpr ::= StepExpr (('/' | '//') StepExpr)* fn relativepath_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( step_expr::<N>(), many0(tuple2( alt2( map(tuple3(xpwhitespace(), tag("//"), xpwhitespace()), |_| "//"), map(tuple3(xpwhitespace(), tag("/"), xpwhitespace()), |_| "/"), ), step_expr::<N>(), )), ), |(a, b)| { if b.is_empty() { a } else { let mut r = Vec::new(); r.push(a); for (s, c) in b { match s { "/" => r.push(c), "//" => { // Insert a descendant-or-self::* step r.push(Transform::Step(NodeMatch { axis: Axis::DescendantOrSelf, nodetest: NodeTest::Name(NameTest { ns: None, prefix: None, name: Some(WildcardOrName::Wildcard), }), })); r.push(c) } _ => panic!("unexpected"), } } Transform::Compose(r) } }, )) } // StepExpr ::= PostfixExpr | AxisStep fn step_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt4( abbreviated_parent::<N>(), inspect("kindtest", abbreviated_kindtest::<N>()), postfix_expr::<N>(), axisstep::<N>(), )) } // AxisStep ::= (ReverseStep | ForwardStep) PredicateList fn axisstep<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( alt2( pair(alt2(forwardaxis(), reverseaxis()), nodetest()), pair(abbreviated_axisstep(), nodetest()), ), predicate_list(), ), |((a, n), pl)| { Transform::Compose(vec![ Transform::Step(NodeMatch { axis: Axis::from(a), nodetest: n, }), pl, ]) }, )) } fn abbreviated_parent<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(tag(".."), |_| { Transform::Step(NodeMatch::new(Axis::Parent, NodeTest::Kind(KindTest::Any))) })) } fn abbreviated_kindtest<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(pair(abbreviated_axisstep(), kindtest()), |(a, n)| { Transform::Step(NodeMatch { axis: Axis::from(a), nodetest: n, }) })) } fn abbreviated_axisstep<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, &'static str), ParseError> + 'a> { Box::new(no_input("child")) } pub fn no_input<'a, A: Clone + 'a, N: Node>( val: A, ) -> impl Fn(ParseInput<N>) -> Result<(ParseInput<N>, A), ParseError> + 'a { move |input| Ok((input, val.clone())) } // ForwardAxis ::= ('child' | 'descendant' | 'attribute' | 'self' | 'descendant-or-self' | 'following-sibling' | 'following' | 'namespace') '::' fn forwardaxis<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, &'static str), ParseError> + 'a> { Box::new(alt2( // alt8( map( pair( // need alt8 alt2( alt4( map(tag("child"), |_| "child"), map(tag("descendant"), |_| "descendant"), map(tag("descendant-or-self"), |_| "descendant-or-self"), map(tag("attribute"), |_| "attribute"), ), alt4( map(tag("self"), |_| "self"), map(tag("following"), |_| "following"), map(tag("following-sibling"), |_| "following-sibling"), map(tag("namespace"), |_| "namespace"), ), ), tag("::"), ), |(a, _)| a, ), map(tag("@"), |_| "attribute"), )) } // ReverseAxis ::= ('parent' | 'ancestor' | 'ancestor-or-self' | 'preceding-sibling' | 'preceding' ) '::' fn reverseaxis<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, &'static str), ParseError> + 'a> { Box::new(map( // alt8( pair( // need alt8 alt5( map(tag("parent"), |_| "parent"), map(tag("ancestor"), |_| "ancestor"), map(tag("ancestor-or-self"), |_| "ancestor-or-self"), map(tag("preceding"), |_| "preceding"), map(tag("preceding-sibling"), |_| "preceding-sibling"), ), tag("::"), ), |(a, _)| a, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/flwr.rs
src/parser/xpath/flwr.rs
//! XPath FLWR expressions. use crate::item::Node; use crate::parser::combinators::list::separated_list1; use crate::parser::combinators::map::{map, map_with_state}; use crate::parser::combinators::pair::pair; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::{tuple10, tuple3, tuple5, tuple6}; use crate::parser::combinators::whitespace::xpwhitespace; //use crate::parser::combinators::debug::inspect; use crate::parser::xpath::nodetests::qualname_test; use crate::parser::xpath::support::get_nt_localname; use crate::parser::xpath::{expr_single_wrapper, expr_wrapper}; use crate::parser::{ParseError, ParseInput}; use crate::transform::{in_scope_namespaces, Transform}; // IfExpr ::= 'if' '(' Expr ')' 'then' ExprSingle 'else' ExprSingle pub(crate) fn if_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( // need tuple15 tuple10( tag("if"), xpwhitespace(), tag("("), xpwhitespace(), expr_wrapper::<N>(true), xpwhitespace(), tag(")"), xpwhitespace(), tag("then"), xpwhitespace(), ), tuple5( expr_single_wrapper::<N>(true), xpwhitespace(), tag("else"), xpwhitespace(), expr_single_wrapper::<N>(true), ), ), |((_, _, _, _, i, _, _, _, _, _), (t, _, _, _, e))| { Transform::Switch(vec![(i, t)], Box::new(e)) }, )) } // ForExpr ::= SimpleForClause 'return' ExprSingle pub(crate) fn for_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( tuple3( simple_for_clause::<N>(), tuple3(xpwhitespace(), tag("return"), xpwhitespace()), expr_single_wrapper::<N>(true), ), |(f, _, e)| Transform::Loop(f, Box::new(e)), // tc_loop does not yet support multiple variable bindings )) } // SimpleForClause ::= 'for' SimpleForBinding (',' SimpleForBinding)* // SimpleForBinding ::= '$' VarName 'in' ExprSingle fn simple_for_clause<'a, N: Node + 'a>() -> Box< dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<(String, Transform<N>)>), ParseError> + 'a, > { Box::new(map( tuple3( tag("for"), xpwhitespace(), separated_list1( map(tuple3(xpwhitespace(), tag(","), xpwhitespace()), |_| ()), map( tuple6( tag("$"), qualname_test(), xpwhitespace(), tag("in"), xpwhitespace(), expr_single_wrapper::<N>(true), ), |(_, qn, _, _, _, e)| (get_nt_localname(&qn), e), ), ), ), |(_, _, v)| v, )) } // LetExpr ::= SimpleLetClause 'return' ExprSingle pub(crate) fn let_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map_with_state( tuple3( simple_let_clause::<N>(), tuple3(xpwhitespace(), tag("return"), xpwhitespace()), expr_single_wrapper::<N>(true), ), |(mut v, _, e), state| { let (qn, f) = v.pop().unwrap(); let mut result = Transform::VariableDeclaration( qn, Box::new(f), Box::new(e), in_scope_namespaces(state.cur.clone()), ); loop { if v.is_empty() { break; } else { let (qn, f) = v.pop().unwrap(); let inter = Transform::VariableDeclaration( qn, Box::new(f), Box::new(result), in_scope_namespaces(state.cur.clone()), ); result = inter; } } result }, )) } // SimpleLetClause ::= 'let' SimpleLetBinding (',' SimpleLetBinding)* // SimpleLetBinding ::= '$' VarName ':=' ExprSingle // TODO: handle multiple bindings fn simple_let_clause<'a, N: Node + 'a>() -> Box< dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Vec<(String, Transform<N>)>), ParseError> + 'a, > { Box::new(map( tuple3( tag("let"), xpwhitespace(), separated_list1( map(tuple3(xpwhitespace(), tag(","), xpwhitespace()), |_| ()), map( tuple6( tag("$"), qualname_test(), xpwhitespace(), tag(":="), xpwhitespace(), expr_single_wrapper::<N>(true), ), |(_, qn, _, _, _, e)| (get_nt_localname(&qn), e), ), ), ), |(_, _, v)| v, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/strings.rs
src/parser/xpath/strings.rs
//! Functions that produce strings. use crate::item::Node; use crate::parser::combinators::list::separated_list1; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple3; use crate::parser::combinators::whitespace::xpwhitespace; use crate::parser::xpath::numbers::range_expr; use crate::parser::{ParseError, ParseInput}; use crate::transform::Transform; // StringConcatExpr ::= RangeExpr ( '||' RangeExpr)* pub(crate) fn stringconcat_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( separated_list1( map(tuple3(xpwhitespace(), tag("||"), xpwhitespace()), |_| ()), range_expr::<N>(), ), |mut v| { if v.len() == 1 { v.pop().unwrap() } else { Transform::Concat(v) } }, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/context.rs
src/parser/xpath/context.rs
//! Functions that manipulate the context. use crate::item::Node; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::{ParseError, ParseInput}; use crate::transform::Transform; // ContextItemExpr ::= '.' pub(crate) fn context_item<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(tag("."), |_| Transform::ContextItem)) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/literals.rs
src/parser/xpath/literals.rs
//! Functions that produce literal values or nodes. use std::rc::Rc; use std::str::FromStr; use crate::item::{Item, Node}; use crate::parser::combinators::alt::{alt2, alt3}; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::many::many0; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::pair::pair; use crate::parser::combinators::support::{digit0, digit1, none_of}; use crate::parser::combinators::tag::{anychar, tag}; use crate::parser::combinators::tuple::{tuple3, tuple4}; use crate::parser::{ParseError, ParseInput}; use crate::transform::Transform; use crate::value::Value; use rust_decimal::Decimal; // Literal ::= NumericLiteral | StringLiteral pub(crate) fn literal<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt2(numeric_literal::<N>(), string_literal::<N>())) } // NumericLiteral ::= IntegerLiteral | DecimalLiteral | DoubleLiteral fn numeric_literal<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt3( double_literal::<N>(), decimal_literal::<N>(), integer_literal::<N>(), )) } // IntegerLiteral ::= Digits fn integer_literal<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(digit1(), |s: String| { let n = s.parse::<i64>().unwrap(); Transform::Literal(Item::Value(Rc::new(Value::Integer(n)))) })) } // DecimalLiteral ::= ('.' Digits) | (Digits '.' [0-9]*) // Construct a double, but if that fails fall back to decimal fn decimal_literal<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt2( decimal_literal_frac::<N>(), decimal_literal_comp::<N>(), )) } fn decimal_literal_frac<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(pair(tag("."), digit1()), |(_, mut f)| { f.insert(0, '.'); let n = f.parse::<f64>(); let i = match n { Ok(m) => Value::Double(m), Err(_) => { f.insert_str(0, "0"); Value::Decimal(Decimal::from_str(&f).unwrap()) } }; Transform::Literal(Item::Value(Rc::new(i))) })) } fn decimal_literal_comp<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(tuple3(digit1(), tag("."), digit0()), |(w, _, f)| { let s = format!("{}.{}", w, f); let n = s.parse::<f64>(); let i = match n { Ok(m) => Value::Double(m), Err(_) => Value::Decimal(Decimal::from_str(&s).unwrap()), }; Transform::Literal(Item::Value(Rc::new(i))) })) } // DoubleLiteral ::= (('.' Digits) | (Digits ('.' [0-9]*)?)) [eE] [+-]? Digits // Construct a double fn double_literal<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt2(double_literal_frac::<N>(), double_literal_comp::<N>())) } fn double_literal_frac<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( tuple4( pair(tag("."), digit1()), alt2(tag("e"), tag("E")), opt(alt2(map(tag("+"), |_| "+"), map(tag("-"), |_| "-"))), digit1(), ), |((_, f), _, s, e)| { let n = format!("0.{}e{}{}", f, s.unwrap_or(""), e).parse::<f64>(); let i = match n { Ok(m) => Value::Double(m), Err(_) => panic!("unable to convert to double"), }; Transform::Literal(Item::Value(Rc::new(i))) }, )) } fn double_literal_comp<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( tuple4( tuple3(digit1(), tag("."), digit1()), alt2(tag("e"), tag("E")), opt(alt2(map(tag("+"), |_| "+"), map(tag("-"), |_| "-"))), digit1(), ), |((c, _, f), _, s, e)| { let n = format!("{}.{}e{}{}", c, f, s.unwrap_or(""), e).parse::<f64>(); let i = match n { Ok(m) => Value::Double(m), Err(_) => panic!("unable to convert to double"), }; Transform::Literal(Item::Value(Rc::new(i))) }, )) } // StringLiteral ::= double- or single-quote delimited with double-delimiter escape fn string_literal_double<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( delimited( anychar('"'), map(many0(alt2(map(tag("\"\""), |_| '"'), none_of("\""))), |v| { v.iter().collect::<String>() }), anychar('"'), ), |s| Transform::Literal(Item::Value(Rc::new(Value::from(s)))), )) } fn string_literal_single<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( delimited( anychar('\''), map(many0(alt2(map(tag("''"), |_| '\''), none_of("'"))), |v| { v.iter().collect::<String>() }), anychar('\''), ), |s| Transform::Literal(Item::Value(Rc::new(Value::from(s)))), )) } fn string_literal<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt2( string_literal_double::<N>(), string_literal_single::<N>(), )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/logic.rs
src/parser/xpath/logic.rs
//! Logic expressions in XPath. use crate::item::Node; use crate::parser::combinators::list::separated_list1; use crate::parser::combinators::map::map; use crate::parser::combinators::tag::tag; use crate::parser::combinators::tuple::tuple3; use crate::parser::combinators::whitespace::xpwhitespace; use crate::parser::xpath::compare::comparison_expr; use crate::parser::{ParseError, ParseInput}; use crate::transform::Transform; // OrExpr ::= AndExpr ('or' AndExpr)* pub(crate) fn or_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( separated_list1( map(tuple3(xpwhitespace(), tag("or"), xpwhitespace()), |_| ()), and_expr::<N>(), ), |mut v| { if v.len() == 1 { v.pop().unwrap() } else { Transform::Or(v) } }, )) } // AndExpr ::= ComparisonExpr ('and' ComparisonExpr)* fn and_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( separated_list1( map(tuple3(xpwhitespace(), tag("and"), xpwhitespace()), |_| ()), comparison_expr::<N>(), ), |mut v| { if v.len() == 1 { v.pop().unwrap() } else { Transform::And(v) } }, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/compare.rs
src/parser/xpath/compare.rs
//! Functions that produce comparisons. use crate::item::Node; use crate::parser::combinators::map::map; use crate::parser::combinators::opt::opt; use crate::parser::combinators::pair::pair; use crate::parser::combinators::tag::anytag; use crate::parser::combinators::tuple::tuple3; use crate::parser::combinators::whitespace::xpwhitespace; use crate::parser::xpath::strings::stringconcat_expr; use crate::parser::{ParseError, ParseInput}; use crate::transform::Transform; use crate::value::Operator; // ComparisonExpr ::= StringConcatExpr ( (ValueComp | GeneralComp | NodeComp) StringConcatExpr)? pub(crate) fn comparison_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map( pair( stringconcat_expr::<N>(), opt(pair( tuple3( xpwhitespace(), anytag(vec![ "=", "!=", "<", "<=", "<<", ">", ">=", ">>", "eq", "ne", "lt", "le", "gt", "ge", "is", ]), xpwhitespace(), ), stringconcat_expr::<N>(), )), ), |(v, o)| match o { None => v, Some(((_, b, _), t)) => { match b.as_str() { "=" | "!=" | "<" | "<=" | ">" | ">=" => { Transform::GeneralComparison(Operator::from(b), Box::new(v), Box::new(t)) } "eq" | "ne" | "lt" | "le" | "gt" | "ge" | "is" | "<<" | ">>" => { Transform::ValueComparison(Operator::from(b), Box::new(v), Box::new(t)) } _ => Transform::Empty, // error } } }, )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/src/parser/xpath/expressions.rs
src/parser/xpath/expressions.rs
//! General productions for XPath expressions. use crate::item::Node; use crate::parser::combinators::alt::{alt2, alt5}; use crate::parser::combinators::map::map; use crate::parser::{ParseError, ParseInput}; //use crate::parser::combinators::debug::inspect; use crate::parser::combinators::delimited::delimited; use crate::parser::combinators::tag::tag; use crate::parser::xpath::context::context_item; use crate::parser::xpath::expr_wrapper; use crate::parser::xpath::functions::function_call; use crate::parser::xpath::literals::literal; use crate::parser::xpath::variables::variable_reference; use crate::transform::Transform; // PostfixExpr ::= PrimaryExpr (Predicate | ArgumentList | Lookup)* // TODO: predicates, arg list, lookup pub(crate) fn postfix_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(primary_expr::<N>()) } // PrimaryExpr ::= Literal | VarRef | ParenthesizedExpr | ContextItemExpr | FunctionCall | FunctionItemExpr | MapConstructor | ArrayConstructor | UnaryLookup // TODO: finish this parser fn primary_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt5( literal::<N>(), parenthesized_expr::<N>(), function_call::<N>(), variable_reference::<N>(), context_item::<N>(), )) } // ParenthesizedExpr ::= '(' Expr? ')' pub(crate) fn parenthesized_expr<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(alt2( parenthesized_expr_empty::<N>(), parenthesized_expr_nonempty::<N>(), )) } fn parenthesized_expr_empty<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(map(tag("()"), |_| Transform::Empty)) } fn parenthesized_expr_nonempty<'a, N: Node + 'a>( ) -> Box<dyn Fn(ParseInput<N>) -> Result<(ParseInput<N>, Transform<N>), ParseError> + 'a> { Box::new(delimited( tag("("), map(expr_wrapper::<N>(true), |e| e), tag(")"), )) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/smite-xslt.rs
tests/smite-xslt.rs
mod smite; mod xsltgeneric; // XSLT tests #[test] fn xslt_literal_text() { xsltgeneric::generic_literal_text( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_sys_prop() { xsltgeneric::generic_sys_prop( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_value_of_1() { xsltgeneric::generic_value_of_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_value_of_2() { xsltgeneric::generic_value_of_2( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_literal_element() { xsltgeneric::generic_literal_element( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_element() { xsltgeneric::generic_element( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_apply_templates_1() { xsltgeneric::generic_apply_templates_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_apply_templates_2() { xsltgeneric::generic_apply_templates_2( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_apply_templates_mode() { xsltgeneric::generic_apply_templates_mode( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_apply_templates_sort() { xsltgeneric::generic_apply_templates_sort( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_comment() { xsltgeneric::generic_comment( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_pi() { xsltgeneric::generic_pi( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_message_1() { xsltgeneric::generic_message_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_message_term() { xsltgeneric::generic_message_term( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_issue_58() { xsltgeneric::generic_issue_58( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_issue_95() { xsltgeneric::generic_issue_95( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_callable_named_1() { xsltgeneric::generic_callable_named_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_callable_posn_1() { xsltgeneric::generic_callable_posn_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] #[should_panic] fn xslt_include() { xsltgeneric::generic_include( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_current() { xsltgeneric::generic_current( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_key_1() { xsltgeneric::generic_key_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_document_1() { xsltgeneric::generic_document_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_number_1() { xsltgeneric::generic_number_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_attr_set_1() { xsltgeneric::attr_set_1( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_attr_set_2() { xsltgeneric::attr_set_2( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_attr_set_3() { xsltgeneric::attr_set_3( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_issue_96_abs() { xsltgeneric::issue_96_abs( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_issue_96_rel() { xsltgeneric::issue_96_rel( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_issue_96_mixed() { xsltgeneric::issue_96_mixed( smite::make_from_str, smite::make_from_str_with_ns, smite::make_sd_cooked, ) .expect("test failed") } #[test] fn xslt_issue_126() { xsltgeneric::issue_126( smite::make_from_str, smite::make_from_str_with_ns, smite::make_empty_doc_cooked, ) .expect("test failed") }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/serializer.rs
tests/serializer.rs
use std::fs; use xrust::parser::xml; use xrust::trees::smite::RNode; use xrust::Node; #[test] fn serializer_issue_98() { /* Github issue number 98 We wish to have XML documents output attributes in some stable order for test purposes. IMPORTANT NOTE: We will be stable for a particular version, but XML itself does not care about attribute order. We may switch the ordering between versions if we find a technical reason to do so. */ let data = fs::read_to_string("tests/xml/issue-98.xml").unwrap(); let mut prev_xml_output = None; for iteration in 0..100 { let doc = xml::parse(RNode::new_document(), data.clone().as_str(), None).unwrap(); let xml_output = doc.to_xml(); if let Some(prev_xml_output) = &prev_xml_output { assert_eq!(&xml_output, prev_xml_output, "Failed on run {}", iteration); } prev_xml_output = Some(xml_output); } } #[test] fn serializer_1() { /* Testing the XML output, simple document. */ let data = "<doc><child/></doc>"; let doc = xml::parse(RNode::new_document(), data, None).unwrap(); let xml_output = doc.to_xml(); /* Note, xRust currently does not output self closing tags, if it does you'll need to update this test with assert_eq!(xml_output, "<doc><child/></doc>"); */ assert_eq!(xml_output, "<doc><child></child></doc>"); } #[test] fn serializer_2() { /* Testing the XML output, with some namespaces. */ let data = "<doc xmlns='ns1'><child xmlns='ns2'/></doc>"; let doc = xml::parse(RNode::new_document(), data, None).unwrap(); let xml_output = doc.to_xml(); /* Note, xRust currently does not output self closing tags, if it does you'll need to update this test with assert_eq!(xml_output, "<doc xmlns='ns1'><child xmlns='ns2'/></doc>"); */ assert_eq!( xml_output, "<doc xmlns='ns1'><child xmlns='ns2'></child></doc>" ); } #[test] fn serializer_3() { /* Testing the XML output, with some namespace aliases. */ let data = "<a:doc xmlns:a='ns1'><a:child xmlns:a='ns2'/></a:doc>"; let doc = xml::parse(RNode::new_document(), data, None).unwrap(); let xml_output = doc.to_xml(); /* Note, xRust currently does not output self closing tags, if it does you'll need to update this test with assert_eq!(xml_output, "<a:doc xmlns:a='ns1'><a:child xmlns:a='ns2'/></a:doc>"); */ assert_eq!( xml_output, "<a:doc xmlns:a='ns1'><a:child xmlns:a='ns2'></a:child></a:doc>" ); } #[test] fn serializer_4() { /* Testing the XML output, mixed content */ let data = r#"<content att1='val1' xmlns:a='someothernamespace' att2='val2' xmlns='somenamespace' a:att4='val4' someatt='val5' other='valx'> <content2>text</content2> <content3/> <content4 xmlns='thirdnamespace' a:something='test'>text3</content4> <content05 xmlns:a='fourthnamespace' a:somethingelse='test2'>text4</content05> </content>"#; let doc = xml::parse(RNode::new_document(), data, None).unwrap(); let xml_output = doc.to_xml(); /* Note, xRust currently does not output self closing tags, if it does you'll need to update this test with assert_eq!(xml_output, "<content xmlns='somenamespace' xmlns:a='someothernamespace' att1='val1' att2='val2' other='valx' someatt='val5' a:att4='val4'> <content2>text</content2> <content3/> <content4 xmlns='thirdnamespace' a:something='test'>text3</content4> <content05 xmlns:a='fourthnamespace' a:somethingelse='test2'>text4</content05> </content>"); */ assert_eq!(xml_output, "<content xmlns='somenamespace' xmlns:a='someothernamespace' att1='val1' att2='val2' other='valx' someatt='val5' a:att4='val4'> <content2>text</content2> <content3></content3> <content4 xmlns='thirdnamespace' a:something='test'>text3</content4> <content05 xmlns:a='fourthnamespace' a:somethingelse='test2'>text4</content05> </content>"); } #[test] #[ignore] fn serializer_5() { /* Testing the XML output, characters to be escaped */ let data = "<doc attr='&apos;'>XML escape test: &lt; &gt; &amp; &apos; &quot;</doc>"; let doc = xml::parse(RNode::new_document(), data, None).unwrap(); let xml_output = doc.to_xml(); assert_eq!( xml_output, "<doc attr='&apos;'>XML escape test: &lt; &gt; &amp; &apos; &quot;</doc>" ); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/parser.rs
tests/parser.rs
/* University of Edinburgh XML 1.0 4th edition errata test suite. */ use std::fs; use xrust::item::{Node, NodeType}; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; #[test] fn parser_config_namespace_nodes_1() { let doc = r#"<doc xmlns="namespace" xmlns:a="namespace1" xmlns:b="namespace2" xmlns:c="namespace3" xmlns:d="namespace4" xmlns:e="namespace5" > <element1/> <element2 xmlns="namespace6"/> <element3 xmlns:f="namespace7"/> <element4 xmlns:f="namespace8"/> <element5> <element6/> </element5> </doc>"#; let pc = ParserConfig::new(); let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, doc, Some(pc)); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let element1 = docchildren.next().unwrap(); let element2 = docchildren.next().unwrap(); let element3 = docchildren.next().unwrap(); let element4 = docchildren.next().unwrap(); let element5 = docchildren.next().unwrap(); let element6 = element5 .child_iter() .filter(|n| n.node_type() == NodeType::Element) .next() .unwrap(); assert_eq!(doc.namespace_iter().count(), 7); assert_eq!(element1.namespace_iter().count(), 7); assert_eq!(element2.namespace_iter().count(), 7); assert_eq!(element3.namespace_iter().count(), 8); assert_eq!(element4.namespace_iter().count(), 8); assert_eq!(element5.namespace_iter().count(), 7); assert_eq!(element6.namespace_iter().count(), 7); } #[test] fn parser_config_default_attrs_1() { /* Conformance tests will determine if the ATTLIST functions are working, this tests only that it can be disabled. */ let doc = r#"<!DOCTYPE doc [ <!ELEMENT doc EMPTY> <!ATTLIST doc a CDATA "a" b CDATA "b" c CDATA #IMPLIED> ]> <doc/>"#; let pc1 = ParserConfig::new(); let testxml1 = RNode::new_document(); let parseresult1 = xml::parse(testxml1, doc, Some(pc1)); let mut pc2 = ParserConfig::new(); pc2.attr_defaults = false; let testxml2 = RNode::new_document(); let parseresult2 = xml::parse(testxml2, doc, Some(pc2)); assert!(parseresult1.is_ok()); assert!(parseresult2.is_ok()); assert_eq!( parseresult1 .clone() .unwrap() .first_child() .unwrap() .attribute_iter() .count(), 2 ); assert_eq!( parseresult2 .clone() .unwrap() .first_child() .unwrap() .attribute_iter() .count(), 0 ); } #[test] fn parser_issue_94() { /* Github issue number 94 Although rare, UTF-8 strings can start with a byte order mark, we strip this automatically. */ let data = fs::read_to_string("tests/xml/issue-94.xml").unwrap(); let source = RNode::new_document(); let parseresult = xml::parse(source.clone(), &data, None); assert!(parseresult.is_ok()) } #[test] fn parser_config_id_1() { /* Conformance tests will determine if the XML IDs are properly tracked by the parser, this tests only that it can be disabled. */ let doc = r#"<!DOCTYPE root [ <!ELEMENT doc ANY> <!ELEMENT element1 EMPTY> <!ATTLIST element1 id ID #IMPLIED idref IDREF #IMPLIED > ]> <doc> <element1 id="a1"/> <element1 id="a1"/> </doc> "#; let pc = ParserConfig::new(); let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, doc, Some(pc)); assert!(parseresult.is_err()); let mut pc2 = ParserConfig::new(); pc2.id_tracking = false; let testxml2 = RNode::new_document(); let parseresult2 = xml::parse(testxml2, doc, Some(pc2)); assert!(parseresult2.is_ok()); } #[test] fn parser_config_id_2() { /* Conformance tests will determine if the XML IDs are properly tracked by the parser, this tests only that it can be disabled. */ let doc = r#"<!DOCTYPE root [ <!ELEMENT doc ANY> <!ELEMENT element1 EMPTY> <!ATTLIST element1 id ID #IMPLIED idref IDREF #IMPLIED > ]> <doc> <element1 idref="a1"/> </doc> "#; let pc = ParserConfig::new(); let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, doc, Some(pc)); assert!(parseresult.is_err()); let mut pc2 = ParserConfig::new(); pc2.id_tracking = false; let testxml2 = RNode::new_document(); let parseresult2 = xml::parse(testxml2, doc, Some(pc2)); assert!(parseresult2.is_ok()); } #[test] fn parser_config_id_3() { /* Conformance tests will determine if the XML IDs are properly tracked by the parser, this tests only that it can be disabled. When we disable XML ID tracking, the is-id and is-idrefs properties will not populate. */ let doc = r#"<!DOCTYPE root [ <!ELEMENT doc ANY> <!ATTLIST doc id ID #IMPLIED idref IDREF #IMPLIED > ]> <doc id="a1"/> "#; let pc = ParserConfig::new(); let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, doc, Some(pc)); assert!(parseresult.is_ok()); assert_eq!( parseresult .unwrap() .first_child() .unwrap() .attribute_iter() .next() .unwrap() .is_id(), true ); let mut pc2 = ParserConfig::new(); pc2.id_tracking = false; let testxml2 = RNode::new_document(); let parseresult2 = xml::parse(testxml2, doc, Some(pc2)); assert!(parseresult2.is_ok()); assert_eq!( parseresult2 .unwrap() .first_child() .unwrap() .attribute_iter() .next() .unwrap() .is_id(), false ); } #[test] fn parser_config_id_4() { /* Conformance tests will determine if the XML IDs are properly tracked by the parser, this tests only that it can be disabled. When we disable XML ID tracking, the is-id and is-idrefs properties will not populate. */ let doc = r#"<!DOCTYPE root [ <!ELEMENT doc ANY> <!ATTLIST doc idref IDREF #IMPLIED > <!ELEMENT element1 EMPTY> <!ATTLIST element1 id ID #IMPLIED > ]> <doc idref="a1"> <element1 id="a1"/> </doc> "#; let pc = ParserConfig::new(); let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, doc, Some(pc)); assert!(parseresult.is_ok()); assert_eq!( parseresult .unwrap() .first_child() .unwrap() .attribute_iter() .next() .unwrap() .is_idrefs(), true ); let mut pc2 = ParserConfig::new(); pc2.id_tracking = false; let testxml2 = RNode::new_document(); let parseresult2 = xml::parse(testxml2, doc, Some(pc2)); assert!(parseresult2.is_ok()); assert_eq!( parseresult2 .unwrap() .first_child() .unwrap() .attribute_iter() .next() .unwrap() .is_idrefs(), false ); } #[test] fn parser_issue_132_full() { let doc = r###"<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"> <xsl:output method="xml" encoding="UTF-16" /> <!-- %% Global Definitions --> <!-- Every single unicode character that is recognized by OMML as an operator --> <xsl:variable name="sOperators" select="concat( '&#x00A8;&#x0021;&#x0022;&#x0023;&#x0026;&#x0028;&#x0029;&#x002B;&#x002C;&#x002D;&#x002E;&#x002F;&#x003A;', '&#x003B;&#x003C;&#x003D;&#x003E;&#x003F;&#x0040;&#x005B;&#x005C;&#x005D;&#x005E;&#x005F;&#x0060;&#x007B;', '&#x007C;&#x007D;&#x007E;&#x00A1;&#x00A6;&#x00AC;&#x00AF;&#x00B0;&#x00B1;&#x00B2;&#x00B3;&#x00B4;&#x00B7;&#x00B9;&#x00BF;', '&#x00D7;&#x007E;&#x00F7;&#x02C7;&#x02D8;&#x02D9;&#x02DC;&#x02DD;&#x0300;&#x0301;&#x0302;&#x0303;&#x0304;&#x0305;&#x0306;&#x0307;&#x0308;&#x0309;', '&#x030A;&#x030B;&#x030C;&#x030D;&#x030E;&#x030F;&#x0310;&#x0311;&#x0312;&#x0313;&#x0314;&#x0315;', '&#x0316;&#x0317;&#x0318;&#x0319;&#x031A;&#x031B;&#x031C;&#x031D;&#x031E;&#x031F;&#x0320;&#x0321;', '&#x0322;&#x0323;&#x0324;&#x0325;&#x0326;&#x0327;&#x0328;&#x0329;&#x032A;&#x032B;&#x032C;&#x032D;', '&#x032E;&#x032F;&#x0330;&#x0331;&#x0332;&#x0333;&#x0334;&#x0335;&#x0336;&#x0337;&#x0338;&#x033F;', '&#x2000;&#x2001;&#x2002;&#x2003;&#x2004;&#x2005;&#x2006;&#x2009;&#x200A;&#x2010;&#x2012;&#x2013;', '&#x2014;&#x2016;&#x2020;&#x2021;&#x2022;&#x2024;&#x2025;&#x2026;&#x2032;&#x2033;&#x2034;&#x203C;', '&#x2040;&#x2044;&#x204E;&#x204F;&#x2050;&#x2057;&#x2061;&#x2062;&#x2063;&#x2070;&#x2074;&#x2075;', '&#x2076;&#x2077;&#x2078;&#x2079;&#x207A;&#x207B;&#x207C;&#x207D;&#x207E;&#x2080;&#x2081;&#x2082;', '&#x2083;&#x2084;&#x2085;&#x2086;&#x2087;&#x2088;&#x2089;&#x208A;&#x208B;&#x208C;&#x208D;&#x208E;', '&#x20D0;&#x20D1;&#x20D2;&#x20D3;&#x20D4;&#x20D5;&#x20D6;&#x20D7;&#x20D8;&#x20D9;&#x20DA;&#x20DB;', '&#x20DC;&#x20DD;&#x20DE;&#x20DF;&#x20E0;&#x20E1;&#x20E4;&#x20E5;&#x20E6;&#x20E7;&#x20E8;&#x20E9;', '&#x20EA;&#x2140;&#x2146;&#x2190;&#x2191;&#x2192;&#x2193;&#x2194;&#x2195;&#x2196;&#x2197;&#x2198;&#x2199;', '&#x219A;&#x219B;&#x219C;&#x219D;&#x219E;&#x219F;&#x21A0;&#x21A1;&#x21A2;&#x21A3;&#x21A4;&#x21A5;', '&#x21A6;&#x21A7;&#x21A8;&#x21A9;&#x21AA;&#x21AB;&#x21AC;&#x21AD;&#x21AE;&#x21AF;&#x21B0;&#x21B1;', '&#x21B2;&#x21B3;&#x21B6;&#x21B7;&#x21BA;&#x21BB;&#x21BC;&#x21BD;&#x21BE;&#x21BF;&#x21C0;&#x21C1;', '&#x21C2;&#x21C3;&#x21C4;&#x21C5;&#x21C6;&#x21C7;&#x21C8;&#x21C9;&#x21CA;&#x21CB;&#x21CC;&#x21CD;', '&#x21CE;&#x21CF;&#x21D0;&#x21D1;&#x21D2;&#x21D3;&#x21D4;&#x21D5;&#x21D6;&#x21D7;&#x21D8;&#x21D9;', '&#x21DA;&#x21DB;&#x21DC;&#x21DD;&#x21DE;&#x21DF;&#x21E0;&#x21E1;&#x21E2;&#x21E3;&#x21E4;&#x21E5;', '&#x21E6;&#x21E7;&#x21E8;&#x21E9;&#x21F3;&#x21F4;&#x21F5;&#x21F6;&#x21F7;&#x21F8;&#x21F9;&#x21FA;', '&#x21FB;&#x21FC;&#x21FD;&#x21FE;&#x21FF;&#x2200;&#x2201;&#x2202;&#x2203;&#x2204;&#x2206;&#x2207;', '&#x2208;&#x2209;&#x220A;&#x220B;&#x220C;&#x220D;&#x220F;&#x2210;&#x2211;&#x2212;&#x2213;&#x2214;', '&#x2215;&#x2216;&#x2217;&#x2218;&#x2219;&#x221A;&#x221B;&#x221C;&#x221D;&#x2223;&#x2224;&#x2225;', '&#x2226;&#x2227;&#x2228;&#x2229;&#x222A;&#x222B;&#x222C;&#x222D;&#x222E;&#x222F;&#x2230;&#x2231;', '&#x2232;&#x2233;&#x2234;&#x2235;&#x2236;&#x2237;&#x2238;&#x2239;&#x223A;&#x223B;&#x223C;&#x223D;', '&#x223E;&#x2240;&#x2241;&#x2242;&#x2243;&#x2244;&#x2245;&#x2246;&#x2247;&#x2248;&#x2249;&#x224A;', '&#x224B;&#x224C;&#x224D;&#x224E;&#x224F;&#x2250;&#x2251;&#x2252;&#x2253;&#x2254;&#x2255;&#x2256;', '&#x2257;&#x2258;&#x2259;&#x225A;&#x225B;&#x225C;&#x225D;&#x225E;&#x225F;&#x2260;&#x2261;&#x2262;', '&#x2263;&#x2264;&#x2265;&#x2266;&#x2267;&#x2268;&#x2269;&#x226A;&#x226B;&#x226C;&#x226D;&#x226E;', '&#x226F;&#x2270;&#x2271;&#x2272;&#x2273;&#x2274;&#x2275;&#x2276;&#x2277;&#x2278;&#x2279;&#x227A;', '&#x227B;&#x227C;&#x227D;&#x227E;&#x227F;&#x2280;&#x2281;&#x2282;&#x2283;&#x2284;&#x2285;&#x2286;', '&#x2287;&#x2288;&#x2289;&#x228A;&#x228B;&#x228C;&#x228D;&#x228E;&#x228F;&#x2290;&#x2291;&#x2292;', '&#x2293;&#x2294;&#x2295;&#x2296;&#x2297;&#x2298;&#x2299;&#x229A;&#x229B;&#x229C;&#x229D;&#x229E;', '&#x229F;&#x22A0;&#x22A1;&#x22A2;&#x22A3;&#x22A5;&#x22A6;&#x22A7;&#x22A8;&#x22A9;&#x22AA;&#x22AB;', '&#x22AC;&#x22AD;&#x22AE;&#x22AF;&#x22B0;&#x22B1;&#x22B2;&#x22B3;&#x22B4;&#x22B5;&#x22B6;&#x22B7;', '&#x22B8;&#x22B9;&#x22BA;&#x22BB;&#x22BC;&#x22BD;&#x22C0;&#x22C1;&#x22C2;&#x22C3;&#x22C4;&#x22C5;', '&#x22C6;&#x22C7;&#x22C8;&#x22C9;&#x22CA;&#x22CB;&#x22CC;&#x22CD;&#x22CE;&#x22CF;&#x22D0;&#x22D1;', '&#x22D2;&#x22D3;&#x22D4;&#x22D5;&#x22D6;&#x22D7;&#x22D8;&#x22D9;&#x22DA;&#x22DB;&#x22DC;&#x22DD;', '&#x22DE;&#x22DF;&#x22E0;&#x22E1;&#x22E2;&#x22E3;&#x22E4;&#x22E5;&#x22E6;&#x22E7;&#x22E8;&#x22E9;', '&#x22EA;&#x22EB;&#x22EC;&#x22ED;&#x22EE;&#x22EF;&#x22F0;&#x22F1;&#x22F2;&#x22F3;&#x22F4;&#x22F5;', '&#x22F6;&#x22F7;&#x22F8;&#x22F9;&#x22FA;&#x22FB;&#x22FC;&#x22FD;&#x22FE;&#x22FF;&#x2305;&#x2306;', '&#x2308;&#x2309;&#x230A;&#x230B;&#x231C;&#x231D;&#x231E;&#x231F;&#x2322;&#x2323;&#x2329;&#x232A;', '&#x233D;&#x233F;&#x23B0;&#x23B1;&#x23DC;&#x23DD;&#x23DE;&#x23DF;&#x23E0;&#x2502;&#x251C;&#x2524;', '&#x252C;&#x2534;&#x2581;&#x2588;&#x2592;&#x25A0;&#x25A1;&#x25AD;&#x25B2;&#x25B3;&#x25B4;&#x25B5;', '&#x25B6;&#x25B7;&#x25B8;&#x25B9;&#x25BC;&#x25BD;&#x25BE;&#x25BF;&#x25C0;&#x25C1;&#x25C2;&#x25C3;', '&#x25C4;&#x25C5;&#x25CA;&#x25CB;&#x25E6;&#x25EB;&#x25EC;&#x25F8;&#x25F9;&#x25FA;&#x25FB;&#x25FC;', '&#x25FD;&#x25FE;&#x25FF;&#x2605;&#x2606;&#x2772;&#x2773;&#x27D1;&#x27D2;&#x27D3;&#x27D4;&#x27D5;', '&#x27D6;&#x27D7;&#x27D8;&#x27D9;&#x27DA;&#x27DB;&#x27DC;&#x27DD;&#x27DE;&#x27DF;&#x27E0;&#x27E1;', '&#x27E2;&#x27E3;&#x27E4;&#x27E5;&#x27E6;&#x27E7;&#x27E8;&#x27E9;&#x27EA;&#x27EB;&#x27F0;&#x27F1;', '&#x27F2;&#x27F3;&#x27F4;&#x27F5;&#x27F6;&#x27F7;&#x27F8;&#x27F9;&#x27FA;&#x27FB;&#x27FC;&#x27FD;', '&#x27FE;&#x27FF;&#x2900;&#x2901;&#x2902;&#x2903;&#x2904;&#x2905;&#x2906;&#x2907;&#x2908;&#x2909;', '&#x290A;&#x290B;&#x290C;&#x290D;&#x290E;&#x290F;&#x2910;&#x2911;&#x2912;&#x2913;&#x2914;&#x2915;', '&#x2916;&#x2917;&#x2918;&#x2919;&#x291A;&#x291B;&#x291C;&#x291D;&#x291E;&#x291F;&#x2920;&#x2921;', '&#x2922;&#x2923;&#x2924;&#x2925;&#x2926;&#x2927;&#x2928;&#x2929;&#x292A;&#x292B;&#x292C;&#x292D;', '&#x292E;&#x292F;&#x2930;&#x2931;&#x2932;&#x2933;&#x2934;&#x2935;&#x2936;&#x2937;&#x2938;&#x2939;', '&#x293A;&#x293B;&#x293C;&#x293D;&#x293E;&#x293F;&#x2940;&#x2941;&#x2942;&#x2943;&#x2944;&#x2945;', '&#x2946;&#x2947;&#x2948;&#x2949;&#x294A;&#x294B;&#x294C;&#x294D;&#x294E;&#x294F;&#x2950;&#x2951;', '&#x2952;&#x2953;&#x2954;&#x2955;&#x2956;&#x2957;&#x2958;&#x2959;&#x295A;&#x295B;&#x295C;&#x295D;', '&#x295E;&#x295F;&#x2960;&#x2961;&#x2962;&#x2963;&#x2964;&#x2965;&#x2966;&#x2967;&#x2968;&#x2969;', '&#x296A;&#x296B;&#x296C;&#x296D;&#x296E;&#x296F;&#x2970;&#x2971;&#x2972;&#x2973;&#x2974;&#x2975;', '&#x2976;&#x2977;&#x2978;&#x2979;&#x297A;&#x297B;&#x297C;&#x297D;&#x297E;&#x297F;&#x2980;&#x2982;', '&#x2983;&#x2984;&#x2985;&#x2986;&#x2987;&#x2988;&#x2989;&#x298A;&#x298B;&#x298C;&#x298D;&#x298E;', '&#x298F;&#x2990;&#x2991;&#x2992;&#x2993;&#x2994;&#x2995;&#x2996;&#x2997;&#x2998;&#x2999;&#x299A;', '&#x29B6;&#x29B7;&#x29B8;&#x29B9;&#x29C0;&#x29C1;&#x29C4;&#x29C5;&#x29C6;&#x29C7;&#x29C8;&#x29CE;', '&#x29CF;&#x29D0;&#x29D1;&#x29D2;&#x29D3;&#x29D4;&#x29D5;&#x29D6;&#x29D7;&#x29D8;&#x29D9;&#x29DA;', '&#x29DB;&#x29DF;&#x29E1;&#x29E2;&#x29E3;&#x29E4;&#x29E5;&#x29E6;&#x29EB;&#x29F4;&#x29F5;&#x29F6;', '&#x29F7;&#x29F8;&#x29F9;&#x29FA;&#x29FB;&#x29FC;&#x29FD;&#x29FE;&#x29FF;&#x2A00;&#x2A01;&#x2A02;', '&#x2A03;&#x2A04;&#x2A05;&#x2A06;&#x2A07;&#x2A08;&#x2A09;&#x2A0A;&#x2A0B;&#x2A0C;&#x2A0D;&#x2A0E;', '&#x2A0F;&#x2A10;&#x2A11;&#x2A12;&#x2A13;&#x2A14;&#x2A15;&#x2A16;&#x2A17;&#x2A18;&#x2A19;&#x2A1A;', '&#x2A1B;&#x2A1C;&#x2A1D;&#x2A1E;&#x2A1F;&#x2A20;&#x2A21;&#x2A22;&#x2A23;&#x2A24;&#x2A25;&#x2A26;', '&#x2A27;&#x2A28;&#x2A29;&#x2A2A;&#x2A2B;&#x2A2C;&#x2A2D;&#x2A2E;&#x2A2F;&#x2A30;&#x2A31;&#x2A32;', '&#x2A33;&#x2A34;&#x2A35;&#x2A36;&#x2A37;&#x2A38;&#x2A39;&#x2A3A;&#x2A3B;&#x2A3C;&#x2A3D;&#x2A3E;', '&#x2A3F;&#x2A40;&#x2A41;&#x2A42;&#x2A43;&#x2A44;&#x2A45;&#x2A46;&#x2A47;&#x2A48;&#x2A49;&#x2A4A;', '&#x2A4B;&#x2A4C;&#x2A4D;&#x2A4E;&#x2A4F;&#x2A50;&#x2A51;&#x2A52;&#x2A53;&#x2A54;&#x2A55;&#x2A56;', '&#x2A57;&#x2A58;&#x2A59;&#x2A5A;&#x2A5B;&#x2A5C;&#x2A5D;&#x2A5E;&#x2A5F;&#x2A60;&#x2A61;&#x2A62;', '&#x2A63;&#x2A64;&#x2A65;&#x2A66;&#x2A67;&#x2A68;&#x2A69;&#x2A6A;&#x2A6B;&#x2A6C;&#x2A6D;&#x2A6E;', '&#x2A6F;&#x2A70;&#x2A71;&#x2A72;&#x2A73;&#x2A74;&#x2A75;&#x2A76;&#x2A77;&#x2A78;&#x2A79;&#x2A7A;', '&#x2A7B;&#x2A7C;&#x2A7D;&#x2A7E;&#x2A7F;&#x2A80;&#x2A81;&#x2A82;&#x2A83;&#x2A84;&#x2A85;&#x2A86;', '&#x2A87;&#x2A88;&#x2A89;&#x2A8A;&#x2A8B;&#x2A8C;&#x2A8D;&#x2A8E;&#x2A8F;&#x2A90;&#x2A91;&#x2A92;', '&#x2A93;&#x2A94;&#x2A95;&#x2A96;&#x2A97;&#x2A98;&#x2A99;&#x2A9A;&#x2A9B;&#x2A9C;&#x2A9D;&#x2A9E;', '&#x2A9F;&#x2AA0;&#x2AA1;&#x2AA2;&#x2AA3;&#x2AA4;&#x2AA5;&#x2AA6;&#x2AA7;&#x2AA8;&#x2AA9;&#x2AAA;', '&#x2AAB;&#x2AAC;&#x2AAD;&#x2AAE;&#x2AAF;&#x2AB0;&#x2AB1;&#x2AB2;&#x2AB3;&#x2AB4;&#x2AB5;&#x2AB6;', '&#x2AB7;&#x2AB8;&#x2AB9;&#x2ABA;&#x2ABB;&#x2ABC;&#x2ABD;&#x2ABE;&#x2ABF;&#x2AC0;&#x2AC1;&#x2AC2;', '&#x2AC3;&#x2AC4;&#x2AC5;&#x2AC6;&#x2AC7;&#x2AC8;&#x2AC9;&#x2ACA;&#x2ACB;&#x2ACC;&#x2ACD;&#x2ACE;', '&#x2ACF;&#x2AD0;&#x2AD1;&#x2AD2;&#x2AD3;&#x2AD4;&#x2AD5;&#x2AD6;&#x2AD7;&#x2AD8;&#x2AD9;&#x2ADA;', '&#x2ADB;&#x2ADC;&#x2ADD;&#x2ADE;&#x2ADF;&#x2AE0;&#x2AE2;&#x2AE3;&#x2AE4;&#x2AE5;&#x2AE6;&#x2AE7;', '&#x2AE8;&#x2AE9;&#x2AEA;&#x2AEB;&#x2AEC;&#x2AED;&#x2AEE;&#x2AEF;&#x2AF0;&#x2AF2;&#x2AF3;&#x2AF4;', '&#x2AF5;&#x2AF6;&#x2AF7;&#x2AF8;&#x2AF9;&#x2AFA;&#x2AFB;&#x2AFC;&#x2AFD;&#x2AFE;&#x2AFF;&#x2B04;', '&#x2B06;&#x2B07;&#x2B0C;&#x2B0D;&#x3014;&#x3015;&#x3016;&#x3017;&#x3018;&#x3019;&#xFF01;&#xFF06;', '&#xFF08;&#xFF09;&#xFF0B;&#xFF0C;&#xFF0D;&#xFF0E;&#xFF0F;&#xFF1A;&#xFF1B;&#xFF1C;&#xFF1D;&#xFF1E;', '&#xFF1F;&#xFF20;&#xFF3B;&#xFF3C;&#xFF3D;&#xFF3E;&#xFF3F;&#xFF5B;&#xFF5C;&#xFF5D;')" /> </xsl:stylesheet> "###; let pc = ParserConfig::new(); let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, doc, Some(pc)); if let Err(e) = &parseresult { eprintln!("Parse error: {:?}", e) }; assert!(parseresult.is_ok()); } #[test] fn parser_issue_132_minimal() { let doc = r###"<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <test value="&#x003C;">empty</test> </xsl:stylesheet> "###; let pc = ParserConfig::new(); let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, doc, Some(pc)); if let Err(e) = &parseresult { eprintln!("Parse error: {:?}", e) }; assert!(parseresult.is_ok()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/smite-macros.rs
tests/smite-macros.rs
use xrust::item::{Node, NodeType}; use xrust::item_node_tests; use xrust::item_value_tests; use xrust::qname::QualifiedName; use xrust::trees::smite::RNode; mod node; mod smite; item_value_tests!(RNode); // Item Node tests item_node_tests!(smite::make_empty_doc, smite::make_doc, smite::make_sd_raw); #[test] fn node_get_attr_node() { node::get_attr_node::<RNode, _>(smite::make_empty_doc).expect("test failed") }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/smite-xpath.rs
tests/smite-xpath.rs
// XPath tests use xrust::trees::smite::RNode; mod smite; mod xpathgeneric; #[test] fn xpath_empty() { xpathgeneric::generic_empty::<RNode>().expect("test failed") } #[test] fn xpath_step_1_pos() { xpathgeneric::generic_step_1_pos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_2_pos() { xpathgeneric::generic_step_2_pos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_2() { xpathgeneric::generic_step_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_attribute_1() { xpathgeneric::generic_step_attribute_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_attribute_2() { xpathgeneric::generic_step_attribute_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_wild_1() { xpathgeneric::generic_step_wild_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_parent_1() { xpathgeneric::generic_step_parent_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_parent_2() { xpathgeneric::generic_step_parent_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_step_wild_2() { xpathgeneric::generic_step_wild_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_path_1_pos() { xpathgeneric::generic_path_1_pos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_path_2_pos() { xpathgeneric::generic_path_2_pos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_path_1_neg() { xpathgeneric::generic_path_1_neg::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_path_3() { xpathgeneric::generic_path_3::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_path_4() { xpathgeneric::generic_path_4::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_navigate_predicate_1() { xpathgeneric::generic_navigate_predicate_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_generate_id() { xpathgeneric::generic_generate_id::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_union() { xpathgeneric::generic_union::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_intersectexcept() { xpathgeneric::generic_intersectexcept::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_instanceof() { xpathgeneric::generic_instanceof::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_treat() { xpathgeneric::generic_treat::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_castable() { xpathgeneric::generic_castable::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_cast() { xpathgeneric::generic_cast::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_arrow() { xpathgeneric::generic_arrow::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_unary() { xpathgeneric::generic_unary::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_simplemap() { xpathgeneric::generic_simplemap::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_int() { xpathgeneric::generic_int::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_decimal() { xpathgeneric::generic_decimal::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_exponent() { xpathgeneric::generic_exponent::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_string_apos() { xpathgeneric::generic_string_apos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_string_apos_esc() { xpathgeneric::generic_string_apos_esc::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_string_quot() { xpathgeneric::generic_string_quot::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_string_quot_esc() { xpathgeneric::generic_string_quot_esc::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_literal_sequence() { xpathgeneric::generic_literal_sequence::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_literal_sequence_ws() { xpathgeneric::generic_literal_sequence_ws::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_comment() { xpathgeneric::generic_xpath_comment::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_kindtest_text_abbrev() { xpathgeneric::generic_kindtest_text_abbrev::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_kindtest_text_full() { xpathgeneric::generic_kindtest_text_full::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_context_item() { xpathgeneric::generic_xpath_context_item::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_parens_singleton() { xpathgeneric::generic_parens_singleton::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_root_desc_or_self_1() { xpathgeneric::generic_root_desc_or_self_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_root_desc_or_self_2() { xpathgeneric::generic_root_desc_or_self_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_root_desc_or_self_3() { xpathgeneric::generic_root_desc_or_self_3::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_rel_path_1() { xpathgeneric::generic_rel_path_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_rel_path_2() { xpathgeneric::generic_rel_path_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_string() { xpathgeneric::generic_fncall_string::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] #[should_panic] fn xpath_fncall_current_1() { xpathgeneric::generic_fncall_current_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_current_2() { xpathgeneric::generic_fncall_current_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_current_3() { xpathgeneric::generic_fncall_current_3::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_concat() { xpathgeneric::generic_fncall_concat::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_startswith_pos() { xpathgeneric::generic_fncall_startswith_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_startswith_neg() { xpathgeneric::generic_fncall_startswith_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_contains_pos() { xpathgeneric::generic_fncall_contains_pos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_contains_neg() { xpathgeneric::generic_fncall_contains_neg::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_substring_2arg() { xpathgeneric::generic_fncall_substring_2arg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_substring_3arg() { xpathgeneric::generic_fncall_substring_3arg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_substringbefore_pos() { xpathgeneric::generic_fncall_substringbefore_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_substringbefore_neg() { xpathgeneric::generic_fncall_substringbefore_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_substringafter_pos_1() { xpathgeneric::generic_fncall_substringafter_pos_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_substringafter_pos_2() { xpathgeneric::generic_fncall_substringafter_pos_2::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_substringafter_neg() { xpathgeneric::generic_fncall_substringafter_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_normalizespace() { xpathgeneric::generic_fncall_normalizespace::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_fncall_translate() { xpathgeneric::generic_fncall_translate::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_boolean_true() { xpathgeneric::generic_fncall_boolean_true::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_boolean_false() { xpathgeneric::generic_fncall_boolean_false::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_not_true() { xpathgeneric::generic_fncall_not_true::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_not_false() { xpathgeneric::generic_fncall_not_false::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_true() { xpathgeneric::generic_fncall_true::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_false() { xpathgeneric::generic_fncall_false::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_number_int() { xpathgeneric::generic_fncall_number_int::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_number_double() { xpathgeneric::generic_fncall_number_double::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_sum() { xpathgeneric::generic_fncall_sum::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_avg() { xpathgeneric::generic_fncall_avg::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_min() { xpathgeneric::generic_fncall_min::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_max() { xpathgeneric::generic_fncall_max::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_floor() { xpathgeneric::generic_fncall_floor::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_ceiling() { xpathgeneric::generic_fncall_ceiling::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_round_down() { xpathgeneric::generic_fncall_round_down::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_round_up() { xpathgeneric::generic_fncall_round_up::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_count_1() { xpathgeneric::generic_fncall_count_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_count_2() { xpathgeneric::generic_fncall_count_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_fncall_user_defined() { xpathgeneric::generic_fncall_user_defined::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_let_1() { xpathgeneric::generic_let_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_let_2() { xpathgeneric::generic_let_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_for_1() { xpathgeneric::generic_for_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_for_2() { xpathgeneric::generic_for_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_if_1() { xpathgeneric::generic_if_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_if_2() { xpathgeneric::generic_if_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_issue_95() { xpathgeneric::generic_issue_95::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_sys_prop_vers_qual() { xpathgeneric::generic_sys_prop_vers_qual::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_sys_prop_product_vers() { xpathgeneric::generic_sys_prop_product_vers::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn xpath_key_1() { xpathgeneric::generic_key_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_format_number_1() { xpathgeneric::generic_format_number_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn xpath_document_1() { xpathgeneric::generic_document_1::<RNode, _, _, _>( smite::make_empty_doc, smite::make_sd, smite::make_from_str, ) .expect("test failed") }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/mod.rs
tests/mod.rs
mod conformance; //use std::convert::TryFrom; //use std::fs; //use xrust::{Document, Error}; /* #[test] #[ignore] fn bigfile() { /* A million elements, each with an attribute and value */ let testxml = Document::try_from((fs::read_to_string("tests/xml/45M.xml").unwrap(), None, None)); assert!(testxml.is_ok()); } */
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/smite-pattern.rs
tests/smite-pattern.rs
// Smite tests for pattern module use xrust::trees::smite::RNode; mod patterngeneric; mod smite; #[test] #[should_panic] fn pattern_empty() { patterngeneric::pattern_empty::<RNode>().expect("test failed") } #[test] fn pattern_predicate_1_pos() { patterngeneric::pattern_predicate_1_pos::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_predicate_1_neg() { patterngeneric::pattern_predicate_1_neg::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_sel_root_pos() { patterngeneric::pattern_sel_root_pos::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_sel_root_neg() { patterngeneric::pattern_sel_root_neg::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_sel_1_pos() { patterngeneric::pattern_sel_1_pos::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_sel_1_neg() { patterngeneric::pattern_sel_1_neg::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_sel_2_pos() { patterngeneric::pattern_sel_2_pos::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_sel_2_neg() { patterngeneric::pattern_sel_2_neg::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_abbrev_1_pos() { patterngeneric::pattern_abbrev_1_pos::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_abbrev_1_neg() { patterngeneric::pattern_abbrev_1_neg::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_abbrev_2_pos() { patterngeneric::pattern_abbrev_2_pos::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_abbrev_2_neg() { patterngeneric::pattern_abbrev_2_neg::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_abbrev_3_pos() { patterngeneric::abbrev_3_pos::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_abbrev_3_neg() { patterngeneric::abbrev_3_neg::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_sel_text_kind_1_pos() { patterngeneric::pattern_sel_text_kind_1_pos::<RNode, _>(smite::make_empty_doc) .expect("test failed") } #[test] fn pattern_issue_95() { patterngeneric::pattern_issue_95::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_union_1() { patterngeneric::pattern_union_1::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_union_2() { patterngeneric::pattern_union_2::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_union_3() { patterngeneric::pattern_union_3::<RNode, _>(smite::make_empty_doc).expect("test failed") } #[test] fn pattern_union_4() { patterngeneric::pattern_union_4::<RNode, _>(smite::make_empty_doc).expect("test failed") }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/smite-transform.rs
tests/smite-transform.rs
// Transform tests use xrust::trees::smite::RNode; mod smite; mod transformgeneric; #[test] fn tr_empty() { transformgeneric::generic_tr_empty::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_singleton_literal() { transformgeneric::generic_tr_singleton_literal::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_literal_element() { transformgeneric::generic_tr_literal_element::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_literal_element_nested() { transformgeneric::generic_tr_literal_element_nested::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_element() { transformgeneric::generic_tr_element::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_literal_text_1() { transformgeneric::generic_tr_literal_text_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_literal_text_2() { transformgeneric::generic_tr_literal_text_2::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_literal_attribute() { transformgeneric::generic_tr_literal_attribute::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_literal_comment() { transformgeneric::generic_tr_literal_comment::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_literal_pi() { transformgeneric::generic_tr_literal_pi::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_generate_id_ctxt() { transformgeneric::generic_tr_generate_id_ctxt::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_generate_id_2() { transformgeneric::generic_tr_generate_id_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_message_1() { transformgeneric::generic_tr_message_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_message_2() { transformgeneric::generic_tr_message_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_message_term_1() { transformgeneric::generic_tr_message_term_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_set_attribute() { transformgeneric::generic_tr_set_attribute::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_copy_literal() { transformgeneric::generic_tr_copy_literal::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_copy_context_literal() { transformgeneric::generic_tr_copy_context_literal::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_copy_context_node() { transformgeneric::generic_tr_copy_context_node::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_current_node() { transformgeneric::generic_tr_current_node::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_deep_copy() { transformgeneric::generic_tr_deep_copy::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_seq_of_literals() { transformgeneric::generic_tr_seq_of_literals::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_seq_of_seqs() { transformgeneric::generic_tr_seq_of_seqs::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_switch_when() { transformgeneric::generic_tr_switch_when::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_switch_otherwise() { transformgeneric::generic_tr_switch_otherwise::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_loop_lit() { transformgeneric::generic_tr_loop_lit::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_context_item() { transformgeneric::generic_tr_context_item::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_context_item_seq() { transformgeneric::generic_tr_context_item_seq::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_root() { transformgeneric::generic_tr_root::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_path_of_lits() { transformgeneric::generic_tr_path_of_lits::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_step_child_1() { transformgeneric::generic_tr_step_child_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_step_child_many() { transformgeneric::generic_tr_step_child_many::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_self() { transformgeneric::generic_tr_step_self::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_step_selfdoc_pos() { transformgeneric::generic_tr_step_selfdoc_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_selfdoc_neg() { transformgeneric::generic_tr_step_selfdoc_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_parent() { transformgeneric::generic_tr_step_parent::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_step_parentdoc_pos() { transformgeneric::generic_tr_step_parentdoc_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_parentdoc_neg() { transformgeneric::generic_tr_step_parentdoc_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_descendant() { transformgeneric::generic_tr_step_descendant::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_descendant_or_self() { transformgeneric::generic_tr_step_descendant_or_self::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_descendant_or_self_or_root() { transformgeneric::generic_tr_step_descendant_or_self_or_root::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_ancestor() { transformgeneric::generic_tr_step_ancestor::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_step_ancestor_or_self() { transformgeneric::generic_tr_step_ancestor_or_self::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_following_sibling() { transformgeneric::generic_tr_step_following_sibling::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_preceding_sibling() { transformgeneric::generic_tr_step_preceding_sibling::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_following() { transformgeneric::generic_tr_step_following::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_preceding() { transformgeneric::generic_tr_step_preceding::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_path_step_child() { transformgeneric::generic_tr_path_step_child::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_attribute() { transformgeneric::generic_tr_step_attribute::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_self_attribute_pos() { transformgeneric::generic_tr_step_self_attribute_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_step_self_attribute_neg() { transformgeneric::generic_tr_step_self_attribute_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_predicate() { transformgeneric::generic_tr_predicate::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_or_true() { transformgeneric::generic_tr_or_true::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_or_false() { transformgeneric::generic_tr_or_false::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_and_true() { transformgeneric::generic_tr_and_true::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_and_false() { transformgeneric::generic_tr_and_false::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_general_compare_true() { transformgeneric::generic_tr_general_compare_true::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_general_compare_false() { transformgeneric::generic_tr_general_compare_false::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_value_compare_true() { transformgeneric::generic_tr_value_compare_true::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_value_compare_false() { transformgeneric::generic_tr_value_compare_false::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_range_empty() { transformgeneric::generic_tr_range_empty::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_range_many() { transformgeneric::generic_tr_range_many::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_range_one() { transformgeneric::generic_tr_range_one::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_arithmetic_add() { transformgeneric::generic_tr_arithmetic_add::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_var_declare() { transformgeneric::generic_tr_var_declare::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_union() { transformgeneric::generic_tr_union::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_for_each() { transformgeneric::generic_tr_for_each::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_for_each_sort_1() { transformgeneric::generic_tr_for_each_sort::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_group_by_1() { transformgeneric::generic_tr_group_by_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_group_by_sort_1() { transformgeneric::generic_tr_group_by_sort_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_group_adjacent_1() { transformgeneric::generic_tr_group_adjacent_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_group_adjacent_sort_1() { transformgeneric::generic_tr_group_adjacent_sort_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_builtins() { transformgeneric::generic_tr_apply_templates_builtins::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_1() { transformgeneric::generic_tr_apply_templates_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_2() { transformgeneric::generic_tr_apply_templates_2::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_3() { transformgeneric::generic_tr_apply_templates_3::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_import() { transformgeneric::generic_tr_apply_templates_import::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_next_match() { transformgeneric::generic_tr_apply_templates_next_match::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_mode() { transformgeneric::generic_tr_apply_templates_mode::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_apply_templates_sort_1() { transformgeneric::generic_tr_apply_templates_sort_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_position() { transformgeneric::generic_tr_position::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_last() { transformgeneric::generic_tr_last::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_count_0() { transformgeneric::generic_tr_count_0::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_count_1() { transformgeneric::generic_tr_count_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_localname_0() { transformgeneric::generic_tr_localname_0::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_name_0() { transformgeneric::generic_tr_name_0::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_string() { transformgeneric::generic_tr_string::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_concat_literal() { transformgeneric::generic_tr_concat_literal::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_starts_with_pos() { transformgeneric::generic_tr_starts_with_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_starts_with_neg() { transformgeneric::generic_tr_starts_with_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_contains_pos() { transformgeneric::generic_tr_contains_pos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_contains_neg() { transformgeneric::generic_tr_contains_neg::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_substring_2args() { transformgeneric::generic_tr_substring_2args::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_substring_3args() { transformgeneric::generic_tr_substring_3args::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_substring_before() { transformgeneric::generic_tr_substring_before::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_substring_after() { transformgeneric::generic_tr_substring_after::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_normalize_space_1() { transformgeneric::generic_tr_normalize_space_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_translate_1() { transformgeneric::generic_tr_translate_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_boolean_string_pos() { transformgeneric::generic_tr_boolean_string_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_boolean_string_neg() { transformgeneric::generic_tr_boolean_string_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_boolean_int_pos() { transformgeneric::generic_tr_boolean_int_pos::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_boolean_int_neg() { transformgeneric::generic_tr_boolean_int_neg::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_not_pos() { transformgeneric::generic_tr_not_pos::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_not_neg() { transformgeneric::generic_tr_not_neg::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_true_literal() { transformgeneric::generic_tr_true_literal::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_false_literal() { transformgeneric::generic_tr_false_literal::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_number() { transformgeneric::generic_tr_number::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_sum() { transformgeneric::generic_tr_sum::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_avg() { transformgeneric::generic_tr_avg::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_min() { transformgeneric::generic_tr_min::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_max() { transformgeneric::generic_tr_max::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_floor() { transformgeneric::generic_tr_floor::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_ceiling() { transformgeneric::generic_tr_ceiling::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_round_1() { transformgeneric::generic_tr_round_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_round_2() { transformgeneric::generic_tr_round_2::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_current_date_time() { transformgeneric::generic_tr_current_date_time::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_current_date() { transformgeneric::generic_tr_current_date::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_current_time() { transformgeneric::generic_tr_current_time::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_format_date_time() { transformgeneric::generic_tr_format_date_time::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_format_date() { transformgeneric::generic_tr_format_date::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_format_time() { transformgeneric::generic_tr_format_time::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_format_number_1() { transformgeneric::generic_tr_format_number_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_key_1() { transformgeneric::generic_tr_key_1::<RNode, _, _>(smite::make_empty_doc, smite::make_sd) .expect("test failed") } #[test] fn tr_callable_named_1() { transformgeneric::generic_tr_callable_named_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_callable_positional_1() { transformgeneric::generic_tr_callable_positional_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, ) .expect("test failed") } #[test] fn tr_document_1() { transformgeneric::generic_tr_document_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_generate_ints_1() { transformgeneric::generic_tr_generate_ints_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_format_int_1() { transformgeneric::generic_tr_format_ints_1::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_format_int_2() { transformgeneric::generic_tr_format_ints_2::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_format_int_3() { transformgeneric::generic_tr_format_ints_3::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_format_int_4() { transformgeneric::generic_tr_format_ints_4::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_format_int_5() { transformgeneric::generic_tr_format_ints_5::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_format_int_6() { transformgeneric::generic_tr_format_ints_6::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") } #[test] fn tr_format_int_7() { transformgeneric::generic_tr_format_ints_7::<RNode, _, _>( smite::make_empty_doc, smite::make_sd, Box::new(smite::make_from_str), ) .expect("test failed") }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/obsolete/intmuttree.rs
tests/obsolete/intmuttree.rs
use std::collections::HashMap; use xrust::item::{Node, NodeType}; use xrust::item_node_tests; use xrust::item_value_tests; use xrust::pattern_tests; use xrust::qname::QualifiedName; use xrust::transform::context::{Context, ContextBuilder, StaticContext, StaticContextBuilder}; use xrust::transform_tests; use xrust::trees::intmuttree::Document; use xrust::trees::intmuttree::{NodeBuilder, RNode}; use xrust::xdmerror::{Error, ErrorKind}; use xrust::xpath_tests; use xrust::xslt_tests; type F = Box<dyn FnMut(&str) -> Result<(), Error>>; fn make_empty_doc() -> RNode { NodeBuilder::new(NodeType::Document).build() } fn make_doc(n: QualifiedName, v: Value) -> RNode { let mut d = NodeBuilder::new(NodeType::Document).build(); let mut child = NodeBuilder::new(NodeType::Element).name(n).build(); d.push(child.clone()).expect("unable to append child"); child .push(NodeBuilder::new(NodeType::Text).value(Rc::new(v)).build()) .expect("unable to append child"); d } fn make_sd_raw() -> RNode { let r = Document::try_from(( "<a id='a1'><b id='b1'><a id='a2'><b id='b2'/><b id='b3'/></a><a id='a3'><b id='b4'/><b id='b5'/></a></b><b id='b6'><a id='a4'><b id='b7'/><b id='b8'/></a><a id='a5'><b id='b9'/><b id='b10'/></a></b></a>", None,None )) .expect("failed to parse XML"); r.content[0].clone() } fn make_sd() -> Item<RNode> { let r = make_sd_raw(); //let e = r.clone(); //let mut d = NodeBuilder::new(NodeType::Document).build(); //d.push(e).expect("unable to append node"); //Item::Node(d) Item::Node(r) } fn make_from_str(s: &str) -> Result<RNode, Error> { Ok(Document::try_from((s, None, None))?.content[0].clone()) } fn make_from_str_with_ns(s: &str) -> Result<(RNode, Vec<HashMap<String, String>>), Error> { let mut ns = HashMap::new(); ns.insert( String::from("xsl"), String::from("http://www.w3.org/1999/XSL/Transform"), ); Ok(( Document::try_from((s, None, None))?.content[0].clone(), vec![ns], )) } item_value_tests!(RNode); item_node_tests!(make_empty_doc, make_doc, make_sd_raw); pattern_tests!(RNode, make_empty_doc, make_sd); transform_tests!(RNode, make_empty_doc, make_doc); xpath_tests!(RNode, make_empty_doc, make_sd); xslt_tests!(make_from_str, make_empty_doc, make_from_str_with_ns);
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/node/mod.rs
tests/node/mod.rs
//! Generic node tests use std::rc::Rc; use xrust::item::{Node, NodeType}; use xrust::qname::QualifiedName; use xrust::value::Value; use xrust::xdmerror::Error; pub fn get_attr_node<N: Node, G>(make_doc: G) -> Result<(), Error> where G: Fn() -> N, { let mut sd = make_doc(); let t = sd.new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), )))?; sd.push(t.clone())?; let a1 = sd.new_attribute( Rc::new(QualifiedName::new(None, None, String::from("role"))), Rc::new(Value::from("testing")), )?; t.add_attribute(a1)?; let a2 = sd.new_attribute( Rc::new(QualifiedName::new(None, None, String::from("phase"))), Rc::new(Value::from("one")), )?; t.add_attribute(a2)?; // NB. attributes could be returned in a different order assert!( sd.to_xml() == "<Test role='testing' phase='one'></Test>" || sd.to_xml() == "<Test phase='one' role='testing'></Test>" ); match t.get_attribute_node(&QualifiedName::new(None, None, "role")) { Some(at) => { assert_eq!(at.node_type(), NodeType::Attribute); assert_eq!(at.to_string(), "testing"); Ok(()) } None => panic!("unable to find attribute \"role\""), } }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/xsltgeneric/mod.rs
tests/xsltgeneric/mod.rs
//! Tests for XSLT defined generically use pkg_version::{pkg_version_major, pkg_version_minor, pkg_version_patch}; use std::rc::Rc; use url::Url; use xrust::item::{Item, Node, Sequence, SequenceTrait}; use xrust::namespace::NamespaceMap; use xrust::transform::context::StaticContextBuilder; use xrust::xdmerror::{Error, ErrorKind}; use xrust::xslt::from_document; fn test_rig<N: Node, G, H, J>( src: impl AsRef<str>, style: impl AsRef<str>, parse_from_str: G, _parse_from_str_with_ns: J, make_doc: H, ) -> Result<Sequence<N>, Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { eprintln!("test_rig, parse source doc"); let srcdoc = parse_from_str(src.as_ref()).map_err(|e| { Error::new( e.kind, format!("error parsing source document: {}", e.message), ) })?; eprintln!("parse style doc"); let styledoc = parse_from_str(style.as_ref()) .map_err(|e| Error::new(e.kind, format!("error parsing stylesheet: {}", e.message)))?; let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let mut ctxt = from_document(styledoc, None, |s| parse_from_str(s), |_| Ok(String::new()))?; ctxt.context(vec![Item::Node(srcdoc.clone())], 0); ctxt.result_document(make_doc()?); ctxt.populate_key_values(&mut stctxt, srcdoc.clone())?; eprintln!("evaluate xform {:?}", ctxt); ctxt.evaluate(&mut stctxt) } fn test_msg_rig<N: Node, G, H, J>( src: impl AsRef<str>, style: impl AsRef<str>, parse_from_str: G, _parse_from_str_with_ns: J, make_doc: H, ) -> Result<(Sequence<N>, Vec<String>), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let srcdoc = parse_from_str(src.as_ref())?; let styledoc = parse_from_str(style.as_ref())?; let mut msgs: Vec<String> = vec![]; let mut stctxt = StaticContextBuilder::new() .message(|m| { msgs.push(String::from(m)); Ok(()) }) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let mut ctxt = from_document(styledoc, None, |s| parse_from_str(s), |_| Ok(String::new()))?; ctxt.context(vec![Item::Node(srcdoc.clone())], 0); ctxt.result_document(make_doc()?); let seq = ctxt.evaluate(&mut stctxt)?; Ok((seq, msgs)) } pub fn generic_literal_text<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><Level1>one</Level1><Level1>two</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'>Found the document</xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_string() == "Found the document" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"Found the document\"", result.to_string() ), )) } } pub fn generic_sys_prop<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><Level1>one</Level1><Level1>two</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:sequence select='system-property("xsl:version")'/>-<xsl:sequence select='system-property("xsl:product-version")'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_string() == format!( "0.9-{}.{}.{}", pkg_version_major!(), pkg_version_minor!(), pkg_version_patch!() ) { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"{}\"", result.to_string(), format!( "0.9-{}.{}.{}", pkg_version_major!(), pkg_version_minor!(), pkg_version_patch!() ) ), )) } } pub fn generic_value_of_1<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test>special &lt; less than</Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='child::*'><xsl:value-of select='.'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_string() == "special &lt; less than" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"special &lt; less than\"", result.to_string() ), )) } } pub fn generic_value_of_2<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test>special &lt; less than</Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='child::*'><xsl:value-of select='.' disable-output-escaping='yes'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_string() == "special < less than" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"special < less than\"", result.to_string() ), )) } } pub fn generic_literal_element<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><Level1>one</Level1><Level1>two</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><answer>Made an element</answer></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "<answer>Made an element</answer>" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"<answer>Made an element</answer>\"", result.to_string() ), )) } } pub fn generic_element<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><Level1>one</Level1><Level1>two</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:element name='answer{count(ancestor::*)}'>Made an element</xsl:element></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "<answer0>Made an element</answer0>" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"<answer0>Made an element</answer0>\"", result.to_string() ), )) } } pub fn generic_apply_templates_1<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><Level1>one</Level1><Level1>two</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::*'><xsl:apply-templates/></xsl:template> <xsl:template match='child::text()'>found text</xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "found textfound text" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"found textfound text\"", result.to_string() ), )) } } pub fn generic_apply_templates_2<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test>one<Level1/>two<Level1/>three<Level1/>four<Level1/></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'><xsl:apply-templates select='child::text()'/></xsl:template> <xsl:template match='child::Level1'>found Level1 element</xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "onetwothreefour" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"onetwothreefour\"", result.to_string() ), )) } } pub fn generic_apply_templates_mode<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test>one<Level1>a</Level1>two<Level1>b</Level1>three<Level1>c</Level1>four<Level1>d</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'><HEAD><xsl:apply-templates select='child::Level1' mode='head'/></HEAD><BODY><xsl:apply-templates select='child::Level1' mode='body'/></BODY></xsl:template> <xsl:template match='child::Level1' mode='head'><h1><xsl:apply-templates/></h1></xsl:template> <xsl:template match='child::Level1' mode='body'><p><xsl:apply-templates/></p></xsl:template> <xsl:template match='child::Level1'>should not see this</xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "<HEAD><h1>a</h1><h1>b</h1><h1>c</h1><h1>d</h1></HEAD><BODY><p>a</p><p>b</p><p>c</p><p>d</p></BODY>" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"<HEAD><h1>a</h1><h1>b</h1><h1>c</h1><h1>d</h1></HEAD><BODY><p>a</p><p>b</p><p>c</p><p>d</p></BODY>\"", result.to_xml() ), )) } } pub fn generic_apply_templates_sort<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test>one<Level1>a</Level1>two<Level1>b</Level1>three<Level1>c</Level1>four<Level1>d</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'><xsl:apply-templates><xsl:sort select='.'/></xsl:apply-templates></xsl:template> <xsl:template match='child::Level1'><L><xsl:apply-templates/></L></xsl:template> <xsl:template match='child::Test/child::text()'><p><xsl:sequence select='.'/></p></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "<L>a</L><L>b</L><L>c</L><L>d</L><p>four</p><p>one</p><p>three</p><p>two</p>" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"<L>a</L><L>b</L><L>c</L><L>d</L><p>four</p><p>one</p><p>three</p><p>two</p>\"", result.to_xml() ), )) } } pub fn generic_comment<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test>one<Level1/>two<Level1/>three<Level1/>four<Level1/></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Level1'><xsl:comment> this is a level 1 element </xsl:comment></xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "one<!-- this is a level 1 element -->two<!-- this is a level 1 element -->three<!-- this is a level 1 element -->four<!-- this is a level 1 element -->" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, format!("got result \"{}\", expected \"one<!-- this is a level 1 element -->two<!-- this is a level 1 element -->three<!-- this is a level 1 element -->four<!-- this is a level 1 element -->\"", result.to_string()))) } } pub fn generic_pi<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test>one<Level1/>two<Level1/>three<Level1/>four<Level1/></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Level1'><xsl:processing-instruction name='piL1'>this is a level 1 element</xsl:processing-instruction></xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "one<?piL1 this is a level 1 element?>two<?piL1 this is a level 1 element?>three<?piL1 this is a level 1 element?>four<?piL1 this is a level 1 element?>" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, format!("got result \"{}\", expected \"one<?piL1 this is a level 1 element?>two<?piL1 this is a level 1 element?>three<?piL1 this is a level 1 element?>four<?piL1 this is a level 1 element?>\"", result.to_string()))) } } pub fn generic_current<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test ref='one'><second name='foo'>I am foo</second><second name='one'>I am one</second></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'> <xsl:sequence select='child::*/child::second[attribute::name eq current()/attribute::ref]'/> </xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "<second name='one'>I am one</second>" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"<second name='one'>I am one</second>\"", result.to_string() ), )) } } pub fn generic_key_1<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><one>blue</one><two>yellow</two><three>green</three><four>blue</four></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:key name='mykey' match='child::*' use='child::text()'/> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'>#blue = <xsl:sequence select='count(key("mykey", "blue"))'/></xsl:template> <xsl:template match='child::Test/child::*'>shouldn't see this</xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "#blue = 2" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"#blue = 2\"", result.to_string() ), )) } } // Although we have the source and stylesheet in files, // they are inlined here to avoid dependency on I/O libraries pub fn generic_issue_58<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( r#"<Example> <Title>XSLT in Rust</Title> <Paragraph>A simple document.</Paragraph> </Example> "#, r#"<xsl:stylesheet version="1.0" xmlns:dat="http://www.stormware.cz/schema/version_2/data.xsd" xmlns:int="http://www.stormware.cz/schema/version_2/intDoc.xsd" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="utf-8" indent="yes"/> <xsl:template match="child::Example"> <dat:dataPack> <xsl:apply-templates/> </dat:dataPack> </xsl:template> <xsl:template match="child::Title"> <int:head> <xsl:apply-templates/> </int:head> </xsl:template> <xsl:template match="child::Paragraph"> <int:body> <xsl:apply-templates/> </int:body> </xsl:template> </xsl:stylesheet> "#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == r#"<dat:dataPack xmlns:dat='http://www.stormware.cz/schema/version_2/data.xsd'> <int:head xmlns:int='http://www.stormware.cz/schema/version_2/intDoc.xsd'>XSLT in Rust</int:head> <int:body xmlns:int='http://www.stormware.cz/schema/version_2/intDoc.xsd'>A simple document.</int:body> </dat:dataPack>"# { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!("not expected result"), )) } } pub fn generic_issue_95<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><Level1>one</Level1><Level1>two</Level1></Test>", r#"<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "<Test><Level1>one</Level1><Level1>two</Level1></Test>" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"Found the document\"", result.to_xml() ), )) } } pub fn generic_message_1<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let (result, msgs) = test_msg_rig( "<Test>one<Level1/>two<Level1/>three<Level1/>four<Level1/></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Level1'><xsl:message>here is a level 1 element</xsl:message><L/></xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_xml() == "one<L></L>two<L></L>three<L></L>four<L></L>" { if msgs.len() == 4 { if msgs[0] == "here is a level 1 element" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got message \"{}\", expected \"here is a level 1 element\"", msgs[0] ), )) } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} messages, expected 4", msgs.len()), )) } } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"one<L></L>two<L></L>three<L></L>four<L></L>\"", result.to_string() ), )) } } pub fn generic_message_term<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { match test_msg_rig( "<Test>one<Level1/>two<Level1/>three<Level1/>four<Level1/></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Level1'><xsl:message terminate='yes'>here is a level 1 element</xsl:message><L/></xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, ) { Err(e) => { if e.kind == ErrorKind::Terminated && e.message == "here is a level 1 element" && e.code.unwrap().to_string() == "XTMM9000" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "incorrect error")) } } Ok(_) => Err(Error::new( ErrorKind::Unknown, "evaluation succeeded when it should have failed", )), } } pub fn generic_callable_named_1<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><one>blue</one><two>yellow</two><three>green</three><four>blue</four></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'> <xsl:call-template name='my_template'> <xsl:with-param name='my_param' select='count(child::*)'/> </xsl:call-template> </xsl:template> <xsl:template name='my_template'> <xsl:param name='my_param'>default value</xsl:param> <xsl:text>There are </xsl:text> <xsl:sequence select='$my_param'/> <xsl:text> child elements</xsl:text> </xsl:template> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_string() == "There are 4 child elements" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"There are 4 child elements\"", result.to_string() ), )) } } pub fn generic_callable_posn_1<N: Node, G, H, J>( parse_from_str: G, parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let result = test_rig( "<Test><one>blue</one><two>yellow</two><three>green</three><four>blue</four></Test>", r#"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:eg='http://example.org/'> <xsl:template match='/'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Test'> <xsl:sequence select='eg:my_func(count(child::*))'/> </xsl:template> <xsl:function name='eg:my_func'> <xsl:param name='my_param'/> <xsl:text>There are </xsl:text> <xsl:sequence select='$my_param'/> <xsl:text> child elements</xsl:text> </xsl:function> </xsl:stylesheet>"#, parse_from_str, parse_from_str_with_ns, make_doc, )?; if result.to_string() == "There are 4 child elements" { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!( "got result \"{}\", expected \"There are 4 child elements\"", result.to_string() ), )) } } pub fn generic_include<N: Node, G, H, J>( parse_from_str: G, _parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let srcdoc = parse_from_str("<Test>one<Level1/>two<Level2/>three<Level3/>four<Level4/></Test>")?; let styledoc = parse_from_str( "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:include href='included.xsl'/> <xsl:template match='child::Test'><xsl:apply-templates/></xsl:template> <xsl:template match='child::Level1'>found Level1 element</xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>", )?; let pwd = std::env::current_dir().expect("unable to get current directory"); let pwds = pwd .into_os_string() .into_string() .expect("unable to convert pwd"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let mut ctxt = from_document( styledoc, Some( Url::parse(format!("file://{}/tests/xsl/including.xsl", pwds.as_str()).as_str()) .expect("unable to parse URL"), ), |s| parse_from_str(s), |_| Ok(String::new()), )?; ctxt.context(vec![Item::Node(srcdoc.clone())], 0); ctxt.result_document(make_doc()?); let result = ctxt.evaluate(&mut stctxt)?; if result.to_string() == "onefound Level1 elementtwofound Level2 elementthreefound Level3 elementfour" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, format!("got result \"{}\", expected \"onefound Level1 elementtwofound Level2 elementthreefound Level3 elementfour\"", result.to_string()))) } } pub fn generic_document_1<N: Node, G, H, J>( parse_from_str: G, _parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let srcdoc = parse_from_str("<Test><internal>on the inside</internal></Test>")?; let styledoc = parse_from_str( r##"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='child::Test'><xsl:apply-templates/>|<xsl:apply-templates select='document("urn::test.org/test")'/></xsl:template> <xsl:template match='child::internal'>found internal element</xsl:template> <xsl:template match='child::external'>found external element</xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"##, )?; let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_url| { Ok(String::from( "<Outside><external>from outside</external></Outside>", )) }) .parser(|s| parse_from_str(s)) .build(); let mut ctxt = from_document(styledoc, None, |s| parse_from_str(s), |_| Ok(String::new()))?; ctxt.context(vec![Item::Node(srcdoc.clone())], 0); ctxt.result_document(make_doc()?); let result = ctxt.evaluate(&mut stctxt)?; if result.to_string() == "found internal element|found external element" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, format!("got result \"{}\", expected \"onefound Level1 elementtwofound Level2 elementthreefound Level3 elementfour\"", result.to_string()))) } } pub fn generic_number_1<N: Node, G, H, J>( parse_from_str: G, _parse_from_str_with_ns: J, make_doc: H, ) -> Result<(), Error> where G: Fn(&str) -> Result<N, Error>, H: Fn() -> Result<N, Error>, J: Fn(&str) -> Result<(N, Rc<NamespaceMap>), Error>, { let srcdoc = parse_from_str("<Test><t>one</t><t>two</t><t>three</t></Test>")?; let styledoc = parse_from_str( r##"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='child::Test'><xsl:apply-templates/></xsl:template> <xsl:template match='child::t'>t element <xsl:number/></xsl:template> <xsl:template match='child::text()'><xsl:sequence select='.'/></xsl:template> </xsl:stylesheet>"##, )?; let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_url| Ok(String::new())) .parser(|s| parse_from_str(s)) .build(); let mut ctxt = from_document(styledoc, None, |s| parse_from_str(s), |_| Ok(String::new()))?; ctxt.context(vec![Item::Node(srcdoc.clone())], 0); ctxt.result_document(make_doc()?); let result = ctxt.evaluate(&mut stctxt)?; assert_eq!(result.to_string(), "t element 1t element 2t element 3"); Ok(()) } pub fn attr_set_1<N: Node, G, H, J>(
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/patterngeneric/mod.rs
tests/patterngeneric/mod.rs
//! Tests for pattern module defined generically use std::rc::Rc; use xrust::ErrorKind; use xrust::item::{Item, Node}; use xrust::pattern::Pattern; use xrust::qname::QualifiedName; use xrust::transform::context::{Context, StaticContextBuilder}; use xrust::value::Value; use xrust::xdmerror::Error; pub fn pattern_empty<N: Node>() -> Result<(), Error> { let _: Pattern<N> = Pattern::try_from("").expect("unable to parse empty string"); Ok(()) } pub fn pattern_predicate_1_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from(".[self::a]").expect("unable to parse \".[self::a]\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), true ); Ok(()) } pub fn pattern_predicate_1_neg<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from(".[self::a]").expect("unable to parse \".[self::a]\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(b))), false ); Ok(()) } pub fn pattern_sel_root_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("/").expect("unable to parse \"/\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(sd))), true ); Ok(()) } pub fn pattern_sel_root_neg<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("/").expect("unable to parse \"/\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), false ); Ok(()) } pub fn pattern_sel_1_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("child::a").expect("unable to parse \"child::a\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), true ); Ok(()) } pub fn pattern_sel_1_neg<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("child::a").expect("unable to parse \"child::a\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(b))), false ); Ok(()) } pub fn pattern_sel_2_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("child::Test/child::a") .expect("unable to parse \"child::Test/child::a\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), true ); Ok(()) } pub fn pattern_sel_2_neg<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("child::Test/child::a") .expect("unable to parse \"child::Test/child::a\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("NotATest"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), false ); Ok(()) } pub fn pattern_abbrev_1_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("a").expect("unable to parse \"a\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), true ); Ok(()) } pub fn pattern_abbrev_1_neg<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("a").expect("unable to parse \"a\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(b))), false ); Ok(()) } pub fn pattern_abbrev_2_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("/Test/a").expect("unable to parse \"/Test/a\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), true ); Ok(()) } pub fn pattern_abbrev_2_neg<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("/a/b").expect("unable to parse \"/a/b\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(b))), false ); Ok(()) } pub fn abbrev_3_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("/Example").expect("unable to parse \"/Example\""); if p.is_err() { return Err(p.get_err().unwrap()); } // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Example"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(t))), true ); Ok(()) } pub fn abbrev_3_neg<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("/Example").expect("unable to parse \"/Example\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Example"), ))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), false ); Ok(()) } pub fn pattern_sel_text_kind_1_pos<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("child::text()").expect("unable to parse \"child::text()\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a.clone()).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(t_a))), true ); Ok(()) } pub fn pattern_issue_95<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("@*|node()").expect("unable to parse \"@*|node()\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a.clone()).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(t_a))), true ); Ok(()) } pub fn pattern_union_1<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("c|b").expect("unable to parse \"c|b\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a.clone()).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(a))), false ); Ok(()) } pub fn pattern_union_2<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("c|b").expect("unable to parse \"c|b\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a.clone()).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(b))), true ); Ok(()) } pub fn pattern_union_3<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("(a|b)/(c|d)").expect("unable to parse \"(a|b)/(c|d)\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a.clone()).expect("unable to append text node"); let mut b = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("b")))) .expect("unable to create element"); t.push(b.clone()).expect("unable to append child"); let t_b = sd .new_text(Rc::new(Value::from("second"))) .expect("unable to create text node"); b.push(t_b).expect("unable to append text node"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); assert_eq!( p.matches(&Context::new(), &mut stctxt, &Rc::new(Item::Node(b))), false ); Ok(()) } pub fn pattern_union_4<N: Node, G>(make_empty_doc: G) -> Result<(), Error> where G: Fn() -> N, { let p: Pattern<N> = Pattern::try_from("(a|b)/(c|d)").expect("unable to parse \"(a|b)/(c|d)\""); // Setup a source document let mut sd = make_empty_doc(); let mut t = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(t.clone()).expect("unable to append child"); let mut a = sd .new_element(Rc::new(QualifiedName::new(None, None, String::from("a")))) .expect("unable to create element"); t.push(a.clone()).expect("unable to append child"); let t_a = sd .new_text(Rc::new(Value::from("first"))) .expect("unable to create text node"); a.push(t_a.clone()).expect("unable to append text node");
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/transformgeneric/mod.rs
tests/transformgeneric/mod.rs
//! Tests for transform module defined generically use chrono::{Datelike, Local, Timelike}; use std::rc::Rc; use xrust::item::{Item, Node, SequenceTrait}; use xrust::namespace::NamespaceMap; use xrust::pattern::Pattern; use xrust::qname::QualifiedName; use xrust::transform::callable::{ActualParameters, Callable, FormalParameters}; use xrust::transform::context::{Context, ContextBuilder, StaticContextBuilder}; use xrust::transform::numbers::{Level, Numbering}; use xrust::transform::template::Template; use xrust::transform::{ ArithmeticOperand, ArithmeticOperator, Axis, Grouping, KindTest, NameTest, NodeMatch, NodeTest, Order, Transform, WildcardOrName, }; use xrust::value::{Operator, Value}; use xrust::xdmerror::{Error, ErrorKind}; pub fn generic_tr_empty<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::<N>::Empty; let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.len(), 0); Ok(()) } pub fn generic_tr_singleton_literal<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::Literal(Item::<N>::Value(Rc::new(Value::from("this is a test")))); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.to_string(), "this is a test"); Ok(()) } pub fn generic_tr_literal_element<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "content", ))))), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test>content</Test>"); Ok(()) } pub fn generic_tr_literal_element_nested<N: Node, G, H>( make_empty_doc: G, _: H, ) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Level-1"))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "content", ))))), )), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test><Level-1>content</Level-1></Test>"); Ok(()) } pub fn generic_tr_element<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::Element( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "Test", ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "content", ))))), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test>content</Test>"); Ok(()) } pub fn generic_tr_literal_text_1<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::LiteralText( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "special character: < less than", ))))), false, ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "special character: &lt; less than"); Ok(()) } pub fn generic_tr_literal_text_2<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::LiteralText( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "special character: < less than", ))))), true, ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "special character: < less than"); Ok(()) } pub fn generic_tr_literal_attribute<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::SequenceItems(vec![ Transform::LiteralAttribute( Rc::new(QualifiedName::new(None, None, String::from("foo"))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "bar", ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("content")))), ])), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test foo='bar'>content</Test>"); Ok(()) } pub fn generic_tr_literal_comment<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::SequenceItems(vec![ Transform::LiteralComment(Box::new(Transform::Literal(Item::<N>::Value(Rc::new( Value::from("bar"), ))))), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("content")))), ])), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test><!--bar-->content</Test>"); Ok(()) } pub fn generic_tr_literal_pi<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::SequenceItems(vec![ Transform::LiteralProcessingInstruction( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "thepi", ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "bar", ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("content")))), ])), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test><?thepi bar?>content</Test>"); Ok(()) } pub fn generic_tr_generate_id_ctxt<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::GenerateId(None); let sd = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().context(vec![Item::Node(sd)]).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert!(seq.to_string().len() > 1); Ok(()) } pub fn generic_tr_generate_id_2<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x1 = Transform::GenerateId(Some(Box::new(Transform::Step(NodeMatch { axis: Axis::Child, nodetest: NodeTest::Name(NameTest::new( None, None, Some(WildcardOrName::Name(Rc::new(Value::from("Test1")))), )), })))); let x2 = Transform::GenerateId(Some(Box::new(Transform::Step(NodeMatch { axis: Axis::Child, nodetest: NodeTest::Name(NameTest::new( None, None, Some(WildcardOrName::Name(Rc::new(Value::from("Test2")))), )), })))); let mut sd = make_empty_doc(); let n1 = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test1"), ))) .expect("unable to create element"); sd.push(n1.clone()).expect("unable to append child"); let n2 = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test2"), ))) .expect("unable to create element"); sd.push(n2.clone()).expect("unable to append child"); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().context(vec![Item::Node(sd)]).build(); let seq1 = ctxt.dispatch(&mut stctxt, &x1).expect("evaluation failed"); let seq2 = ctxt.dispatch(&mut stctxt, &x2).expect("evaluation failed"); assert!(seq1.to_string().len() > 1); assert!(seq2.to_string().len() > 1); assert_ne!(seq1.to_string(), seq2.to_string()); Ok(()) } pub fn generic_tr_message_1<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let mut receiver = String::from("no message received"); let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::SequenceItems(vec![ Transform::Message( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "bar", ))))), None, Box::new(Transform::Empty), Box::new(Transform::Empty), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("content")))), ])), ); let mydoc = make_empty_doc(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let mut stctxt = StaticContextBuilder::new() .message(|m| { receiver = String::from(m); Ok(()) }) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test>content</Test>"); assert_eq!(receiver, "bar"); Ok(()) } pub fn generic_tr_message_2<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let mut messages: Vec<String> = vec![]; let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::SequenceItems(vec![ Transform::Message( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "first message", ))))), None, Box::new(Transform::Empty), Box::new(Transform::Empty), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("content")))), Transform::Message( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "second message", ))))), None, Box::new(Transform::Empty), Box::new(Transform::Empty), ), ])), ); let mydoc = make_empty_doc(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let mut stctxt = StaticContextBuilder::new() .message(|m| { messages.push(String::from(m)); Ok(()) }) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.to_xml(), "<Test>content</Test>"); assert_eq!(messages.len(), 2); assert_eq!(messages[0], "first message"); assert_eq!(messages[1], "second message"); Ok(()) } pub fn generic_tr_message_term_1<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let mut receiver = String::from("no message received"); let x = Transform::LiteralElement( Rc::new(QualifiedName::new(None, None, String::from("Test"))), Box::new(Transform::SequenceItems(vec![ Transform::Message( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "bar", ))))), None, Box::new(Transform::Empty), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "yes", ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("content")))), ])), ); let mydoc = make_empty_doc(); let ctxt = ContextBuilder::new().result_document(mydoc).build(); let mut stctxt = StaticContextBuilder::new() .message(|m| { receiver = String::from(m); Ok(()) }) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); match ctxt.dispatch(&mut stctxt, &x) { Ok(_) => panic!("evaluation succeeded when it should have failed"), Err(e) => { assert_eq!(e.kind, ErrorKind::Terminated); assert_eq!(e.message, "bar"); assert_eq!(e.code.unwrap().to_string(), "XTMM9000"); Ok(()) } } } pub fn generic_tr_set_attribute<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { // Setup a source document let mut sd = make_empty_doc(); let n = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(n.clone()).expect("unable to append child"); let x = Transform::SetAttribute( Rc::new(QualifiedName::new(None, None, String::from("foo"))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "bar", ))))), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new() .result_document(mydoc) .context(vec![Item::Node(n)]) .build(); let _ = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(sd.to_xml(), "<Test foo='bar'></Test>"); Ok(()) } pub fn generic_tr_copy_literal<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::Copy( Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "this is the original", ))))), Box::new(Transform::<N>::Empty), ); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.len(), 1); assert_eq!(seq.to_string(), "this is the original"); Ok(()) } pub fn generic_tr_copy_context_literal<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::Copy( Box::new(Transform::ContextItem), Box::new(Transform::<N>::Empty), ); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = ContextBuilder::new() .context(vec![Item::<N>::Value(Rc::new(Value::from( "this is the original", )))]) .build() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.len(), 1); assert_eq!(seq.to_string(), "this is the original"); Ok(()) } pub fn generic_tr_copy_context_node<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { // Setup a source document let mut sd = make_empty_doc(); let mut n = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(n.clone()).expect("unable to append child"); n.push( sd.new_text(Rc::new(Value::from("this is the original"))) .expect("unable to create text node"), ) .expect("unable to add text node"); let x = Transform::Copy( Box::new(Transform::ContextItem), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "this is the copy", ))))), ); let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new() .result_document(mydoc) .context(vec![Item::Node(n)]) .build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.len(), 1); assert_eq!(seq.to_xml(), "<Test>this is the copy</Test>"); assert_eq!(sd.to_xml(), "<Test>this is the original</Test>"); Ok(()) } pub fn generic_tr_current_node<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { // Setup a source document let mut sd = make_empty_doc(); let mut n = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(n.clone()).expect("unable to append child"); n.push( sd.new_text(Rc::new(Value::from("this is the original"))) .expect("unable to create text node"), ) .expect("unable to add text node"); let x = Transform::CurrentItem; let mydoc = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new() .result_document(mydoc) .context(vec![Item::Node(n.clone())]) .previous_context(Some(Item::Node(n.clone()))) .build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.len(), 1); assert_eq!(seq.to_xml(), "<Test>this is the original</Test>"); Ok(()) } pub fn generic_tr_deep_copy<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { // Setup a source document let mut sd = make_empty_doc(); let mut n = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("Test"), ))) .expect("unable to create element"); sd.push(n.clone()).expect("unable to append child"); let mut u = sd .new_element(Rc::new(QualifiedName::new( None, None, String::from("inner"), ))) .expect("unable to create element"); n.push(u.clone()).expect("unable to append child"); u.push( sd.new_text(Rc::new(Value::from("this is the original"))) .expect("unable to create text node"), ) .expect("unable to add text node"); let x = Transform::DeepCopy(Box::new(Transform::ContextItem)); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let ctxt = ContextBuilder::new().context(vec![Item::Node(n)]).build(); let seq = ctxt.dispatch(&mut stctxt, &x).expect("evaluation failed"); assert_eq!(seq.len(), 1); assert_eq!( seq.to_xml(), "<Test><inner>this is the original</inner></Test>" ); Ok(()) } pub fn generic_tr_seq_of_literals<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::SequenceItems(vec![ Transform::Literal(Item::<N>::Value(Rc::new(Value::from("this is a test")))), Transform::Literal(Item::<N>::Value(Rc::new(Value::from(1)))), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("end of test")))), ]); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.len(), 3); assert_eq!(seq.to_string(), "this is a test1end of test"); Ok(()) } pub fn generic_tr_seq_of_seqs<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::SequenceItems(vec![ Transform::SequenceItems(vec![ Transform::Literal(Item::<N>::Value(Rc::new(Value::from("first sequence")))), Transform::Literal(Item::<N>::Value(Rc::new(Value::from(1)))), ]), Transform::SequenceItems(vec![ Transform::Literal(Item::<N>::Value(Rc::new(Value::from("second sequence")))), Transform::Literal(Item::<N>::Value(Rc::new(Value::from(2)))), ]), ]); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.len(), 4); assert_eq!(seq.to_string(), "first sequence1second sequence2"); Ok(()) } pub fn generic_tr_switch_when<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::Switch( vec![ ( Transform::ValueComparison( Operator::Equal, Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 1, ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 2.0, ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("comparison failed")))), ), ( Transform::ValueComparison( Operator::Equal, Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 1, ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 1.0, ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "comparison succeeded", )))), ), ( Transform::ValueComparison( Operator::Equal, Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 1, ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 3.0, ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("comparison failed")))), ), ], Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "otherwise clause", ))))), ); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.to_string(), "comparison succeeded"); Ok(()) } pub fn generic_tr_switch_otherwise<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::Switch( vec![ ( Transform::ValueComparison( Operator::Equal, Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 1, ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 2.0, ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("comparison failed")))), ), ( Transform::ValueComparison( Operator::Equal, Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 1, ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 11.0, ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("comparison failed")))), ), ( Transform::ValueComparison( Operator::Equal, Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 1, ))))), Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( 3.0, ))))), ), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("comparison failed")))), ), ], Box::new(Transform::Literal(Item::<N>::Value(Rc::new(Value::from( "otherwise clause", ))))), ); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.to_string(), "otherwise clause"); Ok(()) } pub fn generic_tr_loop_lit<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::Loop( vec![( String::from("x"), Transform::SequenceItems(vec![ Transform::Literal(Item::<N>::Value(Rc::new(Value::from("one")))), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("two")))), Transform::Literal(Item::<N>::Value(Rc::new(Value::from("three")))), ]), )], Box::new(Transform::Concat(vec![ Transform::VariableReference(String::from("x"), Rc::new(NamespaceMap::new())), Transform::VariableReference(String::from("x"), Rc::new(NamespaceMap::new())), ])), ); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let seq = Context::new() .dispatch(&mut stctxt, &x) .expect("evaluation failed"); assert_eq!(seq.to_string(), "oneonetwotwothreethree"); Ok(()) } pub fn generic_tr_context_item<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let x = Transform::ContextItem; let c = Context::from(vec![Item::<N>::Value(Rc::new(Value::from( "the context item", )))]); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(()))
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/smite/mod.rs
tests/smite/mod.rs
// Support functions for smite tests use std::rc::Rc; use xrust::item::{Item, Node}; use xrust::namespace::NamespaceMap; use xrust::parser::xml::{parse as xmlparse, parse_with_ns}; use xrust::qname::QualifiedName; use xrust::trees::smite::RNode; use xrust::value::Value; use xrust::xdmerror::Error; #[allow(dead_code)] pub fn make_empty_doc() -> RNode { RNode::new_document() } #[allow(dead_code)] pub fn make_empty_doc_cooked() -> Result<RNode, Error> { Ok(RNode::new_document()) } #[allow(dead_code)] pub fn make_doc(n: Rc<QualifiedName>, v: Value) -> RNode { let mut d = RNode::new_document(); let mut child = d.new_element(n).expect("unable to create element"); d.push(child.clone()).expect("unable to add element node"); child .push( child .new_text(Rc::new(v)) .expect("unable to create text node"), ) .expect("unable to add text node"); d } #[allow(dead_code)] pub fn make_sd_raw() -> RNode { let doc = RNode::new_document(); xmlparse(doc.clone(), "<a id='a1'><b id='b1'><a id='a2'><b id='b2'/><b id='b3'/></a><a id='a3'><b id='b4'/><b id='b5'/></a></b><b id='b6'><a id='a4'><b id='b7'/><b id='b8'/></a><a id='a5'><b id='b9'/><b id='b10'/></a></b></a>", None).expect("unable to parse XML"); doc } #[allow(dead_code)] pub fn make_sd_cooked() -> Result<RNode, Error> { Ok(make_sd_raw()) } #[allow(dead_code)] pub fn make_sd() -> Item<RNode> { Item::Node(make_sd_raw()) } #[allow(dead_code)] pub fn make_from_str(s: &str) -> Result<RNode, Error> { let doc = RNode::new_document(); xmlparse(doc.clone(), s, None)?; Ok(doc) } #[allow(dead_code)] pub fn make_from_str_with_ns(s: &str) -> Result<(RNode, Rc<NamespaceMap>), Error> { let doc = RNode::new_document(); let r = parse_with_ns(doc.clone(), s, None)?; Ok(r) }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/xpathgeneric/mod.rs
tests/xpathgeneric/mod.rs
//! Tests for XPath defined generically use pkg_version::{pkg_version_major, pkg_version_minor, pkg_version_patch}; use std::rc::Rc; use xrust::item::{Item, Node, NodeType, Sequence, SequenceTrait}; use xrust::parser::xpath::parse; use xrust::pattern::Pattern; use xrust::qname::QualifiedName; use xrust::transform::callable::ActualParameters; use xrust::transform::context::{Context, ContextBuilder, StaticContextBuilder}; use xrust::transform::{Axis, KindTest, NodeMatch, NodeTest, Transform}; use xrust::value::Value; use xrust::xdmerror::{Error, ErrorKind}; fn no_src_no_result<N: Node>(e: impl AsRef<str>) -> Result<Sequence<N>, Error> { let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); Context::new().dispatch(&mut stctxt, &parse(e.as_ref(), None)?) } fn dispatch_rig<N: Node, G, H>( e: impl AsRef<str>, make_empty_doc: G, make_doc: H, ) -> Result<Sequence<N>, Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let rd = make_empty_doc(); ContextBuilder::new() .context(vec![make_doc()]) .result_document(rd) .build() .dispatch(&mut stctxt, &parse(e.as_ref(), None)?) } pub fn generic_empty<N: Node>() -> Result<(), Error> { let result: Sequence<N> = no_src_no_result("")?; if result.len() == 0 { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, format!("got result \"{}\", expected \"\"", result.to_string()), )) } } pub fn generic_step_1_pos<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = dispatch_rig("child::a", make_empty_doc, make_doc)?; if result.len() == 1 { match &result[0] { Item::Node(n) => match (n.node_type(), n.name().to_string().as_str()) { (NodeType::Element, "a") => Ok(()), (NodeType::Element, _) => Err(Error::new( ErrorKind::Unknown, format!( "got element named \"{}\", expected \"a\"", result[0].name().to_string() ), )), _ => Err(Error::new(ErrorKind::Unknown, "not an element type node")), }, _ => Err(Error::new(ErrorKind::Unknown, "not a node")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got result \"{}\", expected \"\"", result.to_string()), )) } } pub fn generic_step_2_pos<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { // Abbreviated from child::a let result: Sequence<N> = dispatch_rig("a", make_empty_doc, make_doc)?; if result.len() == 1 { match &result[0] { Item::Node(n) => match (n.node_type(), n.name().to_string().as_str()) { (NodeType::Element, "a") => Ok(()), (NodeType::Element, _) => Err(Error::new( ErrorKind::Unknown, format!( "got element named \"{}\", expected \"a\"", result[0].name().to_string() ), )), _ => Err(Error::new(ErrorKind::Unknown, "not an element type node")), }, _ => Err(Error::new(ErrorKind::Unknown, "not a node")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got result \"{}\", expected \"\"", result.to_string()), )) } } pub fn generic_path_1_pos<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = dispatch_rig("/child::a", make_empty_doc, make_doc)?; if result.len() == 1 { match &result[0] { Item::Node(n) => match (n.node_type(), n.name().to_string().as_str()) { (NodeType::Element, "a") => Ok(()), (NodeType::Element, _) => Err(Error::new( ErrorKind::Unknown, format!( "got element named \"{}\", expected \"a\"", result[0].name().to_string() ), )), _ => Err(Error::new(ErrorKind::Unknown, "not an element type node")), }, _ => Err(Error::new(ErrorKind::Unknown, "not a node")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got result \"{}\", expected \"\"", result.to_string()), )) } } pub fn generic_path_2_pos<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = dispatch_rig("/a", make_empty_doc, make_doc)?; if result.len() == 1 { match &result[0] { Item::Node(n) => match (n.node_type(), n.name().to_string().as_str()) { (NodeType::Element, "a") => Ok(()), (NodeType::Element, _) => Err(Error::new( ErrorKind::Unknown, format!( "got element named \"{}\", expected \"a\"", result[0].name().to_string() ), )), _ => Err(Error::new(ErrorKind::Unknown, "not an element type node")), }, _ => Err(Error::new(ErrorKind::Unknown, "not a node")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got result \"{}\", expected \"\"", result.to_string()), )) } } pub fn generic_path_1_neg<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = dispatch_rig("/child::b", make_empty_doc, make_doc)?; if result.len() == 0 { Ok(()) } else { Err(Error::new( ErrorKind::Unknown, "found node, expected nothing", )) } } pub fn generic_path_3<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = dispatch_rig("/child::a/child::b", make_empty_doc, make_doc)?; if result.len() == 2 { match &result[0] { Item::Node(n) => match (n.node_type(), n.name().to_string().as_str()) { (NodeType::Element, "b") => Ok(()), (NodeType::Element, _) => Err(Error::new( ErrorKind::Unknown, format!( "got element named \"{}\", expected \"a\"", result[0].name().to_string() ), )), _ => Err(Error::new(ErrorKind::Unknown, "not an element type node")), }, _ => Err(Error::new(ErrorKind::Unknown, "not a node")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 0", result.len()), )) } } pub fn generic_path_4<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = dispatch_rig("/a/b", make_empty_doc, make_doc)?; if result.len() == 2 { match &result[0] { Item::Node(n) => match (n.node_type(), n.name().to_string().as_str()) { (NodeType::Element, "b") => Ok(()), (NodeType::Element, _) => Err(Error::new( ErrorKind::Unknown, format!( "got element named \"{}\", expected \"a\"", result[0].name().to_string() ), )), _ => Err(Error::new(ErrorKind::Unknown, "not an element type node")), }, _ => Err(Error::new(ErrorKind::Unknown, "not a node")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 0", result.len()), )) } } pub fn generic_root_desc_or_self_1<N: Node, G, H>( make_empty_doc: G, make_doc: H, ) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("//child::a", make_empty_doc, make_doc)?; assert_eq!(s.len(), 5); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Element); assert_eq!(n.name().to_string(), "a") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_root_desc_or_self_2<N: Node, G, H>( make_empty_doc: G, make_doc: H, ) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("//child::a/child::b", make_empty_doc, make_doc)?; assert_eq!(s.len(), 10); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Element); assert_eq!(n.name().to_string(), "b") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_root_desc_or_self_3<N: Node, G, H>( make_empty_doc: G, make_doc: H, ) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("//child::a//child::b", make_empty_doc, make_doc)?; assert_eq!(s.len(), 10); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Element); assert_eq!(n.name().to_string(), "b") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_rel_path_1<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("child::a/child::b", make_empty_doc, make_doc)?; assert_eq!(s.len(), 2); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Element); assert_eq!(n.name().to_string(), "b") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_rel_path_2<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("child::a//child::b", make_empty_doc, make_doc)?; assert_eq!(s.len(), 10); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Element); assert_eq!(n.name().to_string(), "b") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_step_2<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("child::bc", make_empty_doc, make_doc)?; assert_eq!(s.len(), 0); Ok(()) } pub fn generic_step_wild_1<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("child::*", make_empty_doc, make_doc)?; assert_eq!(s.len(), 1); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Element); assert_eq!(n.name().to_string(), "a") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_step_attribute_1<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("/child::*/attribute::id", make_empty_doc, make_doc)?; assert_eq!(s.len(), 1); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Attribute); assert_eq!(n.name().to_string(), "id"); assert_eq!(n.value().to_string(), "a1") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_step_attribute_2<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("/child::*/@id", make_empty_doc, make_doc)?; assert_eq!(s.len(), 1); for t in s { match &t { Item::Node(n) => { assert_eq!(n.node_type(), NodeType::Attribute); assert_eq!(n.name().to_string(), "id"); assert_eq!(n.value().to_string(), "a1") } _ => panic!("not a node"), } } Ok(()) } pub fn generic_step_parent_1<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let rd = make_empty_doc(); let sd = make_doc(); match &sd { Item::Node(c) => { let l = c.descend_iter().last().unwrap(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let s = ContextBuilder::new() .context(vec![Item::Node(l)]) .result_document(rd) .build() .dispatch(&mut stctxt, &parse("parent::a", None)?)?; assert_eq!(s.len(), 1); assert_eq!(s[0].name().to_string(), "a") } _ => panic!("unable to unpack node"), } Ok(()) } pub fn generic_step_parent_2<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let rd = make_empty_doc(); let sd = make_doc(); match &sd { Item::Node(c) => { let l = c.descend_iter().last().unwrap(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let s = ContextBuilder::new() .context(vec![Item::Node(l)]) .result_document(rd) .build() .dispatch(&mut stctxt, &parse("..", None)?)?; assert_eq!(s.len(), 1); assert_eq!(s[0].name().to_string(), "a") } _ => panic!("unable to unpack node"), } Ok(()) } pub fn generic_step_wild_2<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let rd = make_empty_doc(); let sd = make_doc(); match &sd { Item::Node(c) => { let l = c.descend_iter().last().unwrap(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let s = ContextBuilder::new() .context(vec![Item::Node(l)]) .result_document(rd) .build() .dispatch(&mut stctxt, &parse("ancestor::*", None)?)?; assert_eq!(s.len(), 3); } _ => panic!("unable to unpack node"), } Ok(()) } pub fn generic_generate_id<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = dispatch_rig("generate-id()", make_empty_doc, make_doc)?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_string().len() > 0 { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected non-empty string")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_xpath_context_item<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let rd = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let s = ContextBuilder::new() .context(vec![Item::Value(Rc::new(Value::from("foobar")))]) .result_document(rd) .build() .dispatch(&mut stctxt, &parse(".", None)?)?; assert_eq!(s.len(), 1); assert_eq!(s[0].to_string(), "foobar"); Ok(()) } pub fn generic_parens_singleton<N: Node, G, H>(make_empty_doc: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let rd = make_empty_doc(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let s = ContextBuilder::new() .context(vec![Item::Value(Rc::new(Value::from("foobar")))]) .result_document(rd) .build() .dispatch(&mut stctxt, &parse("(1)", None)?)?; assert_eq!(s.len(), 1); assert_eq!(s[0].to_int().unwrap(), 1); Ok(()) } pub fn generic_int<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result("1")?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_int().unwrap() == 1 { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected integer value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_decimal<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result("1.2")?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_double() == 1.2 { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected double value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_exponent<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result("1.2e2")?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_double() == 120.0 { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected double value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_string_apos<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result("'abc'")?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_string() == "abc" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected string value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_string_apos_esc<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result("'abc''def'")?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_string() == "abc'def" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected string value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_string_quot<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result(r#""abc""#)?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_string() == "abc" { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected string value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_string_quot_esc<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result(r#""abc""def""#)?; if result.len() == 1 { match &result[0] { Item::Value(v) => { if v.to_string() == r#"abc"def"# { Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected string value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_literal_sequence<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let result: Sequence<N> = no_src_no_result("1,'abc',2")?; if result.len() == 3 { match &result[0] { Item::Value(v) => { if v.to_int().unwrap() == 1 { assert_eq!(result[1].to_string(), "abc"); assert_eq!(result[2].to_int().unwrap(), 2); Ok(()) } else { Err(Error::new(ErrorKind::Unknown, "expected integer value")) } } _ => Err(Error::new(ErrorKind::Unknown, "not a value")), } } else { Err(Error::new( ErrorKind::Unknown, format!("got {} results, expected 1", result.len()), )) } } pub fn generic_literal_sequence_ws<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("1 , 'abc', 2")?; assert_eq!(s.len(), 3); assert_eq!(s[0].to_int().unwrap(), 1); assert_eq!(s[1].to_string(), "abc"); assert_eq!(s[2].to_int().unwrap(), 2); Ok(()) } pub fn generic_xpath_comment<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("1(::),(: a comment :)'abc', (: outer (: inner :) outer :) 2")?; assert_eq!(s.len(), 3); assert_eq!(s[0].to_int().unwrap(), 1); assert_eq!(s[1].to_string(), "abc"); assert_eq!(s[2].to_int().unwrap(), 2); Ok(()) } pub fn generic_kindtest_text_abbrev<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("text()")?; assert_eq!(s.len(), 0); Ok(()) } pub fn generic_kindtest_text_full<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("child::text()")?; assert_eq!(s.len(), 0); Ok(()) } pub fn generic_fncall_string<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("string(('a', 'b', 'c'))")?; assert_eq!(s.len(), 1); assert_eq!(s.to_string(), "abc"); Ok(()) } pub fn generic_fncall_current_1<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("current()")?; assert_eq!(s.len(), 0); assert_eq!(s.to_string(), ""); Ok(()) } pub fn generic_fncall_current_2<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = dispatch_rig("current()/child::a", make_empty_doc, make_doc)?; assert_eq!(s.len(), 1); Ok(()) } pub fn generic_fncall_current_3<N: Node, G, H>(make_empty_doc: G, make_doc: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let rd = make_empty_doc(); let sd = make_doc(); if let Item::Node(ref doc) = sd { let top = doc.child_iter().nth(0).unwrap(); let mut stctxt = StaticContextBuilder::new() .message(|_| Ok(())) .fetcher(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .parser(|_| Err(Error::new(ErrorKind::NotImplemented, "not implemented"))) .build(); let s = ContextBuilder::new() .result_document(rd) .context(vec![Item::Node(top)]) .previous_context(Some(sd)) .build() .dispatch(&mut stctxt, &parse("current()/child::a", None)?) .expect("evaluation failed"); assert_eq!(s.len(), 1) } else { panic!("not a node") } Ok(()) } pub fn generic_fncall_concat<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("concat('a', 'b', 'c')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_string(), "abc"); Ok(()) } pub fn generic_fncall_startswith_pos<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("starts-with('abc', 'a')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_bool(), true); Ok(()) } pub fn generic_fncall_startswith_neg<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("starts-with('abc', 'b')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_bool(), false); Ok(()) } pub fn generic_fncall_contains_pos<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("contains('abc', 'b')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_bool(), true); Ok(()) } pub fn generic_fncall_contains_neg<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("contains('abc', 'd')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_bool(), false); Ok(()) } pub fn generic_fncall_substring_2arg<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("substring('abcdefg', 4)")?; assert_eq!(s.len(), 1); assert_eq!(s.to_string(), "defg"); Ok(()) } pub fn generic_fncall_substring_3arg<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("substring('abcdefg', 4, 2)")?; assert_eq!(s.len(), 1); assert_eq!(s.to_string(), "de"); Ok(()) } pub fn generic_fncall_substringbefore_pos<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("substring-before('abc', 'b')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_string(), "a"); Ok(()) } pub fn generic_fncall_substringbefore_neg<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("substring-before('abc', 'd')")?; assert_eq!(s.to_string(), ""); Ok(()) } pub fn generic_fncall_substringafter_pos_1<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("substring-after('abc', 'b')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_string(), "c"); Ok(()) } pub fn generic_fncall_substringafter_pos_2<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("substring-after('abc', 'c')")?; assert_eq!(s.len(), 1); assert_eq!(s.to_string(), ""); Ok(()) } pub fn generic_fncall_substringafter_neg<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("substring-after('abc', 'd')")?; assert_eq!(s.to_string(), ""); Ok(()) } pub fn generic_fncall_normalizespace<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("normalize-space(' a b\nc ')")?; assert_eq!(s.to_string(), "a b c"); Ok(()) } pub fn generic_fncall_translate<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("translate('abcdeabcde', 'ade', 'XY')")?; assert_eq!(s.to_string(), "XbcYXbcY"); Ok(()) } pub fn generic_fncall_boolean_true<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("boolean('abcdeabcde')")?; assert_eq!(s.len(), 1); match &s[0] { Item::Value(v) => match **v { Value::Boolean(b) => assert_eq!(b, true), _ => panic!("not a singleton boolean true value"), }, _ => panic!("not a value"), } Ok(()) } pub fn generic_fncall_boolean_false<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("boolean('')")?; assert_eq!(s.len(), 1); match &s[0] { Item::Value(v) => match **v { Value::Boolean(b) => assert_eq!(b, false), _ => panic!("not a singleton boolean true value"), }, _ => panic!("not a value"), } Ok(()) } pub fn generic_fncall_not_true<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("not('')")?; assert_eq!(s.len(), 1); match &s[0] { Item::Value(v) => match **v { Value::Boolean(b) => assert_eq!(b, true), _ => panic!("not a singleton boolean true value"), }, _ => panic!("not a value"), } Ok(()) } pub fn generic_fncall_not_false<N: Node, G, H>(_: G, _: H) -> Result<(), Error> where G: Fn() -> N, H: Fn() -> Item<N>, { let s: Sequence<N> = no_src_no_result("not('abc')")?;
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/mod.rs
tests/conformance/mod.rs
use std::fs; use std::fs::File; use std::io::{Read, Seek, SeekFrom}; use xrust::{Error, ErrorKind}; //mod relaxng; mod xml; mod xml_id; use encoding_rs::UTF_16BE; use encoding_rs::UTF_16LE; use encoding_rs::UTF_8; use encoding_rs::WINDOWS_1252; use encoding_rs_io::DecodeReaderBytesBuilder; fn dtdfileresolve() -> fn(Option<String>, String) -> Result<String, Error> { move |locdir, uri| { let u = match locdir { None => uri, Some(ld) => ld + uri.as_str(), }; match fs::read_to_string(u) { Err(_) => Err(Error::new( ErrorKind::Unknown, "Unable to read external DTD".to_string(), )), Ok(s) => Ok(s), } } } fn non_utf8_file_reader(filedir: &str) -> String { /* xRust itself will most likely be UTF-8 only, but there are UTF-16 files in the conformance suite. I could change them, but best leave as-is in case we do try to support later. */ let mut file_in = File::open(filedir).unwrap(); let mut buffer = [0; 4]; // read exactly 4 bytes let _ = file_in.read_exact(&mut buffer); let _ = file_in.seek(SeekFrom::Start(0)); let enc = match buffer { //[0, 0, 254, 255] => {} //UCS-4, big-endian machine (1234 order) //[255, 254, 0, 0] => {} //UCS-4, little-endian machine (4321 order) //[0, 0, 255, 254] => {} //UCS-4, unusual octet order (2143) //[254, 255, 0, 0] => {} //UCS-4, unusual octet order (3412) [254, 255, _, _] => Some(UTF_16BE), //UTF-16, big-endian [255, 254, _, _] => Some(UTF_16LE), //UTF-16, little-endian [239, 187, 191, _] => Some(UTF_8), //UTF-8 [60, 63, 120, 109] => Some(WINDOWS_1252), //UTF-8 _ => Some(UTF_8), //Other }; let mut decoded_stream = DecodeReaderBytesBuilder::new().encoding(enc).build(file_in); let mut dest = String::new(); let _ = decoded_stream.read_to_string(&mut dest); dest }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/relaxng/mod.rs
tests/conformance/relaxng/mod.rs
mod jamesclark; use std::rc::Rc; use xrust::Node; use xrust::parser::xml; use xrust::trees::smite::{Node as SmiteNode}; use xrust::validators::relaxng::validate_relaxng; #[test] #[ignore] fn rngtestone(){ let s = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <element xmlns=\"http://relaxng.org/ns/structure/1.0\" name=\"foo\" ns=\"\"> <empty/> </element>"; let d = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <foo/> "; let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), d, None); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), s, None); let result = validate_relaxng(&doc, &sch); assert!(result.is_ok()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/relaxng/jamesclark.rs
tests/conformance/relaxng/jamesclark.rs
use std::fs; use std::rc::Rc; //use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::{Node as SmiteNode}; use xrust::validators::relaxng::validate_relaxng; #[test] #[ignore] fn relaxng_incorrect_001_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/001/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_002_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/002/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_003_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/003/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_004_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/004/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_005_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/005/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_006_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/006/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_007_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/007/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_008_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/008/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_009_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/009/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_010_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/010/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_011_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/011/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_012_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/012/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_013_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/013/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_014_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/014/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_015_1(){ /* Spec Sections: 3 Description: Various possible syntax errors. */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/015/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_016_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/016/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_017_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/017/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_018_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/018/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_019_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/019/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_020_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/020/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_021_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/021/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_022_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/022/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_023_1(){ /* Spec Sections: 3 Description: Tests for obsolete syntax */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/023/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_024_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/024/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_025_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/025/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_026_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/026/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_027_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/027/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_028_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/028/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_029_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/029/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_030_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/030/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_031_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/031/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_032_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/032/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_033_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/033/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_034_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/034/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_035_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/035/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_036_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/036/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_037_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/037/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_038_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/038/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_039_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/039/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_040_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/040/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_041_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/041/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_042_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/042/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_043_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/043/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_044_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/044/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_045_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/045/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_046_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/046/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_047_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/047/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_048_1(){ /* Spec Sections: 3 Description: Tests for missing attributes and child elements */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/048/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_valid_049_1(){ /* Spec Sections: 3 Description: Checking of ns attribute */ let docfile = fs::read_to_string("tests/conformance/relaxng/jamesclark/049/1.v.xml").unwrap(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/049/c.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_ok()); } #[test] #[ignore] fn relaxng_valid_050_1(){ /* Spec Sections: 3 Description: Checking of ns attribute Description: No checking of ns attribute is performed */ let docfile = fs::read_to_string("tests/conformance/relaxng/jamesclark/050/1.v.xml").unwrap(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/050/c.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_ok()); } #[test] #[ignore] fn relaxng_incorrect_053_1(){ /* Spec Sections: 3 Description: Checking of datatypeLibrary attribute Description: Value of datatypeLibrary attribute must conform to RFC 2396 */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/053/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_valid_054_1(){ /* Spec Sections: 3 Description: Checking of datatypeLibrary attribute Description: Value of datatypeLibrary attribute must conform to RFC 2396 */ let docfile = fs::read_to_string("tests/conformance/relaxng/jamesclark/054/1.v.xml").unwrap(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/054/c.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_ok()); } #[test] #[ignore] fn relaxng_valid_055_1(){ /* Spec Sections: 3 Description: Checking of datatypeLibrary attribute Description: Value of datatypeLibrary attribute must conform to RFC 2396 */ let docfile = fs::read_to_string("tests/conformance/relaxng/jamesclark/055/1.v.xml").unwrap(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/055/c.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_ok()); } #[test] #[ignore] fn relaxng_incorrect_056_1(){ /* Spec Sections: 3 Description: Checking of datatypeLibrary attribute Description: Value of datatypeLibrary attribute must conform to RFC 2396 */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/056/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_057_1(){ /* Spec Sections: 3 Description: Checking of datatypeLibrary attribute Description: Value of datatypeLibrary attribute must conform to RFC 2396 */ let docfile = "<doc/>".to_string(); let doc = Rc::new(SmiteNode::new()); let _ = xml::parse(doc.clone(), docfile.as_str(), None); let schemafile = fs::read_to_string("tests/conformance/relaxng/jamesclark/057/i.rng").unwrap(); let sch = Rc::new(SmiteNode::new()); let _ = xml::parse(sch.clone(), schemafile.as_str(), None); let result = validate_relaxng(&doc, &sch); assert!(result.is_err()); } #[test] #[ignore] fn relaxng_incorrect_058_1(){ /* Spec Sections: 3
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml_id/mod.rs
tests/conformance/xml_id/mod.rs
mod normwalsh;
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml_id/normwalsh.rs
tests/conformance/xml_id/normwalsh.rs
use std::fs; use xrust::item::{Node, NodeType}; use xrust::parser::xml; use xrust::trees::smite::RNode; /* https://www.w3.org/XML/2005/01/xml-id/ Test catalog submitted by Norm Walsh of Sun Microsystems */ #[test] fn normal_001() { /* Test ID:normal_001 Spec Sections:4 Description:Check ID normalization Expected:xml:id on para is an ID (te st) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/001_normalize.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let para = docchildren.next().unwrap(); assert_eq!( para.attribute_iter().next().unwrap().to_string(), "te st".to_string() ); } #[test] fn undecl_001() { /* Test ID:undecl_001 Spec Sections:4 Description:Check that xml:id does not have to be declared Expected:xml:id on para is an ID (test) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/002_undecl.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let para = docchildren.next().unwrap(); assert_eq!( para.attribute_iter().next().unwrap().to_string(), "test".to_string() ); } #[test] fn declar_001() { /* Test ID:declar_001 Spec Sections:4 Description:Check that xml:id can be declared correctly with a DTD Expected:xml:id on para is an ID (id) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/003_dtd.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let para = docchildren.next().unwrap(); assert_eq!( para.attribute_iter().next().unwrap().to_string(), "id".to_string() ); } #[test] fn declar_002() { /* Test ID:declar_002 Spec Sections:4 Description:Check that xml:id can be declared correctly with a schema Expected:xml:id on para is an ID (id) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/004_schema.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let para = docchildren.next().unwrap(); assert_eq!( para.attribute_iter().next().unwrap().to_string(), "id".to_string() ); } #[test] fn baddcl_001() { /* Test ID:baddcl_001 Spec Sections:4 Description:Check that an incorrect DTD declaration is caught Expected:Must generate invalid declared type error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/005_errdtdbad.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn dupdup_001() { /* Test ID:dupdup_001 Spec Sections:4 Description:Test to see if duplicate IDs are detected. Expected:Should generate duplicate ID error; may report both elements. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/005_errdup.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn baddcl_002() { /* Test ID:baddcl_002 Spec Sections:4 Description:Check that an incorrect schema declaration is caught Expected:Must generate invalid declared type error; proper evaluation requires a schema-aware processor. */ /* We need to support XSD to properly test this */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/006_errschemabad.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn dupdup_002() { /* Test ID:dupdup_002 Spec Sections:4 Description:Test to see if duplicate IDs are detected. Expected:Should generate duplicate ID error; may report both elements. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/007_errdup.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn okchar_001() { /* Test ID:okchar_001 Spec Sections:4 Description:Check that an XML 1.0 document accepts 1.0 IDs Expected:xml:id on p is an ID (anid) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/008_ok10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let para = docchildren.next().unwrap(); assert_eq!( para.attribute_iter().next().unwrap().to_string(), "anid".to_string() ); } #[test] fn okchar_002() { /* Test ID:okchar_002 Spec Sections:4 Description:Check that an XML 1.1 document accepts 1.1 IDs Expected:xml:id on p is an ID (id&#11264;ok) Note: Will fail if an XML 1.0 processor is used. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/009_ok11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let para = docchildren.next().unwrap(); assert_eq!( para.attribute_iter().next().unwrap().to_string(), "idⰀok".to_string() ); } #[test] fn xref_001() { /* Test ID:xref___001 Spec Sections:4 Description:Check that IDREFs work Expected:id on para is an ID (id1) xml:id on para is an ID (id2) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/010_okxref.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn normal_002() { /* Test ID:normal_002 Spec Sections:4 Description:Check that an ID is normalized Expected:xml:id on p is an ID (anid) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/011_oknormalize.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let p = docchildren.next().unwrap(); assert_eq!( p.attribute_iter().next().unwrap().to_string(), "anid".to_string() ); } #[test] #[ignore] fn normal_003() { /* Test ID:normal_003 Spec Sections:4 Description:Check that an ID is normalized Expected:xml:id on para is an ID (&#x0D; p2) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml_id/normwalsh/012_value.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.clone().unwrap().first_child().unwrap(); let mut docchildren = doc .child_iter() .filter(|n| n.node_type() == NodeType::Element); let p = docchildren.next().unwrap(); assert_eq!( p.attribute_iter().next().unwrap().to_string(), "anid".to_string() ); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/ibm_invalid.rs
tests/conformance/xml/ibm_invalid.rs
/* IBM test cases */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] #[ignore] fn ibminvalid_p28ibm28i01xml() { /* Test ID:ibm-invalid-P28-ibm28i01.xml Test URI:invalid/P28/ibm28i01.xml Spec Sections:2.8 Description:The test violates VC:Root Element Type in P28. The Name in the document type declaration does not match the element type of the root element. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P28/ibm28i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p32ibm32i01xml() { /* Test ID:ibm-invalid-P32-ibm32i01.xml Test URI:invalid/P32/ibm32i01.xml Spec Sections:2.9 Description:This test violates VC: Standalone Document Declaration in P32. The standalone document declaration has the value yes, BUT there is an external markup declaration of attributes with default values, and the associated element appears in the document with specified values for those attributes. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P32/ibm32i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p32ibm32i03xml() { /* Test ID:ibm-invalid-P32-ibm32i03.xml Test URI:invalid/P32/ibm32i03.xml Spec Sections:2.9 Description:This test violates VC: Standalone Document Declaration in P32. The standalone document declaration has the value yes, BUT there is an external markup declaration of attributes with values that will change if normalized. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P32/ibm32i03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p32ibm32i04xml() { /* Test ID:ibm-invalid-P32-ibm32i04.xml Test URI:invalid/P32/ibm32i04.xml Spec Sections:2.9 Description:This test violates VC: Standalone Document Declaration in P32. The standalone document declaration has the value yes, BUT there is an external markup declaration of element with element content, and white space occurs directly within the mixed content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P32/ibm32i04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p39ibm39i01xml() { /* Test ID:ibm-invalid-P39-ibm39i01.xml Test URI:invalid/P39/ibm39i01.xml Spec Sections:3 Description:This test violates VC: Element Valid in P39. Element a is declared empty in DTD, but has content in the document. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P39/ibm39i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p39ibm39i02xml() { /* Test ID:ibm-invalid-P39-ibm39i02.xml Test URI:invalid/P39/ibm39i02.xml Spec Sections:3 Description:This test violates VC: Element Valid in P39. root is declared only having element children in DTD, but have text content in the document. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P39/ibm39i02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p39ibm39i03xml() { /* Test ID:ibm-invalid-P39-ibm39i03.xml Test URI:invalid/P39/ibm39i03.xml Spec Sections:3 Description:This test violates VC: Element Valid in P39. Illegal elements are inserted in b's content of Mixed type. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P39/ibm39i03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p39ibm39i04xml() { /* Test ID:ibm-invalid-P39-ibm39i04.xml Test URI:invalid/P39/ibm39i04.xml Spec Sections:3 Description:This test violates VC: Element Valid in P39. Element c has undeclared element as its content of ANY type */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P39/ibm39i04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p41ibm41i01xml() { /* Test ID:ibm-invalid-P41-ibm41i01.xml Test URI:invalid/P41/ibm41i01.xml Spec Sections:3.1 Description:This test violates VC: Attribute Value Type in P41. attr1 for Element b is not declared. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P41/ibm41i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p41ibm41i02xml() { /* Test ID:ibm-invalid-P41-ibm41i02.xml Test URI:invalid/P41/ibm41i02.xml Spec Sections:3.1 Description:This test violates VC: Attribute Value Type in P41. attr3 for Element b is given a value that does not match the declaration in the DTD. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P41/ibm41i02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p45ibm45i01xml() { /* Test ID:ibm-invalid-P45-ibm45i01.xml Test URI:invalid/P45/ibm45i01.xml Spec Sections:3.2 Description:This test violates VC: Unique Element Type Declaration. Element not_unique has been declared 3 time in the DTD. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P45/ibm45i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p49ibm49i01xml() { /* Test ID:ibm-invalid-P49-ibm49i01.xml Test URI:invalid/P49/ibm49i01.xml Spec Sections:3.2.1 Description:Violates VC:Proper Group/PE Nesting in P49. Open and close parenthesis for a choice content model are in different PE replace Texts. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P49/ibm49i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p50ibm50i01xml() { /* Test ID:ibm-invalid-P50-ibm50i01.xml Test URI:invalid/P50/ibm50i01.xml Spec Sections:3.2.1 Description:Violates VC:Proper Group/PE Nesting in P50. Open and close parenthesis for a seq content model are in different PE replace Texts. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P50/ibm50i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p51ibm51i01xml() { /* Test ID:ibm-invalid-P51-ibm51i01.xml Test URI:invalid/P51/ibm51i01.xml Spec Sections:3.2.2 Description:Violates VC:Proper Group/PE Nesting in P51. Open and close parenthesis for a Mixed content model are in different PE replace Texts. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P51/ibm51i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p51ibm51i03xml() { /* Test ID:ibm-invalid-P51-ibm51i03.xml Test URI:invalid/P51/ibm51i03.xml Spec Sections:3.2.2 Description:Violates VC:No Duplicate Types in P51. Element a appears twice in the Mixed content model of Element e. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P51/ibm51i03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p56ibm56i01xml() { /* Test ID:ibm-invalid-P56-ibm56i01.xml Test URI:invalid/P56/ibm56i01.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: ID. The value of the ID attribute "UniqueName" is "@999" which does not meet the Name production. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p56ibm56i02xml() { /* Test ID:ibm-invalid-P56-ibm56i02.xml Test URI:invalid/P56/ibm56i02.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: ID. The two ID attributes "attr" and "UniqueName" have the same value "Ac999" for the element "b" and the element "tokenizer". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p56ibm56i03xml() { /* Test ID:ibm-invalid-P56-ibm56i03.xml Test URI:invalid/P56/ibm56i03.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: ID Attribute Default. The "#FIXED" occurs in the DefaultDecl for the ID attribute "UniqueName". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p56ibm56i05xml() { /* Test ID:ibm-invalid-P56-ibm56i05.xml Test URI:invalid/P56/ibm56i05.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: ID Attribute Default. The constant string "BOGUS" occurs in the DefaultDecl for the ID attribute "UniqueName". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p56ibm56i06xml() { /* Test ID:ibm-invalid-P56-ibm56i06.xml Test URI:invalid/P56/ibm56i06.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: One ID per Element Type. The element "a" has two ID attributes "first" and "second". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i07xml() { /* Test ID:ibm-invalid-P56-ibm56i07.xml Test URI:invalid/P56/ibm56i07.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: IDREF. The value of the IDREF attribute "reference" is "@456" which does not meet the Name production. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i08xml() { /* Test ID:ibm-invalid-P56-ibm56i08.xml Test URI:invalid/P56/ibm56i08.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: IDREF. The value of the IDREF attribute "reference" is "BC456" which does not match the value assigned to any ID attributes. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i09xml() { /* Test ID:ibm-invalid-P56-ibm56i09.xml Test URI:invalid/P56/ibm56i09.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: IDREFS. The value of the IDREFS attribute "reference" is "AC456 #567" which does not meet the Names production. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i10xml() { /* Test ID:ibm-invalid-P56-ibm56i10.xml Test URI:invalid/P56/ibm56i10.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: IDREFS. The value of the IDREFS attribute "reference" is "EF456 DE355" which does not match the values assigned to two ID attributes. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i11xml() { /* Test ID:ibm-invalid-P56-ibm56i11.xml Test URI:invalid/P56/ibm56i11.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: Entity Name. The value of the ENTITY attribute "sun" is "ima ge" which does not meet the Name production. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i12xml() { /* Test ID:ibm-invalid-P56-ibm56i12.xml Test URI:invalid/P56/ibm56i12.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: Entity Name. The value of the ENTITY attribute "sun" is "notimage" which does not match the name of any unparsed entity declared. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i13xml() { /* Test ID:ibm-invalid-P56-ibm56i13.xml Test URI:invalid/P56/ibm56i13.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: Entity Name. The value of the ENTITY attribute "sun" is "parsedentity" which matches the name of a parsed entity instead of an unparsed entity declared. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i13.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i14xml() { /* Test ID:ibm-invalid-P56-ibm56i14.xml Test URI:invalid/P56/ibm56i14.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: Entity Name. The value of the ENTITIES attribute "sun" is "#image1 @image" which does not meet the Names production. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i14.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i15xml() { /* Test ID:ibm-invalid-P56-ibm56i15.xml Test URI:invalid/P56/ibm56i15.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: ENTITIES. The value of the ENTITIES attribute "sun" is "image3 image4" which does not match the names of two unparsed entities declared. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i15.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p56ibm56i16xml() { /* Test ID:ibm-invalid-P56-ibm56i16.xml Test URI:invalid/P56/ibm56i16.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: ENTITIES. The value of the ENTITIES attribute "sun" is "parsedentity1 parsedentity2" which matches the names of two parsed entities instead of two unparsed entities declared. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i16.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p56ibm56i17xml() { /* Test ID:ibm-invalid-P56-ibm56i17.xml Test URI:invalid/P56/ibm56i17.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: Name Token. The value of the NMTOKEN attribute "thistoken" is "x : image" which does not meet the Nmtoken production. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i17.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p56ibm56i18xml() { /* Test ID:ibm-invalid-P56-ibm56i18.xml Test URI:invalid/P56/ibm56i18.xml Spec Sections:3.3.1 Description:Tests invalid TokenizedType which is against P56 VC: Name Token. The value of the NMTOKENS attribute "thistoken" is "@lang y: #country" which does not meet the Nmtokens production. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P56/ibm56i18.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p58ibm58i01xml() { /* Test ID:ibm-invalid-P58-ibm58i01.xml Test URI:invalid/P58/ibm58i01.xml Spec Sections:3.3.1 Description:Tests invalid NotationType which is against P58 VC: Notation Attributes. The attribute "content-encoding" with value "raw" is not a value from the list "(base64|uuencode)". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P58/ibm58i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p58ibm58i02xml() { /* Test ID:ibm-invalid-P58-ibm58i02.xml Test URI:invalid/P58/ibm58i02.xml Spec Sections:3.3.1 Description:Tests invalid NotationType which is against P58 VC: Notation Attributes. The attribute "content-encoding" with value "raw" is a value from the list "(base64|uuencode|raw|ascii)", but "raw" is not a declared notation. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P58/ibm58i02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p59ibm59i01xml() { /* Test ID:ibm-invalid-P59-ibm59i01.xml Test URI:invalid/P59/ibm59i01.xml Spec Sections:3.3.1 Description:Tests invalid Enumeration which is against P59 VC: Enumeration. The value of the attribute is "ONE" which matches neither "one" nor "two" as declared in the Enumeration in the AttDef in the AttlistDecl. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P59/ibm59i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p60ibm60i01xml() { /* Test ID:ibm-invalid-P60-ibm60i01.xml Test URI:invalid/P60/ibm60i01.xml Spec Sections:3.3.2 Description:Tests invalid DefaultDecl which is against P60 VC: Required Attribute. The attribute "chapter" for the element "two" is declared as #REQUIRED in the DefaultDecl in the AttlistDecl, but the value of this attribute is not given. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P60/ibm60i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p60ibm60i02xml() { /* Test ID:ibm-invalid-P60-ibm60i02.xml Test URI:invalid/P60/ibm60i02.xml Spec Sections:3.3.2 Description:Tests invalid DefaultDecl which is against P60 VC: Fixed Attribute Default.. The attribute "chapter" for the element "one" is declared as #FIXED with the given value "Introduction" in the DefaultDecl in the AttlistDecl, but the value of a instance of this attribute is assigned to "JavaBeans". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P60/ibm60i02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p60ibm60i03xml() { /* Test ID:ibm-invalid-P60-ibm60i03.xml Test URI:invalid/P60/ibm60i03.xml Spec Sections:3.3.2 Description:Tests invalid DefaultDecl which is against P60 VC: Attribute Default Legal. The declared default value "c" is not legal for the type (a|b) in the AttDef in the AttlistDecl. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P60/ibm60i03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibminvalid_p60ibm60i04xml() { /* Test ID:ibm-invalid-P60-ibm60i04.xml Test URI:invalid/P60/ibm60i04.xml Spec Sections:3.3.2 Description:Tests invalid DefaultDecl which is against P60 VC: Attribute Default Legal. The declared default value "@#$" is not legal for the type NMTOKEN the AttDef in the AttlistDecl. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P60/ibm60i04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p76ibm76i01xml() { /* Test ID:ibm-invalid-P76-ibm76i01.xml Test URI:invalid/P76/ibm76i01.xml Spec Sections:4.2.2 Description:Tests invalid NDataDecl which is against P76 VC: Notation declared. The Name "JPGformat" in the NDataDecl in the EntityDecl for "ge2" does not match the Name of any declared notation. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P76/ibm76i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_misc_notwf.rs
tests/conformance/xml/eduni_misc_notwf.rs
/* Bjoern Hoehrmann via HST 2013-09-18 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn hstbh001() { /* Test ID:hst-bh-001 Test URI:001.xml Spec Sections:2.2 [2], 4.1 [66] Description:decimal charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/misc/001.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn hstbh002() { /* Test ID:hst-bh-002 Test URI:002.xml Spec Sections:2.2 [2], 4.1 [66] Description:hex charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/misc/002.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn hstbh003() { /* Test ID:hst-bh-003 Test URI:003.xml Spec Sections:2.2 [2], 4.1 [66] Description:decimal charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/misc/003.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn hstbh004() { /* Test ID:hst-bh-004 Test URI:004.xml Spec Sections:2.2 [2], 4.1 [66] Description:hex charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/misc/004.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn hstlhs007() { /* Test ID:hst-lhs-007 Test URI:007.xml Spec Sections:4.3.3 Description:UTF-8 BOM plus xml decl of iso-8859-1 incompatible */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/misc/007.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn hstlhs008() { /* Test ID:hst-lhs-008 Test URI:008.xml Spec Sections:4.3.3 Description:UTF-16 BOM plus xml decl of utf-8 (using UTF-16 coding) incompatible */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/misc/008.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn hstlhs009() { /* Test ID:hst-lhs-009 Test URI:009.xml Spec Sections:4.3.3 Description:UTF-16 BOM plus xml decl of utf-8 (using UTF-8 coding) incompatible */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/misc/009.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata2e_error.rs
tests/conformance/xml/eduni_errata2e_error.rs
/* Richard Tobin's XML 1.0 2nd edition errata test suite. */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] #[ignore] fn rmte2e34() { /* Test ID:rmt-e2e-34 Test URI:E34.xml Spec Sections:E34 Description:A non-deterministic content model is an error even if the element type is not used. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E34.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmte2e55() { /* Test ID:rmt-e2e-55 Test URI:E55.xml Spec Sections:E55 Description:A reference to an unparsed entity in an entity value is an error rather than forbidden (unless the entity is referenced, of course) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E55.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmte2e57() { /* Test ID:rmt-e2e-57 Test URI:E57.xml Spec Sections:E57 Description:A value other than preserve or default for xml:space is an error */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E57.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata3e_notwf.rs
tests/conformance/xml/eduni_errata3e_notwf.rs
/* Richard Tobin's XML 1.0 3rd edition errata test suite 1 June 2006 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn rmte3e12() { /* Test ID:rmt-e3e-12 Test URI:E12.xml Spec Sections:E12 Description:Default values for attributes may not contain references to external entities. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_xml11_invalid.rs
tests/conformance/xml/eduni_xml11_invalid.rs
/* Richard Tobin's XML 1.1 test suite 13 Feb 2003 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; use xrust::validators::Schema; /* #[test] fn rmt015() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:rmt-015 Test URI:015.xml Spec Sections:2.3 Description:Has a "long s" in a name, legal in XML 1.1, illegal in XML 1.0 thru 4th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/015.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn rmt017() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:rmt-017 Test URI:017.xml Spec Sections:2.3 Description:Has a Byzantine Musical Symbol Kratimata in a name, legal in XML 1.1, illegal in XML 1.0 thru 4th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/017.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn rmt018() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:rmt-018 Test URI:018.xml Spec Sections:2.3 Description:Has the last legal namechar in XML 1.1, illegal in XML 1.0 thru 4th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/018.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ #[test] #[ignore] fn rmt030() { /* Test ID:rmt-030 Test URI:030.xml Spec Sections:2.11 Description:Has a NEL character in an NMTOKENS attribute; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/030.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmt032() { /* Test ID:rmt-032 Test URI:032.xml Spec Sections:2.11 Description:Has an LSEP character in an NMTOKENS attribute; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/032.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmt036() { /* Test ID:rmt-036 Test URI:036.xml Spec Sections:2.3 Description:Has an NMTOKENS attribute containing a NEL character that comes from a character reference in an internal entity. Because NEL is not in the S production (even though real NELs are converted to LF on input), this is invalid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/036.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmt037() { /* Test ID:rmt-037 Test URI:037.xml Spec Sections:2.3 Description:Has an NMTOKENS attribute containing a NEL character that comes from a character reference in an internal entity. Because NEL is not in the S production (even though real NELs are converted to LF on input), this is invalid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/037.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmt046() { /* Test ID:rmt-046 Test URI:046.xml Spec Sections:2.11 Description:Has a NEL character in element content whitespace; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/046.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmt048() { /* Test ID:rmt-048 Test URI:048.xml Spec Sections:2.11 Description:Has an LSEP character in element content whitespace; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/048.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmt052() { /* Test ID:rmt-052 Test URI:052.xml Spec Sections:2.3 Description:Has element content whitespace containing a NEL character that comes from a character reference in an internal entity. Because NEL is not in the S production (even though real NELs are converted to LF on input), this is invalid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/052.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmt053() { /* Test ID:rmt-053 Test URI:053.xml Spec Sections:2.3 Description:Has element content whitespace containing a NEL character that comes from a character reference in an internal entity. Because NEL is not in the S production (even though real NELs are converted to LF on input), this is invalid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/053.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/ibm_notwf.rs
tests/conformance/xml/ibm_notwf.rs
/* IBM test cases */ use crate::conformance::{dtdfileresolve, non_utf8_file_reader}; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; #[test] fn ibmnotwf_p01ibm01n01xml() { /* Test ID:ibm-not-wf-P01-ibm01n01.xml Test URI:not-wf/P01/ibm01n01.xml Spec Sections:2.1 Description:Tests a document with no element. A well-formed document should have at lease one elements. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P01/ibm01n01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p01ibm01n02xml() { /* Test ID:ibm-not-wf-P01-ibm01n02.xml Test URI:not-wf/P01/ibm01n02.xml Spec Sections:2.1 Description:Tests a document with wrong ordering of its prolog and element. The element occurs before the xml declaration and the DTD. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P01/ibm01n02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p01ibm01n03xml() { /* Test ID:ibm-not-wf-P01-ibm01n03.xml Test URI:not-wf/P01/ibm01n03.xml Spec Sections:2.1 Description:Tests a document with wrong combination of misc and element. One PI occurs between two elements. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P01/ibm01n03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n01xml() { /* Test ID:ibm-not-wf-P02-ibm02n01.xml Test URI:not-wf/P02/ibm02n01.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x00 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n02xml() { /* Test ID:ibm-not-wf-P02-ibm02n02.xml Test URI:not-wf/P02/ibm02n02.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x01 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n03xml() { /* Test ID:ibm-not-wf-P02-ibm02n03.xml Test URI:not-wf/P02/ibm02n03.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x02 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n04xml() { /* Test ID:ibm-not-wf-P02-ibm02n04.xml Test URI:not-wf/P02/ibm02n04.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x03 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n05xml() { /* Test ID:ibm-not-wf-P02-ibm02n05.xml Test URI:not-wf/P02/ibm02n05.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x04 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n06xml() { /* Test ID:ibm-not-wf-P02-ibm02n06.xml Test URI:not-wf/P02/ibm02n06.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x05 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n07xml() { /* Test ID:ibm-not-wf-P02-ibm02n07.xml Test URI:not-wf/P02/ibm02n07.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x06 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n08xml() { /* Test ID:ibm-not-wf-P02-ibm02n08.xml Test URI:not-wf/P02/ibm02n08.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x07 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n09xml() { /* Test ID:ibm-not-wf-P02-ibm02n09.xml Test URI:not-wf/P02/ibm02n09.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x08 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n10xml() { /* Test ID:ibm-not-wf-P02-ibm02n10.xml Test URI:not-wf/P02/ibm02n10.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x0B */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n11xml() { /* Test ID:ibm-not-wf-P02-ibm02n11.xml Test URI:not-wf/P02/ibm02n11.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x0C */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n12xml() { /* Test ID:ibm-not-wf-P02-ibm02n12.xml Test URI:not-wf/P02/ibm02n12.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x0E */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n13xml() { /* Test ID:ibm-not-wf-P02-ibm02n13.xml Test URI:not-wf/P02/ibm02n13.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x0F */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n13.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n14xml() { /* Test ID:ibm-not-wf-P02-ibm02n14.xml Test URI:not-wf/P02/ibm02n14.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x10 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n14.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n15xml() { /* Test ID:ibm-not-wf-P02-ibm02n15.xml Test URI:not-wf/P02/ibm02n15.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x11 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n15.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n16xml() { /* Test ID:ibm-not-wf-P02-ibm02n16.xml Test URI:not-wf/P02/ibm02n16.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x12 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n16.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n17xml() { /* Test ID:ibm-not-wf-P02-ibm02n17.xml Test URI:not-wf/P02/ibm02n17.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x13 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n17.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n18xml() { /* Test ID:ibm-not-wf-P02-ibm02n18.xml Test URI:not-wf/P02/ibm02n18.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x14 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n18.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n19xml() { /* Test ID:ibm-not-wf-P02-ibm02n19.xml Test URI:not-wf/P02/ibm02n19.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x15 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n19.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n20xml() { /* Test ID:ibm-not-wf-P02-ibm02n20.xml Test URI:not-wf/P02/ibm02n20.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x16 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n20.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n21xml() { /* Test ID:ibm-not-wf-P02-ibm02n21.xml Test URI:not-wf/P02/ibm02n21.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x17 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n21.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n22xml() { /* Test ID:ibm-not-wf-P02-ibm02n22.xml Test URI:not-wf/P02/ibm02n22.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x18 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n22.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n23xml() { /* Test ID:ibm-not-wf-P02-ibm02n23.xml Test URI:not-wf/P02/ibm02n23.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x19 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n23.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n24xml() { /* Test ID:ibm-not-wf-P02-ibm02n24.xml Test URI:not-wf/P02/ibm02n24.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x1A */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n24.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n25xml() { /* Test ID:ibm-not-wf-P02-ibm02n25.xml Test URI:not-wf/P02/ibm02n25.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x1B */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n25.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n26xml() { /* Test ID:ibm-not-wf-P02-ibm02n26.xml Test URI:not-wf/P02/ibm02n26.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x1C */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n26.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n27xml() { /* Test ID:ibm-not-wf-P02-ibm02n27.xml Test URI:not-wf/P02/ibm02n27.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x1D */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n27.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n28xml() { /* Test ID:ibm-not-wf-P02-ibm02n28.xml Test URI:not-wf/P02/ibm02n28.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x1E */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n28.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n29xml() { /* Test ID:ibm-not-wf-P02-ibm02n29.xml Test URI:not-wf/P02/ibm02n29.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #x1F */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n29.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibmnotwf_p02ibm02n30xml() { /* Test ID:ibm-not-wf-P02-ibm02n30.xml Test URI:not-wf/P02/ibm02n30.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #xD800 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n30.xml").as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibmnotwf_p02ibm02n31xml() { /* Test ID:ibm-not-wf-P02-ibm02n31.xml Test URI:not-wf/P02/ibm02n31.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #xDFFF */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n31.xml").as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n32xml() { /* Test ID:ibm-not-wf-P02-ibm02n32.xml Test URI:not-wf/P02/ibm02n32.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #xFFFE */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n32.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p02ibm02n33xml() { /* Test ID:ibm-not-wf-P02-ibm02n33.xml Test URI:not-wf/P02/ibm02n33.xml Spec Sections:2.2 Description:Tests a comment which contains an illegal Char: #xFFFF */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P02/ibm02n33.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p03ibm03n01xml() { /* Test ID:ibm-not-wf-P03-ibm03n01.xml Test URI:not-wf/P03/ibm03n01.xml Spec Sections:2.3 Description:Tests an end tag which contains an illegal space character #x3000 which follows the element name "book". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P03/ibm03n01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n01xml() { /* Test ID:ibm-not-wf-P04-ibm04n01.xml Test URI:not-wf/P04/ibm04n01.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x21 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n02xml() { /* Test ID:ibm-not-wf-P04-ibm04n02.xml Test URI:not-wf/P04/ibm04n02.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x28 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n03xml() { /* Test ID:ibm-not-wf-P04-ibm04n03.xml Test URI:not-wf/P04/ibm04n03.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x29 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n04xml() { /* Test ID:ibm-not-wf-P04-ibm04n04.xml Test URI:not-wf/P04/ibm04n04.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x2B */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n05xml() { /* Test ID:ibm-not-wf-P04-ibm04n05.xml Test URI:not-wf/P04/ibm04n05.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x2C */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n06xml() { /* Test ID:ibm-not-wf-P04-ibm04n06.xml Test URI:not-wf/P04/ibm04n06.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x2F */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n07xml() { /* Test ID:ibm-not-wf-P04-ibm04n07.xml Test URI:not-wf/P04/ibm04n07.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x3B */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n08xml() { /* Test ID:ibm-not-wf-P04-ibm04n08.xml Test URI:not-wf/P04/ibm04n08.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x3C */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n09xml() { /* Test ID:ibm-not-wf-P04-ibm04n09.xml Test URI:not-wf/P04/ibm04n09.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x3D */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n10xml() { /* Test ID:ibm-not-wf-P04-ibm04n10.xml Test URI:not-wf/P04/ibm04n10.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x3F */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n11xml() { /* Test ID:ibm-not-wf-P04-ibm04n11.xml Test URI:not-wf/P04/ibm04n11.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x5B */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n12xml() { /* Test ID:ibm-not-wf-P04-ibm04n12.xml Test URI:not-wf/P04/ibm04n12.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x5C */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n13xml() { /* Test ID:ibm-not-wf-P04-ibm04n13.xml Test URI:not-wf/P04/ibm04n13.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x5D */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n13.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n14xml() { /* Test ID:ibm-not-wf-P04-ibm04n14.xml Test URI:not-wf/P04/ibm04n14.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x5E */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n14.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n15xml() { /* Test ID:ibm-not-wf-P04-ibm04n15.xml Test URI:not-wf/P04/ibm04n15.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x60 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n15.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n16xml() { /* Test ID:ibm-not-wf-P04-ibm04n16.xml Test URI:not-wf/P04/ibm04n16.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x7B */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n16.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n17xml() { /* Test ID:ibm-not-wf-P04-ibm04n17.xml Test URI:not-wf/P04/ibm04n17.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x7C */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n17.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p04ibm04n18xml() { /* Test ID:ibm-not-wf-P04-ibm04n18.xml Test URI:not-wf/P04/ibm04n18.xml Spec Sections:2.3 Description:Tests an element name which contains an illegal ASCII NameChar. "IllegalNameChar" is followed by #x7D */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P04/ibm04n18.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p05ibm05n01xml() { /* Test ID:ibm-not-wf-P05-ibm05n01.xml Test URI:not-wf/P05/ibm05n01.xml Spec Sections:2.3 Description:Tests an element name which has an illegal first character. An illegal first character "." is followed by "A_name-starts_with.". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P05/ibm05n01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p05ibm05n02xml() { /* Test ID:ibm-not-wf-P05-ibm05n02.xml Test URI:not-wf/P05/ibm05n02.xml Spec Sections:2.3 Description:Tests an element name which has an illegal first character. An illegal first character "-" is followed by "A_name-starts_with-". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P05/ibm05n02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p05ibm05n03xml() { /* Test ID:ibm-not-wf-P05-ibm05n03.xml Test URI:not-wf/P05/ibm05n03.xml Spec Sections:2.3 Description:Tests an element name which has an illegal first character. An illegal first character "5" is followed by "A_name-starts_with_digit". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P05/ibm05n03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p09ibm09n01xml() { /* Test ID:ibm-not-wf-P09-ibm09n01.xml Test URI:not-wf/P09/ibm09n01.xml Spec Sections:2.3 Description:Tests an internal general entity with an invalid value. The entity "Fullname" contains "%". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P09/ibm09n01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibmnotwf_p09ibm09n02xml() { /* Test ID:ibm-not-wf-P09-ibm09n02.xml Test URI:not-wf/P09/ibm09n02.xml Spec Sections:2.3 Description:Tests an internal general entity with an invalid value. The entity "Fullname" contains the ampersand character. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml,
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/ibm_valid.rs
tests/conformance/xml/ibm_valid.rs
/* IBM test cases */ use crate::conformance::dtdfileresolve; use std::fs; //use hexdump::hexdump; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] fn ibmvalid_p01ibm01v01xml() { /* Test ID:ibm-valid-P01-ibm01v01.xml Test URI:valid/P01/ibm01v01.xml Spec Sections:2.1 Description:Tests with a xml document consisting of prolog followed by element then Misc */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P01/ibm01v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P01/out/ibm01v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p02ibm02v01xml() { /* Test ID:ibm-valid-P02-ibm02v01.xml Test URI:valid/P02/ibm02v01.xml Spec Sections:2.2 Description:This test case covers legal character ranges plus discrete legal characters for production 02. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P02/ibm02v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P02/out/ibm02v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p03ibm03v01xml() { /* Test ID:ibm-valid-P03-ibm03v01.xml Test URI:valid/P03/ibm03v01.xml Spec Sections:2.3 Description:Tests all 4 legal white space characters - #x20 #x9 #xD #xA */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P03/ibm03v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P03/out/ibm03v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p09ibm09v01xml() { /* Test ID:ibm-valid-P09-ibm09v01.xml Test URI:valid/P09/ibm09v01.xml Spec Sections:2.3 Description:Empty EntityValue is legal */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/ibm09v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/out/ibm09v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p09ibm09v02xml() { /* Test ID:ibm-valid-P09-ibm09v02.xml Test URI:valid/P09/ibm09v02.xml Spec Sections:2.3 Description:Tests a normal EnitityValue */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/ibm09v02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/out/ibm09v02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p09ibm09v03xml() { /* Test ID:ibm-valid-P09-ibm09v03.xml Test URI:valid/P09/ibm09v03.xml Spec Sections:2.3 Description:Tests EnitityValue referencing a Parameter Entity */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/ibm09v03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/out/ibm09v03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p09ibm09v04xml() { /* Test ID:ibm-valid-P09-ibm09v04.xml Test URI:valid/P09/ibm09v04.xml Spec Sections:2.3 Description:Tests EnitityValue referencing a General Entity */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/ibm09v04.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/out/ibm09v04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p09ibm09v05xml() { /* Test ID:ibm-valid-P09-ibm09v05.xml Test URI:valid/P09/ibm09v05.xml Spec Sections:2.3 Description:Tests EnitityValue with combination of GE, PE and text, the GE used is declared in the student.dtd */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/ibm09v05.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P09/out/ibm09v05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v01xml() { /* Test ID:ibm-valid-P10-ibm10v01.xml Test URI:valid/P10/ibm10v01.xml Spec Sections:2.3 Description:Tests empty AttValue with double quotes as the delimiters */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v02xml() { /* Test ID:ibm-valid-P10-ibm10v02.xml Test URI:valid/P10/ibm10v02.xml Spec Sections:2.3 Description:Tests empty AttValue with single quotes as the delimiters */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v03xml() { /* Test ID:ibm-valid-P10-ibm10v03.xml Test URI:valid/P10/ibm10v03.xml Spec Sections:2.3 Description:Test AttValue with double quotes as the delimiters and single quote inside */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v04xml() { /* Test ID:ibm-valid-P10-ibm10v04.xml Test URI:valid/P10/ibm10v04.xml Spec Sections:2.3 Description:Test AttValue with single quotes as the delimiters and double quote inside */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v04.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v05xml() { /* Test ID:ibm-valid-P10-ibm10v05.xml Test URI:valid/P10/ibm10v05.xml Spec Sections:2.3 Description:Test AttValue with a GE reference and double quotes as the delimiters */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v05.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v06xml() { /* Test ID:ibm-valid-P10-ibm10v06.xml Test URI:valid/P10/ibm10v06.xml Spec Sections:2.3 Description:Test AttValue with a GE reference and single quotes as the delimiters */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v06.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v07xml() { /* Test ID:ibm-valid-P10-ibm10v07.xml Test URI:valid/P10/ibm10v07.xml Spec Sections:2.3 Description:testing AttValue with mixed references and text content in double quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v07.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p10ibm10v08xml() { /* Test ID:ibm-valid-P10-ibm10v08.xml Test URI:valid/P10/ibm10v08.xml Spec Sections:2.3 Description:testing AttValue with mixed references and text content in single quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/ibm10v08.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P10/out/ibm10v08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p11ibm11v01xml() { /* Test ID:ibm-valid-P11-ibm11v01.xml Test URI:valid/P11/ibm11v01.xml Spec Sections:2.3 Description:Tests empty systemliteral using the double quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/ibm11v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/out/ibm11v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p11ibm11v02xml() { /* Test ID:ibm-valid-P11-ibm11v02.xml Test URI:valid/P11/ibm11v02.xml Spec Sections:2.3 Description:Tests empty systemliteral using the single quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/ibm11v02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/out/ibm11v02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p11ibm11v03xml() { /* Test ID:ibm-valid-P11-ibm11v03.xml Test URI:valid/P11/ibm11v03.xml Spec Sections:2.3 Description:Tests regular systemliteral using the single quotes */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/ibm11v03.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/out/ibm11v03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p11ibm11v04xml() { /* Test ID:ibm-valid-P11-ibm11v04.xml Test URI:valid/P11/ibm11v04.xml Spec Sections:2.3 Description:Tests regular systemliteral using the double quotes */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/ibm11v04.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P11/out/ibm11v04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p12ibm12v01xml() { /* Test ID:ibm-valid-P12-ibm12v01.xml Test URI:valid/P12/ibm12v01.xml Spec Sections:2.3 Description:Tests empty systemliteral using the double quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/ibm12v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/out/ibm12v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p12ibm12v02xml() { /* Test ID:ibm-valid-P12-ibm12v02.xml Test URI:valid/P12/ibm12v02.xml Spec Sections:2.3 Description:Tests empty systemliteral using the single quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/ibm12v02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/out/ibm12v02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p12ibm12v03xml() { /* Test ID:ibm-valid-P12-ibm12v03.xml Test URI:valid/P12/ibm12v03.xml Spec Sections:2.3 Description:Tests regular systemliteral using the double quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/ibm12v03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/out/ibm12v03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p12ibm12v04xml() { /* Test ID:ibm-valid-P12-ibm12v04.xml Test URI:valid/P12/ibm12v04.xml Spec Sections:2.3 Description:Tests regular systemliteral using the single quotes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/ibm12v04.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P12/out/ibm12v04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ibmvalid_p13ibm13v01xml() { /* Test ID:ibm-valid-P13-ibm13v01.xml Test URI:valid/P13/ibm13v01.xml Spec Sections:2.3 Description:Testing PubidChar with all legal PubidChar in a PubidLiteral */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P13/ibm13v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P13/out/ibm13v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p14ibm14v01xml() { /* Test ID:ibm-valid-P14-ibm14v01.xml Test URI:valid/P14/ibm14v01.xml Spec Sections:2.4 Description:Testing CharData with empty string */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P14/ibm14v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P14/out/ibm14v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p14ibm14v02xml() { /* Test ID:ibm-valid-P14-ibm14v02.xml Test URI:valid/P14/ibm14v02.xml Spec Sections:2.4 Description:Testing CharData with white space character */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P14/ibm14v02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P14/out/ibm14v02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); assert_eq!( parseresult.unwrap().get_canonical().unwrap(), canonicalparseresult.unwrap().get_canonical().unwrap() ); } #[test] fn ibmvalid_p14ibm14v03xml() { /* Test ID:ibm-valid-P14-ibm14v03.xml Test URI:valid/P14/ibm14v03.xml Spec Sections:2.4 Description:Testing CharData with a general text string */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P14/ibm14v03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P14/out/ibm14v03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p15ibm15v01xml() { /* Test ID:ibm-valid-P15-ibm15v01.xml Test URI:valid/P15/ibm15v01.xml Spec Sections:2.5 Description:Tests empty comment */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P15/ibm15v01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P15/out/ibm15v01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p15ibm15v02xml() { /* Test ID:ibm-valid-P15-ibm15v02.xml Test URI:valid/P15/ibm15v02.xml Spec Sections:2.5 Description:Tests comment with regular text */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P15/ibm15v02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P15/out/ibm15v02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p15ibm15v03xml() { /* Test ID:ibm-valid-P15-ibm15v03.xml Test URI:valid/P15/ibm15v03.xml Spec Sections:2.5 Description:Tests comment with one dash inside */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P15/ibm15v03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/valid/P15/out/ibm15v03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn ibmvalid_p15ibm15v04xml() { /* Test ID:ibm-valid-P15-ibm15v04.xml Test URI:valid/P15/ibm15v04.xml Spec Sections:2.5 Description:Tests comment with more comprehensive content */
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata3e_invalid.rs
tests/conformance/xml/eduni_errata3e_invalid.rs
/* Richard Tobin's XML 1.0 3rd edition errata test suite 1 June 2006 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn rmte3e06a() { /* Test ID:rmt-e3e-06a Test URI:E06a.xml Spec Sections:E06 Description:Default values for IDREF attributes must match Name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06a.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmte3e06b() { /* Test ID:rmt-e3e-06b Test URI:E06b.xml Spec Sections:E06 Description:Default values for ENTITY attributes must match Name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06b.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmte3e06c() { /* Test ID:rmt-e3e-06c Test URI:E06c.xml Spec Sections:E06 Description:Default values for IDREFS attributes must match Names. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06c.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmte3e06d() { /* Test ID:rmt-e3e-06d Test URI:E06d.xml Spec Sections:E06 Description:Default values for ENTITIES attributes must match Names. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06d.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmte3e06e() { /* Test ID:rmt-e3e-06e Test URI:E06e.xml Spec Sections:E06 Description:Default values for NMTOKEN attributes must match Nmtoken. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06e.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmte3e06f() { /* Test ID:rmt-e3e-06f Test URI:E06f.xml Spec Sections:E06 Description:Default values for NMTOKENS attributes must match Nmtokens. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06f.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmte3e06g() { /* Test ID:rmt-e3e-06g Test URI:E06g.xml Spec Sections:E06 Description:Default values for NOTATION attributes must match one of the enumerated values. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06g.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmte3e06h() { /* Test ID:rmt-e3e-06h Test URI:E06h.xml Spec Sections:E06 Description:Default values for enumerated attributes must match one of the enumerated values. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E06h.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmte3e13() { /* Test ID:rmt-e3e-13 Test URI:E13.xml Spec Sections:E13 Description:Even internal parameter entity references are enough to make undeclared entities into mere validity errors rather than well-formedness errors. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-3e/E13.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/ibm11_invalid.rs
tests/conformance/xml/ibm11_invalid.rs
/* IBM test cases */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] #[ignore] fn ibm11valid_p46ibm46i01xml() { /* Test ID:ibm-1-1-valid-P46-ibm46i01.xml Test URI:invalid/P46/ibm46i01.xml Spec Sections:3.2.1, 2.2 Description:An element with Element-Only content contains the character #x85 (NEL not a whitespace character as defined by S). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/invalid/P46/ibm46i01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibm11valid_p46ibm46i02xml() { /* Test ID:ibm-1-1-valid-P46-ibm46i02.xml Test URI:invalid/P46/ibm46i02.xml Spec Sections:3.2.1, 2.2 Description:An element with Element-Only content contains the character #x2028 (LESP not a whitespace character as defined by S). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/invalid/P46/ibm46i02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/ibm_error.rs
tests/conformance/xml/ibm_error.rs
/* IBM test cases */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; #[test] #[ignore] fn ibmnotwf_p69ibm69n05xml() { /* Test ID:ibm-not-wf-P69-ibm69n05.xml Test URI:not-wf/P69/ibm69n05.xml Spec Sections:4.1 Description:Based on E29 substantial source: minutes XML-Syntax 1999-02-24 E38 in XML 1.0 Errata, this WFC does not apply to P69, but the VC Entity declared still apply. Tests PEReference which is against P69 WFC: Entity Declared. The PE with the name "paaa" is referred before declared in the DTD. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P69/ibm69n05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p68ibm68i01xml() { /* Test ID:ibm-invalid-P68-ibm68i01.xml Test URI:invalid/P68/ibm68i01.xml Spec Sections:4.1 Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge2" is referred in the file ibm68i01.dtd", but not declared. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P68/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i01.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p68ibm68i02xml() { /* Test ID:ibm-invalid-P68-ibm68i02.xml Test URI:invalid/P68/ibm68i02.xml Spec Sections:4.1 Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge1" is referred before declared in the file ibm68i01.dtd". */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P68/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i02.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p68ibm68i03xml() { /* Test ID:ibm-invalid-P68-ibm68i03.xml Test URI:invalid/P68/ibm68i03.xml Spec Sections:4.1 Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge2" is referred in the file ibm68i03.ent", but not declared. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P68/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i03.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p68ibm68i04xml() { /* Test ID:ibm-invalid-P68-ibm68i04.xml Test URI:invalid/P68/ibm68i04.xml Spec Sections:4.1 Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge1" is referred before declared in the file ibm68i04.ent". */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P68/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p69ibm69i01xml() { /* Test ID:ibm-invalid-P69-ibm69i01.xml Test URI:invalid/P69/ibm69i01.xml Spec Sections:4.1 Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The Name "pe2" in the PEReference in the file ibm69i01.dtd does not match the Name of any declared PE. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P69/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i01.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p69ibm69i02xml() { /* Test ID:ibm-invalid-P69-ibm69i02.xml Test URI:invalid/P69/ibm69i02.xml Spec Sections:4.1 Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The PE with the name "pe1" is referred before declared in the file ibm69i02.dtd */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P69/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i02.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p69ibm69i03xml() { /* Test ID:ibm-invalid-P69-ibm69i03.xml Test URI:invalid/P69/ibm69i03.xml Spec Sections:4.1 Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The Name "pe3" in the PEReference in the file ibm69i03.ent does not match the Name of any declared PE. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P69/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i03.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn ibminvalid_p69ibm69i04xml() { /* Test ID:ibm-invalid-P69-ibm69i04.xml Test URI:invalid/P69/ibm69i04.xml Spec Sections:4.1 Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The PE with the name "pe2" is referred before declared in the file ibm69i04.ent. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/invalid/P69/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i04.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata2e_invalid.rs
tests/conformance/xml/eduni_errata2e_invalid.rs
/* Richard Tobin's XML 1.0 2nd edition errata test suite. */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] #[ignore] fn rmte2e2a() { /* Test ID:rmt-e2e-2a Test URI:E2a.xml Spec Sections:E2 Description:Duplicate token in enumerated attribute declaration */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E2a.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e2b() { /* Test ID:rmt-e2e-2b Test URI:E2b.xml Spec Sections:E2 Description:Duplicate token in NOTATION attribute declaration */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E2b.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e9b() { /* Test ID:rmt-e2e-9b Test URI:E9b.xml Spec Sections:E9 Description:An attribute default must be syntactically correct even if unused */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E9b.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmte2e14() { /* Test ID:rmt-e2e-14 Test URI:E14.xml Spec Sections:E14 Description:Declarations mis-nested wrt parameter entities are just validity errors (but note that some parsers treat some such errors as fatal) */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/eduni/errata-2e/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E14.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmte2e15a() { /* Test ID:rmt-e2e-15a Test URI:E15a.xml Spec Sections:E15 Description:Empty content can't contain an entity reference */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15a.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e15b() { /* Test ID:rmt-e2e-15b Test URI:E15b.xml Spec Sections:E15 Description:Empty content can't contain a comment */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15b.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e15c() { /* Test ID:rmt-e2e-15c Test URI:E15c.xml Spec Sections:E15 Description:Empty content can't contain a PI */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15c.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e15d() { /* Test ID:rmt-e2e-15d Test URI:E15d.xml Spec Sections:E15 Description:Empty content can't contain whitespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15d.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e15g() { /* Test ID:rmt-e2e-15g Test URI:E15g.xml Spec Sections:E15 Description:Element content can't contain character reference to whitespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15g.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e15h() { /* Test ID:rmt-e2e-15h Test URI:E15h.xml Spec Sections:E15 Description:Element content can't contain entity reference if replacement text is character reference to whitespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15h.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmte2e20() { /* Test ID:rmt-e2e-20 Test URI:E20.xml Spec Sections:E20 Description:Tokens, after normalization, must be separated by space, not other whitespace characters */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E20.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata4e_error.rs
tests/conformance/xml/eduni_errata4e_error.rs
/* University of Edinburgh XML 1.0 4th edition errata test suite. */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn invalidbo7() { /* Test ID:invalid-bo-7 Test URI:inclbomboom_be.xml Spec Sections:4.3.3 Description:A byte order mark and a backwards one in general entity cause an illegal char. error (big-endian) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbomboom_be.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn invalidbo8() { /* Test ID:invalid-bo-8 Test URI:inclbomboom_le.xml Spec Sections:4.3.3 Description:A byte order mark and a backwards one in general entity cause an illegal char. error (little-endian) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbomboom_le.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn invalidbo9() { /* Test ID:invalid-bo-9 Test URI:incl8bomboom.xml Spec Sections:4.3.3 Description:A byte order mark and a backwards one in general entity cause an illegal char. error (utf-8) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/incl8bomboom.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } /* #[test] #[ignore] fn xrmt008() { /* This test is deliberately ignored. In 5th edition, any document number other than 1.1 is treated as a 1.0 document. */ /* Test ID:x-rmt-008 Test URI:008.xml Spec Sections:2.8 4.3.4 Description:a document with version=1.7, illegal in XML 1.0 through 4th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/008.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_namespaces_10_notwf.rs
tests/conformance/xml/eduni_namespaces_10_notwf.rs
/* Richard Tobin's XML Namespaces 1.0 test suite 14 Feb 2003 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn rmtns10009() { /* Test ID:rmt-ns10-009 Test URI:009.xml Spec Sections:1 Description:Namespace equality test: plain repetition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/009.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10010() { /* Test ID:rmt-ns10-010 Test URI:010.xml Spec Sections:1 Description:Namespace equality test: use of character reference */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/010.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10011() { /* Test ID:rmt-ns10-011 Test URI:011.xml Spec Sections:1 Description:Namespace equality test: use of entity reference */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/011.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10012() { /* Test ID:rmt-ns10-012 Test URI:012.xml Spec Sections:1 Description:Namespace inequality test: equal after attribute value normalization */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/012.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10013() { /* Test ID:rmt-ns10-013 Test URI:013.xml Spec Sections:3 Description:Bad QName syntax: multiple colons */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/013.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10014() { /* Test ID:rmt-ns10-014 Test URI:014.xml Spec Sections:3 Description:Bad QName syntax: colon at end */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/014.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10015() { /* Test ID:rmt-ns10-015 Test URI:015.xml Spec Sections:3 Description:Bad QName syntax: colon at start */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/015.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10016() { /* Test ID:rmt-ns10-016 Test URI:016.xml Spec Sections:2 Description:Bad QName syntax: xmlns: */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/016.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10023() { /* Test ID:rmt-ns10-023 Test URI:023.xml Spec Sections:2 Description:Illegal use of 1.1-style prefix unbinding in 1.0 document */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/023.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10025() { /* Test ID:rmt-ns10-025 Test URI:025.xml Spec Sections:4 Description:Unbound element prefix */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/025.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10026() { /* Test ID:rmt-ns10-026 Test URI:026.xml Spec Sections:4 Description:Unbound attribute prefix */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/026.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10029() { /* Test ID:rmt-ns10-029 Test URI:029.xml Spec Sections:NE05 Description:Reserved prefixes and namespaces: declaring the xml prefix incorrectly */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/029.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10030() { /* Test ID:rmt-ns10-030 Test URI:030.xml Spec Sections:NE05 Description:Reserved prefixes and namespaces: binding another prefix to the xml namespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/030.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10031() { /* Test ID:rmt-ns10-031 Test URI:031.xml Spec Sections:NE05 Description:Reserved prefixes and namespaces: declaring the xmlns prefix with its correct URI (illegal) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/031.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10032() { /* Test ID:rmt-ns10-032 Test URI:032.xml Spec Sections:NE05 Description:Reserved prefixes and namespaces: declaring the xmlns prefix with an incorrect URI */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/032.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10033() { /* Test ID:rmt-ns10-033 Test URI:033.xml Spec Sections:NE05 Description:Reserved prefixes and namespaces: binding another prefix to the xmlns namespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/033.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10035() { /* Test ID:rmt-ns10-035 Test URI:035.xml Spec Sections:5.3 Description:Attribute uniqueness: repeated identical attribute */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/035.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10036() { /* Test ID:rmt-ns10-036 Test URI:036.xml Spec Sections:5.3 Description:Attribute uniqueness: repeated attribute with different prefixes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/036.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10042() { /* Test ID:rmt-ns10-042 Test URI:042.xml Spec Sections:NE08 Description:Colon in PI name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/042.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10043() { /* Test ID:rmt-ns10-043 Test URI:043.xml Spec Sections:NE08 Description:Colon in entity name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/043.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtns10044() { /* Test ID:rmt-ns10-044 Test URI:044.xml Spec Sections:NE08 Description:Colon in entity name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/044.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/ibm11_notwf.rs
tests/conformance/xml/ibm11_notwf.rs
/* IBM test cases */ use crate::conformance::{dtdfileresolve, non_utf8_file_reader}; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; #[test] fn ibm11notwf_p02ibm02n01xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n01.xml Test URI:not-wf/P02/ibm02n01.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n02xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n02.xml Test URI:not-wf/P02/ibm02n02.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x2. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n03xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n03.xml Test URI:not-wf/P02/ibm02n03.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x3. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n04xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n04.xml Test URI:not-wf/P02/ibm02n04.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x4. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n05xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n05.xml Test URI:not-wf/P02/ibm02n05.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x5. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n06xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n06.xml Test URI:not-wf/P02/ibm02n06.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x6. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n07xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n07.xml Test URI:not-wf/P02/ibm02n07.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x7. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n08xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n08.xml Test URI:not-wf/P02/ibm02n08.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x8. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n09xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n09.xml Test URI:not-wf/P02/ibm02n09.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x0. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n10xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n10.xml Test URI:not-wf/P02/ibm02n10.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x100. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n11xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n11.xml Test URI:not-wf/P02/ibm02n11.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x0B. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n12xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n12.xml Test URI:not-wf/P02/ibm02n12.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x0C. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n14xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n14.xml Test URI:not-wf/P02/ibm02n14.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x0E. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n14.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n15xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n15.xml Test URI:not-wf/P02/ibm02n15.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x0F. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n15.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n16xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n16.xml Test URI:not-wf/P02/ibm02n16.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x10. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n16.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n17xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n17.xml Test URI:not-wf/P02/ibm02n17.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x11. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n17.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n18xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n18.xml Test URI:not-wf/P02/ibm02n18.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x12. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n18.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n19xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n19.xml Test URI:not-wf/P02/ibm02n19.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x13. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n19.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n20xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n20.xml Test URI:not-wf/P02/ibm02n20.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x14. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n20.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n21xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n21.xml Test URI:not-wf/P02/ibm02n21.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x15. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n21.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n22xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n22.xml Test URI:not-wf/P02/ibm02n22.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x16. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n22.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n23xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n23.xml Test URI:not-wf/P02/ibm02n23.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x17. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n23.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n24xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n24.xml Test URI:not-wf/P02/ibm02n24.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x18. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n24.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n25xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n25.xml Test URI:not-wf/P02/ibm02n25.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x19. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n25.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n26xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n26.xml Test URI:not-wf/P02/ibm02n26.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x1A. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n26.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n27xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n27.xml Test URI:not-wf/P02/ibm02n27.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x1B. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n27.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n28xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n28.xml Test URI:not-wf/P02/ibm02n28.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x1C. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n28.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n29xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n29.xml Test URI:not-wf/P02/ibm02n29.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x1D. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n29.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n30xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n30.xml Test URI:not-wf/P02/ibm02n30.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x1E. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n30.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n31xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n31.xml Test URI:not-wf/P02/ibm02n31.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x1F. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n31.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n32xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n32.xml Test URI:not-wf/P02/ibm02n32.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x7F. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/ibm/xml-1.1/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n32.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n33xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n33.xml Test URI:not-wf/P02/ibm02n33.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x80. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n33.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n34xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n34.xml Test URI:not-wf/P02/ibm02n34.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x81. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n34.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n35xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n35.xml Test URI:not-wf/P02/ibm02n35.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x82. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n35.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n36xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n36.xml Test URI:not-wf/P02/ibm02n36.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x83. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n36.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n37xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n37.xml Test URI:not-wf/P02/ibm02n37.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x84. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n37.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n38xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n38.xml Test URI:not-wf/P02/ibm02n38.xml Spec Sections:2.2,4.1 Description:This test contains embeded control characters x82, x83 and x84. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n38.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n39xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n39.xml Test URI:not-wf/P02/ibm02n39.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x86. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n39.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n40xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n40.xml Test URI:not-wf/P02/ibm02n40.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x87. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n40.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n41xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n41.xml Test URI:not-wf/P02/ibm02n41.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x88. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n41.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n42xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n42.xml Test URI:not-wf/P02/ibm02n42.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x89. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n42.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n43xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n43.xml Test URI:not-wf/P02/ibm02n43.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x8A. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n43.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n44xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n44.xml Test URI:not-wf/P02/ibm02n44.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x8B. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n44.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n45xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n45.xml Test URI:not-wf/P02/ibm02n45.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x8C. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n45.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n46xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n46.xml Test URI:not-wf/P02/ibm02n46.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x8D. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n46.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n47xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n47.xml Test URI:not-wf/P02/ibm02n47.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x8E. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n47.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n48xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n48.xml Test URI:not-wf/P02/ibm02n48.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x8F. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n48.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n49xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n49.xml Test URI:not-wf/P02/ibm02n49.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x90. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n49.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n50xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n50.xml Test URI:not-wf/P02/ibm02n50.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x91. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n50.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n51xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n51.xml Test URI:not-wf/P02/ibm02n51.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x92. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n51.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n52xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n52.xml Test URI:not-wf/P02/ibm02n52.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x93. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n52.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n53xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n53.xml Test URI:not-wf/P02/ibm02n53.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x94. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n53.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n54xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n54.xml Test URI:not-wf/P02/ibm02n54.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x95. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n54.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n55xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n55.xml Test URI:not-wf/P02/ibm02n55.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x96. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n55.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n56xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n56.xml Test URI:not-wf/P02/ibm02n56.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x97. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n56.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n57xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n57.xml Test URI:not-wf/P02/ibm02n57.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x98. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n57.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn ibm11notwf_p02ibm02n58xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n58.xml Test URI:not-wf/P02/ibm02n58.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x99. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n58.xml") .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n59xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n59.xml Test URI:not-wf/P02/ibm02n59.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x9A. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n59.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n60xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n60.xml Test URI:not-wf/P02/ibm02n60.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x9B. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n60.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n61xml() { /* Test ID:ibm-1-1-not-wf-P02-ibm02n61.xml Test URI:not-wf/P02/ibm02n61.xml Spec Sections:2.2,4.1 Description:This test contains embeded control character 0x9C. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/ibm/xml-1.1/not-wf/P02/ibm02n61.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn ibm11notwf_p02ibm02n62xml() { /*
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_xml11_notwf.rs
tests/conformance/xml/eduni_xml11_notwf.rs
/* Richard Tobin's XML 1.1 test suite 13 Feb 2003 */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; #[test] fn rmt001() { /* Test ID:rmt-001 Test URI:001.xml Spec Sections:2.8 4.3.4 Description:External subset has later version number */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/eduni/xml-1.1/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/001.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn rmt002() { /* Test ID:rmt-002 Test URI:002.xml Spec Sections:2.8 4.3.4 Description:External PE has later version number */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/eduni/xml-1.1/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/002.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn rmt003() { /* Test ID:rmt-003 Test URI:003.xml Spec Sections:2.8 4.3.4 Description:External general entity has later version number */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/eduni/xml-1.1/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/003.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn rmt004() { /* Test ID:rmt-004 Test URI:004.xml Spec Sections:2.8 4.3.4 Description:External general entity has later version number (no decl means 1.0) */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/eduni/xml-1.1/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/004.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn rmt005() { /* Test ID:rmt-005 Test URI:005.xml Spec Sections:2.8 4.3.4 Description:Indirect external general entity has later version number */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/eduni/xml-1.1/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/005.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmt011() { /* Test ID:rmt-011 Test URI:011.xml Spec Sections:2.2 Description:Contains a C1 control, legal in XML 1.0, illegal in XML 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/011.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmt013() { /* Test ID:rmt-013 Test URI:013.xml Spec Sections:2.2 Description:Contains a DEL, legal in XML 1.0, illegal in XML 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/013.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } /* #[test] #[ignore] fn rmt014() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:rmt-014 Test URI:014.xml Spec Sections:2.3 Description:Has a "long s" in a name, legal in XML 1.1, illegal in XML 1.0 thru 4th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/014.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn rmt016() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:rmt-016 Test URI:016.xml Spec Sections:2.3 Description:Has a Byzantine Musical Symbol Kratimata in a name, legal in XML 1.1, illegal in XML 1.0 thru 4th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/016.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn rmt019() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:rmt-019 Test URI:019.xml Spec Sections:2.3 Description:Has the last legal namechar in XML 1.1, illegal in XML 1.0 thru 4th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/019.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ #[test] fn rmt020() { /* Test ID:rmt-020 Test URI:020.xml Spec Sections:2.3 Description:Has the first character after the last legal namechar in XML 1.1, illegal in both XML 1.0 and 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/020.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmt021() { /* Test ID:rmt-021 Test URI:021.xml Spec Sections:2.3 Description:Has the first character after the last legal namechar in XML 1.1, illegal in both XML 1.0 and 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/021.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmt038() { /* Test ID:rmt-038 Test URI:038.xml Spec Sections:2.2 Description:Contains a C0 control character (form-feed), illegal in both XML 1.0 and 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/038.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmt039() { /* Test ID:rmt-039 Test URI:039.xml Spec Sections:2.2 Description:Contains a C0 control character (form-feed), illegal in both XML 1.0 and 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/039.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmt041() { /* Test ID:rmt-041 Test URI:041.xml Spec Sections:2.2 Description:Contains a C1 control character (partial line up), legal in XML 1.0 but not 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/041.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmt042() { /* Test ID:rmt-042 Test URI:042.xml Spec Sections:4.1 Description:Contains a character reference to a C0 control character (form-feed), legal in XML 1.1 but not 1.0 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/042.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/sun_error.rs
tests/conformance/xml/sun_error.rs
/* Sun Microsystems test cases */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn uri01() { /* Test ID:uri01 Test URI:not-wf/uri01.xml Spec Sections:4.2.2 [75] Description: SYSTEM ids may not have URI fragments */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/uri01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/xmltest_notwf_not_sa.rs
tests/conformance/xml/xmltest_notwf_not_sa.rs
/* James Clark XMLTEST cases - Standalone This contains cases that are not well-formed XML documents This contains cases that are not standalone. */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; #[test] fn notwfnotsa001() { /* Test ID:not-wf-not-sa-001 Test URI:not-wf/not-sa/001.xml Spec Sections:3.4 [62] Description:Conditional sections must be properly terminated ("]>" usedinstead of "]]>"). */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/001.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa002() { /* Test ID:not-wf-not-sa-002 Test URI:not-wf/not-sa/002.xml Spec Sections:2.6 [17] Description:Processing instruction target names may not be "XML"in any combination of cases. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/002.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa003() { /* Test ID:not-wf-not-sa-003 Test URI:not-wf/not-sa/003.xml Spec Sections:3.4 [62] Description:Conditional sections must be properly terminated ("]]>" omitted). */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/003.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa004() { /* Test ID:not-wf-not-sa-004 Test URI:not-wf/not-sa/004.xml Spec Sections:3.4 [62] Description:Conditional sections must be properly terminated ("]]>" omitted). */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/004.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa005() { /* Test ID:not-wf-not-sa-005 Test URI:not-wf/not-sa/005.xml Spec Sections:4.1 Description:Tests the Entity Declared VC by referring to anundefined parameter entity within an external entity. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/005.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa006() { /* Test ID:not-wf-not-sa-006 Test URI:not-wf/not-sa/006.xml Spec Sections:3.4 [62] Description:Conditional sections need a '[' after the INCLUDE or IGNORE. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/006.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa007() { /* Test ID:not-wf-not-sa-007 Test URI:not-wf/not-sa/007.xml Spec Sections:4.3.2 [79] Description:A <!DOCTYPE ...> declaration may not begin any externalentity; it's only found once, in the document entity. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/007.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa008() { /* Test ID:not-wf-not-sa-008 Test URI:not-wf/not-sa/008.xml Spec Sections:4.1 [69] Description:In DTDs, the '%' character must be part of a parameterentity reference. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/008.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn notwfnotsa009() { /* Test ID:not-wf-not-sa-009 Test URI:not-wf/not-sa/009.xml Spec Sections:2.8 Description:This test violates WFC:PE Between Declarations in Production 28a.The last character of a markup declaration is not contained in the sameparameter-entity text replacement. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/not-sa/009.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata2e_valid.rs
tests/conformance/xml/eduni_errata2e_valid.rs
/* Richard Tobin's XML 1.0 2nd edition errata test suite. */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] #[ignore] fn rmte2e9a() { /* Test ID:rmt-e2e-9a Test URI:E9a.xml Spec Sections:E9 Description:An unused attribute default need only be syntactically correct */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E9a.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e15e() { /* Test ID:rmt-e2e-15e Test URI:E15e.xml Spec Sections:E15 Description:Element content can contain entity reference if replacement text is whitespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15e.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e15f() { /* Test ID:rmt-e2e-15f Test URI:E15f.xml Spec Sections:E15 Description:Element content can contain entity reference if replacement text is whitespace, even if it came from a character reference in the literal entity value */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15f.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e15i() { /* Test ID:rmt-e2e-15i Test URI:E15i.xml Spec Sections:E15 Description:Element content can contain a comment */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15i.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e15j() { /* Test ID:rmt-e2e-15j Test URI:E15j.xml Spec Sections:E15 Description:Element content can contain a PI */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15j.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e15k() { /* Test ID:rmt-e2e-15k Test URI:E15k.xml Spec Sections:E15 Description:Mixed content can contain a comment */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15k.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e15l() { /* Test ID:rmt-e2e-15l Test URI:E15l.xml Spec Sections:E15 Description:Mixed content can contain a PI */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15l.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] #[ignore] fn rmte2e18() { /* Test ID:rmt-e2e-18 Test URI:E18.xml Spec Sections:E18 Description:External entity containing start of entity declaration is base URI for system identifier */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E18.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E18.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmte2e19() { /* Test ID:rmt-e2e-19 Test URI:E19.xml Spec Sections:E19 Description:Parameter entities and character references are included-in-literal, but general entities are bypassed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E19.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E19.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmte2e22() { /* Test ID:rmt-e2e-22 Test URI:E22.xml Spec Sections:E22 Description:UTF-8 entities may start with a BOM */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E22.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e24() { /* Test ID:rmt-e2e-24 Test URI:E24.xml Spec Sections:E24 Description:Either the built-in entity or a character reference can be used to represent greater-than after two close-square-brackets */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E24.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e29() { /* Test ID:rmt-e2e-29 Test URI:E29.xml Spec Sections:E29 Description:Three-letter language codes are allowed */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E29.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] #[ignore] fn rmte2e36() { /* Test ID:rmt-e2e-36 Test URI:E36.xml Spec Sections:E36 Description:An external ATTLIST declaration does not make a document non-standalone if the normalization would have been the same without the declaration */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E36.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e41() { /* Test ID:rmt-e2e-41 Test URI:E41.xml Spec Sections:E41 Description:An xml:lang attribute may be empty */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E41.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e48() { /* Test ID:rmt-e2e-48 Test URI:E48.xml Spec Sections:E48 Description:ANY content allows character data */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E48.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] #[ignore] fn rmte2e50() { /* Test ID:rmt-e2e-50 Test URI:E50.xml Spec Sections:E50 Description:All line-ends are normalized, even those not passed to the application. NB this can only be tested effectively in XML 1.1, since CR is in the S production; in 1.1 we can use NEL which isn't. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E50.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmte2e60() { /* Test ID:rmt-e2e-60 Test URI:E60.xml Spec Sections:E60 Description:Conditional sections are allowed in external parameter entities referred to from the internal subset. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/eduni/errata-2e/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E60.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_namespaces_11_valid.rs
tests/conformance/xml/eduni_namespaces_11_valid.rs
/* Richard Tobin's XML Namespaces 1.1 test suite 14 Feb 2003 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] #[ignore] fn rmtns11001() { /* Test ID:rmt-ns11-001 Test URI:001.xml Spec Sections:2.1 Description:Namespace name test: a perfectly good http IRI that is not a URI */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/001.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] #[ignore] fn rmtns11002() { /* Test ID:rmt-ns11-002 Test URI:002.xml Spec Sections:2.3 Description:Namespace inequality test: different escaping of non-ascii letter */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/002.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmtns11003() { /* Test ID:rmt-ns11-003 Test URI:003.xml Spec Sections:6.1 Description:1.1 style prefix unbinding */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/003.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmtns11004() { /* Test ID:rmt-ns11-004 Test URI:004.xml Spec Sections:6.1 Description:1.1 style prefix unbinding and rebinding */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/004.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] #[ignore] fn rmtns11006() { /* Test ID:rmt-ns11-006 Test URI:006.xml Spec Sections:2.1 Description:Test whether non-Latin-1 characters are accepted in IRIs, and whether they are correctly distinguished */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/006.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_namespaces_10_invalid.rs
tests/conformance/xml/eduni_namespaces_10_invalid.rs
/* Richard Tobin's XML Namespaces 1.0 test suite 14 Feb 2003 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] fn rmtns10017() { /* Test ID:rmt-ns10-017 Test URI:017.xml Spec Sections:- Description:Simple legal case: no namespaces */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/017.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10018() { /* Test ID:rmt-ns10-018 Test URI:018.xml Spec Sections:5.2 Description:Simple legal case: default namespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/018.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10019() { /* Test ID:rmt-ns10-019 Test URI:019.xml Spec Sections:4 Description:Simple legal case: prefixed element */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/019.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10020() { /* Test ID:rmt-ns10-020 Test URI:020.xml Spec Sections:4 Description:Simple legal case: prefixed attribute */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/020.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10021() { /* Test ID:rmt-ns10-021 Test URI:021.xml Spec Sections:5.2 Description:Simple legal case: default namespace and unbinding */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/021.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10022() { /* Test ID:rmt-ns10-022 Test URI:022.xml Spec Sections:5.2 Description:Simple legal case: default namespace and rebinding */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/022.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10024() { /* Test ID:rmt-ns10-024 Test URI:024.xml Spec Sections:5.1 Description:Simple legal case: prefix rebinding */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/024.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10027() { /* Test ID:rmt-ns10-027 Test URI:027.xml Spec Sections:2 Description:Reserved prefixes and namespaces: using the xml prefix undeclared */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/027.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10028() { /* Test ID:rmt-ns10-028 Test URI:028.xml Spec Sections:NE05 Description:Reserved prefixes and namespaces: declaring the xml prefix correctly */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/028.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10034() { /* Test ID:rmt-ns10-034 Test URI:034.xml Spec Sections:NE05 Description:Reserved prefixes and namespaces: binding a reserved prefix */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/034.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10037() { /* Test ID:rmt-ns10-037 Test URI:037.xml Spec Sections:5.3 Description:Attribute uniqueness: different attributes with same local name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/037.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10038() { /* Test ID:rmt-ns10-038 Test URI:038.xml Spec Sections:5.3 Description:Attribute uniqueness: prefixed and unprefixed attributes with same local name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/038.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10039() { /* Test ID:rmt-ns10-039 Test URI:039.xml Spec Sections:5.3 Description:Attribute uniqueness: prefixed and unprefixed attributes with same local name, with default namespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/039.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10040() { /* Test ID:rmt-ns10-040 Test URI:040.xml Spec Sections:5.3 Description:Attribute uniqueness: prefixed and unprefixed attributes with same local name, with default namespace and element in default namespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/040.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn rmtns10041() { /* Test ID:rmt-ns10-041 Test URI:041.xml Spec Sections:5.3 Description:Attribute uniqueness: prefixed and unprefixed attributes with same local name, element in same namespace as prefixed attribute */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/041.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmtns10045() { /* Test ID:rmt-ns10-045 Test URI:045.xml Spec Sections:NE08 Description:Colon in ID attribute name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/045.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn rmtns10046() { /* Test ID:rmt-ns10-046 Test URI:046.xml Spec Sections:NE08 Description:Colon in ID attribute name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/046.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/xmltest_valid_not_sa.rs
tests/conformance/xml/xmltest_valid_not_sa.rs
/* James Clark XMLTEST cases - Standalone This contains cases that are valid XML documents. This contains cases that are not standalone. */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] fn validnotsa001() { /* Test ID:valid-not-sa-001 Test URI:valid/not-sa/001.xml Spec Sections:4.2.2 [75] Description:Test demonstrates the use of an ExternalID within a document type definition. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/001.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/001.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validnotsa002() { /* Test ID:valid-not-sa-002 Test URI:valid/not-sa/002.xml Spec Sections:4.2.2 [75] Description:Test demonstrates the use of an ExternalID within a document type definition. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/002.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/002.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa003() { /* Test ID:valid-not-sa-003 Test URI:valid/not-sa/003.xml Spec Sections:4.1 [69] Description:Test demonstrates the expansion of an external parameter entity that declares an attribute. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/003.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/003.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa004() { /* Test ID:valid-not-sa-004 Test URI:valid/not-sa/004.xml Spec Sections:4.1 [69] Description:Expands an external parameter entity in two different ways, with one of them declaring an attribute. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/004.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/004.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa005() { /* Test ID:valid-not-sa-005 Test URI:valid/not-sa/005.xml Spec Sections:4.1 [69] Description:Test demonstrates the expansion of an external parameter entity that declares an attribute. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/005.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/005.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa006() { /* Test ID:valid-not-sa-006 Test URI:valid/not-sa/006.xml Spec Sections:3.3 [52] Description:Test demonstrates that when more than one definition is provided for the same attribute of a given element type only the first declaration is binding. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/006.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/006.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa007() { /* Test ID:valid-not-sa-007 Test URI:valid/not-sa/007.xml Spec Sections:3.3 [52] Description:Test demonstrates the use of an Attribute list declaration within an external entity. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/007.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/007.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa008() { /* Test ID:valid-not-sa-008 Test URI:valid/not-sa/008.xml Spec Sections:4.2.2 [75] Description:Test demonstrates that an external identifier may include a public identifier. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/008.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/008.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa009() { /* Test ID:valid-not-sa-009 Test URI:valid/not-sa/009.xml Spec Sections:4.2.2 [75] Description:Test demonstrates that an external identifier may include a public identifier. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/009.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/009.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa010() { /* Test ID:valid-not-sa-010 Test URI:valid/not-sa/010.xml Spec Sections:3.3 [52] Description:Test demonstrates that when more that one definition is provided for the same attribute of a given element type only the first declaration is binding. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/010.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/010.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa011() { /* Test ID:valid-not-sa-011 Test URI:valid/not-sa/011.xml Spec Sections:4.2 4.2.1 [72] [75] Description:Test demonstrates a parameter entity declaration whose parameter entity definition is an ExternalID. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/011.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/011.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa012() { /* Test ID:valid-not-sa-012 Test URI:valid/not-sa/012.xml Spec Sections:4.3.1 [77] Description:Test demonstrates an enternal parsed entity that begins with a text declaration. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/012.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/012.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa013() { /* Test ID:valid-not-sa-013 Test URI:valid/not-sa/013.xml Spec Sections:3.4 [62] Description:Test demonstrates the use of the conditional section INCLUDE that will include its contents as part of the DTD. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/013.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/013.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa014() { /* Test ID:valid-not-sa-014 Test URI:valid/not-sa/014.xml Spec Sections:3.4 [62] Description:Test demonstrates the use of the conditional section INCLUDE that will include its contents as part of the DTD. The keyword is a parameter-entity reference. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/014.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/014.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa015() { /* Test ID:valid-not-sa-015 Test URI:valid/not-sa/015.xml Spec Sections:3.4 [63] Description:Test demonstrates the use of the conditonal section IGNORE the will ignore its content from being part of the DTD. The keyword is a parameter-entity reference. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/015.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/015.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa016() { /* Test ID:valid-not-sa-016 Test URI:valid/not-sa/016.xml Spec Sections:3.4 [62] Description:Test demonstrates the use of the conditional section INCLUDE that will include its contents as part of the DTD. The keyword is a parameter-entity reference. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/016.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/016.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa017() { /* Test ID:valid-not-sa-017 Test URI:valid/not-sa/017.xml Spec Sections:4.2 [72] Description:Test demonstrates a parameter entity declaration that contains an attribute list declaration. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/017.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/017.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa018() { /* Test ID:valid-not-sa-018 Test URI:valid/not-sa/018.xml Spec Sections:4.2.2 [75] Description:Test demonstrates an EnternalID whose contents contain an parameter entity declaration and a attribute list definition. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/018.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/018.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa019() { /* Test ID:valid-not-sa-019 Test URI:valid/not-sa/019.xml Spec Sections:4.4.8 Description:Test demonstrates that a parameter entity will be expanded with spaces on either side. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/019.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/019.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa020() { /* Test ID:valid-not-sa-020 Test URI:valid/not-sa/020.xml Spec Sections:4.4.8 Description:Parameter entities expand with spaces on either side. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/020.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/020.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa021() { /* Test ID:valid-not-sa-021 Test URI:valid/not-sa/021.xml Spec Sections:4.2 [72] Description:Test demonstrates a parameter entity declaration that contains a partial attribute list declaration. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/021.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/021.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa023() { /* Test ID:valid-not-sa-023 Test URI:valid/not-sa/023.xml Spec Sections:2.3 4.1 [10] [69] Description:Test demonstrates the use of a parameter entity reference within an attribute list declaration. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/023.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/023.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa024() { /* Test ID:valid-not-sa-024 Test URI:valid/not-sa/024.xml Spec Sections:2.8, 4.1 [69] Description:Constructs an <!ATTLIST...> declaration from several PEs. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/024.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/024.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa025() { /* Test ID:valid-not-sa-025 Test URI:valid/not-sa/025.xml Spec Sections:4.2 Description:Test demonstrates that when more that one definition is provided for the same entity only the first declaration is binding. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/025.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/025.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa026() { /* Test ID:valid-not-sa-026 Test URI:valid/not-sa/026.xml Spec Sections:3.3 [52] Description:Test demonstrates that when more that one definition is provided for the same attribute of a given element type only the first declaration is binding. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/026.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/026.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validnotsa027() { /* Test ID:valid-not-sa-027 Test URI:valid/not-sa/027.xml Spec Sections:4.1 [69] Description:Test demonstrates a parameter entity reference whose value is NULL. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/027.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/not-sa/out/027.xml") .unwrap() .as_str(), None, );
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/xmltest_valid_sa.rs
tests/conformance/xml/xmltest_valid_sa.rs
/* James Clark XMLTEST cases - Standalone This contains cases that are valid XML documents. This contains cases that are standalone (as defined in XML) and do not have references to external general entities. */ use crate::conformance::{dtdfileresolve, non_utf8_file_reader}; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] fn validsa001() { /* Test ID:valid-sa-001 Test URI:valid/sa/001.xml Spec Sections:3.2.2 [51] Description:Test demonstrates an Element Type Declaration with Mixed Content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/001.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/001.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa002() { /* Test ID:valid-sa-002 Test URI:valid/sa/002.xml Spec Sections:3.1 [40] Description:Test demonstrates that whitespace is permitted after the tag name in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/002.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/002.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa003() { /* Test ID:valid-sa-003 Test URI:valid/sa/003.xml Spec Sections:3.1 [42] Description:Test demonstrates that whitespace is permitted after the tag name in an End-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/003.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/003.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa004() { /* Test ID:valid-sa-004 Test URI:valid/sa/004.xml Spec Sections:3.1 [41] Description:Test demonstrates a valid attribute specification within a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/004.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/004.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa005() { /* Test ID:valid-sa-005 Test URI:valid/sa/005.xml Spec Sections:3.1 [40] Description:Test demonstrates a valid attribute specification within a Start-tag thatcontains whitespace on both sides of the equal sign. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/005.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/005.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa006() { /* Test ID:valid-sa-006 Test URI:valid/sa/006.xml Spec Sections:3.1 [41] Description:Test demonstrates that the AttValue within a Start-tag can use a single quote as a delimter. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/006.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/006.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa007() { /* Test ID:valid-sa-007 Test URI:valid/sa/007.xml Spec Sections:3.1 4.6 [43] Description:Test demonstrates numeric character references can be used for element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/007.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/007.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validsa008() { /* Test ID:valid-sa-008 Test URI:valid/sa/008.xml Spec Sections:2.4 3.1 [43] Description:Test demonstrates character references can be used for element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/008.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/008.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa009() { /* Test ID:valid-sa-009 Test URI:valid/sa/009.xml Spec Sections:2.3 3.1 [43] Description:Test demonstrates that PubidChar can be used for element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/009.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/009.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa010() { /* Test ID:valid-sa-010 Test URI:valid/sa/010.xml Spec Sections:3.1 [40] Description:Test demonstrates that whitespace is valid after the Attribute in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/010.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/010.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa011() { /* Test ID:valid-sa-011 Test URI:valid/sa/011.xml Spec Sections:3.1 [40] Description:Test demonstrates mutliple Attibutes within the Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/011.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/011.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } /* #[test] #[ignore] fn validsa012() { /* This test is deliberately ignored. Although these are valid XML documents, XML without namespaces is not something we wish to handle. */ /* Test ID:valid-sa-012 Test URI:valid/sa/012.xml Spec Sections:2.3 [4] Description:Uses a legal XML 1.0 name consisting of a single colon character (disallowed by the latest XML Namespaces draft). */ let testxml = RNode::new_document(); let parseresult = xml::parse(testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/012.xml").unwrap(), None,None )); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse(canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/012.xml").unwrap(), None,None )); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); assert_eq!(parseresult.unwrap().get_canonical().unwrap(), canonicalparseresult.unwrap()); } */ #[test] fn validsa013() { /* Test ID:valid-sa-013 Test URI:valid/sa/013.xml Spec Sections:2.3 3.1 [13] [40] Description:Test demonstrates that the Attribute in a Start-tag can consist of numerals along with special characters. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/013.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/013.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa014() { /* Test ID:valid-sa-014 Test URI:valid/sa/014.xml Spec Sections:2.3 3.1 [13] [40] Description:Test demonstrates that all lower case letters are valid for the Attribute in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/014.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/014.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa015() { /* Test ID:valid-sa-015 Test URI:valid/sa/015.xml Spec Sections:2.3 3.1 [13] [40] Description:Test demonstrates that all upper case letters are valid for the Attribute in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/015.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/015.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa016() { /* Test ID:valid-sa-016 Test URI:valid/sa/016.xml Spec Sections:2.6 3.1 [16] [43] Description:Test demonstrates that Processing Instructions are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/016.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/016.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa017() { /* Test ID:valid-sa-017 Test URI:valid/sa/017.xml Spec Sections:2.6 3.1 [16] [43] Description:Test demonstrates that Processing Instructions are valid element content and there can be more than one. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/017.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/017.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validsa018() { /* Test ID:valid-sa-018 Test URI:valid/sa/018.xml Spec Sections:2.7 3.1 [18] [43] Description:Test demonstrates that CDATA sections are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/018.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/018.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validsa019() { /* Test ID:valid-sa-019 Test URI:valid/sa/019.xml Spec Sections:2.7 3.1 [18] [43] Description:Test demonstrates that CDATA sections are valid element content and thatampersands may occur in their literal form. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/019.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/019.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn validsa020() { /* Test ID:valid-sa-020 Test URI:valid/sa/020.xml Spec Sections:2.7 3.1 [18] [43] Description:Test demonstractes that CDATA sections are valid element content and thateveryting between the CDStart and CDEnd is recognized as character data not markup. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/020.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/020.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa021() { /* Test ID:valid-sa-021 Test URI:valid/sa/021.xml Spec Sections:2.5 3.1 [15] [43] Description:Test demonstrates that comments are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/021.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/021.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa022() { /* Test ID:valid-sa-022 Test URI:valid/sa/022.xml Spec Sections:2.5 3.1 [15] [43] Description:Test demonstrates that comments are valid element content and that all characters before the double-hypen right angle combination are considered part of thecomment. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/022.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/022.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa023() { /* Test ID:valid-sa-023 Test URI:valid/sa/023.xml Spec Sections:3.1 [43] Description:Test demonstrates that Entity References are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/023.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/023.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa024() { /* Test ID:valid-sa-024 Test URI:valid/sa/024.xml Spec Sections:3.1 4.1 [43] [66] Description:Test demonstrates that Entity References are valid element content and also demonstrates a valid Entity Declaration. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/024.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/024.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa025() { /* Test ID:valid-sa-025 Test URI:valid/sa/025.xml Spec Sections:3.2 [46] Description:Test demonstrates an Element Type Declaration and that the contentspec can be of mixed content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/025.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/025.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa026() { /* Test ID:valid-sa-026 Test URI:valid/sa/026.xml Spec Sections:3.2 [46] Description:Test demonstrates an Element Type Declaration and that EMPTY is a valid contentspec. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/026.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/026.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa027() { /* Test ID:valid-sa-027 Test URI:valid/sa/027.xml Spec Sections:3.2 [46] Description:Test demonstrates an Element Type Declaration and that ANY is a valid contenspec. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/027.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/027.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa028() { /* Test ID:valid-sa-028 Test URI:valid/sa/028.xml Spec Sections:2.8 [24] Description:Test demonstrates a valid prolog that uses double quotes as delimeters around the VersionNum. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/028.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/028.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa029() { /* Test ID:valid-sa-029 Test URI:valid/sa/029.xml Spec Sections:2.8 [24] Description:Test demonstrates a valid prolog that uses single quotes as delimters around the VersionNum. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/029.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/029.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa030() { /* Test ID:valid-sa-030 Test URI:valid/sa/030.xml Spec Sections:2.8 [25] Description:Test demonstrates a valid prolog that contains whitespace on both sides of the equal sign in the VersionInfo. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/030.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/030.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn validsa031() { /* Test ID:valid-sa-031 Test URI:valid/sa/031.xml Spec Sections:4.3.3 [80] Description:Test demonstrates a valid EncodingDecl within the prolog. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/031.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml.clone(), fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/031.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD);
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_namespaces_errata1e_notwf.rs
tests/conformance/xml/eduni_namespaces_errata1e_notwf.rs
/* Richard Tobin's XML Namespaces 1.0/1.1 2nd edition test suite 1 June 2006 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn rmtnse1013a() { /* Test ID:rmt-ns-e1.0-13a Test URI:NE13a.xml Spec Sections:NE13 Description:The xml namespace must not be declared as the default namespace. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/errata-1e/NE13a.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtnse1013b() { /* Test ID:rmt-ns-e1.0-13b Test URI:NE13b.xml Spec Sections:NE13 Description:The xmlns namespace must not be declared as the default namespace. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/errata-1e/NE13b.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmtnse1013c() { /* Test ID:rmt-ns-e1.0-13c Test URI:NE13c.xml Spec Sections:NE13 Description:Elements must not have the prefix xmlns. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/errata-1e/NE13c.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/sun_invalid.rs
tests/conformance/xml/sun_invalid.rs
/* Sun Microsystems test cases */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] #[ignore] fn invdtd01() { /* Test ID:inv-dtd01 Test URI:invalid/dtd01.xml Spec Sections:3.2.2 Description:Tests the No Duplicate Types VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/dtd01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invdtd02() { /* Test ID:inv-dtd02 Test URI:invalid/dtd02.xml Spec Sections:4.2.2 Description:Tests the "Notation Declared" VC by using an undeclared notation name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/dtd02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn invdtd03() { /* Test ID:inv-dtd03 Test URI:invalid/dtd03.xml Spec Sections:3 Description:Tests the "Element Valid" VC (clause 2) by omitting a required element. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/dtd03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn el01() { /* Test ID:el01 Test URI:invalid/el01.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 4) by including an undeclared child element. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/el01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn el02() { /* Test ID:el02 Test URI:invalid/el02.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 1) by including elements in an EMPTY content model. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/el02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn el03() { /* Test ID:el03 Test URI:invalid/el03.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 3) by including a child element not permitted by a mixed content model. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/el03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn el04() { /* Test ID:el04 Test URI:invalid/el04.xml Spec Sections:3.2 Description:Tests the Unique Element Type Declaration VC. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/el04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn el05() { /* Test ID:el05 Test URI:invalid/el05.xml Spec Sections:3.2.2 Description:Tests the No Duplicate Types VC. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/el05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn el06() { /* Test ID:el06 Test URI:invalid/el06.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 1), using one of the predefined internal entities inside an EMPTY content model. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/el06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id01() { /* Test ID:id01 Test URI:invalid/id01.xml Spec Sections:3.3.1 Description:Tests the ID (is a Name) VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id02() { /* Test ID:id02 Test URI:invalid/id02.xml Spec Sections:3.3.1 Description:Tests the ID (appears once) VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id03() { /* Test ID:id03 Test URI:invalid/id03.xml Spec Sections:3.3.1 Description:Tests the One ID per Element Type VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] fn id04() { /* Test ID:id04 Test URI:invalid/id04.xml Spec Sections:3.3.1 Description:Tests the ID Attribute Default VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id05() { /* Test ID:id05 Test URI:invalid/id05.xml Spec Sections:3.3.1 Description:Tests the ID Attribute Default VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id06() { /* Test ID:id06 Test URI:invalid/id06.xml Spec Sections:3.3.1 Description:Tests the IDREF (is a Name) VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id07() { /* Test ID:id07 Test URI:invalid/id07.xml Spec Sections:3.3.1 Description:Tests the IDREFS (is a Names) VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id08() { /* Test ID:id08 Test URI:invalid/id08.xml Spec Sections:3.3.1 Description:Tests the IDREF (matches an ID) VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn id09() { /* Test ID:id09 Test URI:invalid/id09.xml Spec Sections:3.3.1 Description:Tests the IDREF (IDREFS matches an ID) VC */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/id09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa01() { /* Test ID:inv-not-sa01 Test URI:invalid/not-sa01.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that optional whitespace causes a validity error. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/sun/invalid/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa01.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa02() { /* Test ID:inv-not-sa02 Test URI:invalid/not-sa02.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that attributes needing normalization cause a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa04() { /* Test ID:inv-not-sa04 Test URI:invalid/not-sa04.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that attributes needing defaulting cause a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa05() { /* Test ID:inv-not-sa05 Test URI:invalid/not-sa05.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that a token attribute that needs normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa06() { /* Test ID:inv-not-sa06 Test URI:invalid/not-sa06.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that a NOTATION attribute that needs normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa07() { /* Test ID:inv-not-sa07 Test URI:invalid/not-sa07.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that an NMTOKEN attribute needing normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa08() { /* Test ID:inv-not-sa08 Test URI:invalid/not-sa08.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that an NMTOKENS attribute needing normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa09() { /* Test ID:inv-not-sa09 Test URI:invalid/not-sa09.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that an ID attribute needing normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa10() { /* Test ID:inv-not-sa10 Test URI:invalid/not-sa10.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that an IDREF attribute needing normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa11() { /* Test ID:inv-not-sa11 Test URI:invalid/not-sa11.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that an IDREFS attribute needing normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa12() { /* Test ID:inv-not-sa12 Test URI:invalid/not-sa12.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that an ENTITY attribute needing normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa13() { /* Test ID:inv-not-sa13 Test URI:invalid/not-sa13.xml Spec Sections:2.9 Description:Tests the Standalone Document Declaration VC, ensuring that an ENTITIES attribute needing normalization causes a validity error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa13.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invnotsa14() { /* Test ID:inv-not-sa14 Test URI:invalid/not-sa14.xml Spec Sections:3 Description:CDATA sections containing only whitespace do not match the nonterminal S, and cannot appear in these positions. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/not-sa14.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional01() { /* Test ID:optional01 Test URI:invalid/optional01.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one is required. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional02() { /* Test ID:optional02 Test URI:invalid/optional02.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing two children where one is required. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional03() { /* Test ID:optional03 Test URI:invalid/optional03.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where two are required. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional04() { /* Test ID:optional04 Test URI:invalid/optional04.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing three children where two are required. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional05() { /* Test ID:optional05 Test URI:invalid/optional05.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or two are required (one construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional06() { /* Test ID:optional06 Test URI:invalid/optional06.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or two are required (a second construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional07() { /* Test ID:optional07 Test URI:invalid/optional07.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or two are required (a third construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional08() { /* Test ID:optional08 Test URI:invalid/optional08.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or two are required (a fourth construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional09() { /* Test ID:optional09 Test URI:invalid/optional09.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or two are required (a fifth construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional10() { /* Test ID:optional10 Test URI:invalid/optional10.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing three children where one or two are required (a basic construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional11() { /* Test ID:optional11 Test URI:invalid/optional11.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing three children where one or two are required (a second construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional12() { /* Test ID:optional12 Test URI:invalid/optional12.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing three children where one or two are required (a third construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional13() { /* Test ID:optional13 Test URI:invalid/optional13.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing three children where one or two are required (a fourth construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional13.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional14() { /* Test ID:optional14 Test URI:invalid/optional14.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing three children where one or two are required (a fifth construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional14.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional20() { /* Test ID:optional20 Test URI:invalid/optional20.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or more are required (a sixth construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional20.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional21() { /* Test ID:optional21 Test URI:invalid/optional21.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or more are required (a seventh construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional21.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional22() { /* Test ID:optional22 Test URI:invalid/optional22.xml Spec Sections:3 Description:Tests the Element Valid VC (clause 2) for one instance of "children" content model, providing no children where one or more are required (an eigth construction of that model). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/invalid/optional22.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn optional23() { /* Test ID:optional23 Test URI:invalid/optional23.xml Spec Sections:3
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/xmltest_valid_sa_canonicalonly.rs
tests/conformance/xml/xmltest_valid_sa_canonicalonly.rs
/* James Clark XMLTEST cases - Standalone This contains cases that are valid XML documents. */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn validsa001() { /* Test ID:valid-sa-001 Test URI:valid/sa/001.xml Spec Sections:3.2.2 [51] Description:Test demonstrates an Element Type Declaration with Mixed Content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/001.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa002() { /* Test ID:valid-sa-002 Test URI:valid/sa/002.xml Spec Sections:3.1 [40] Description:Test demonstrates that whitespace is permitted after the tag name in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/002.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa003() { /* Test ID:valid-sa-003 Test URI:valid/sa/003.xml Spec Sections:3.1 [42] Description:Test demonstrates that whitespace is permitted after the tag name in an End-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/003.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa004() { /* Test ID:valid-sa-004 Test URI:valid/sa/004.xml Spec Sections:3.1 [41] Description:Test demonstrates a valid attribute specification within a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/004.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa005() { /* Test ID:valid-sa-005 Test URI:valid/sa/005.xml Spec Sections:3.1 [40] Description:Test demonstrates a valid attribute specification within a Start-tag thatcontains whitespace on both sides of the equal sign. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/005.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa006() { /* Test ID:valid-sa-006 Test URI:valid/sa/006.xml Spec Sections:3.1 [41] Description:Test demonstrates that the AttValue within a Start-tag can use a single quote as a delimter. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/006.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa007() { /* Test ID:valid-sa-007 Test URI:valid/sa/007.xml Spec Sections:3.1 4.6 [43] Description:Test demonstrates numeric character references can be used for element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/007.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa008() { /* Test ID:valid-sa-008 Test URI:valid/sa/008.xml Spec Sections:2.4 3.1 [43] Description:Test demonstrates character references can be used for element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/008.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa009() { /* Test ID:valid-sa-009 Test URI:valid/sa/009.xml Spec Sections:2.3 3.1 [43] Description:Test demonstrates that PubidChar can be used for element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/009.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa010() { /* Test ID:valid-sa-010 Test URI:valid/sa/010.xml Spec Sections:3.1 [40] Description:Test demonstrates that whitespace is valid after the Attribute in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/010.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa011() { /* Test ID:valid-sa-011 Test URI:valid/sa/011.xml Spec Sections:3.1 [40] Description:Test demonstrates mutliple Attibutes within the Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/011.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } /* #[test] #[ignore] fn validsa012() { /* This test is deliberately ignored. Although these are valid XML documents, XML without namespaces is not something we wish to handle. */ /* Test ID:valid-sa-012 Test URI:valid/sa/012.xml Spec Sections:2.3 [4] Description:Uses a legal XML 1.0 name consisting of a single colon character (disallowed by the latest XML Namespaces draft). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/012.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } */ #[test] fn validsa013() { /* Test ID:valid-sa-013 Test URI:valid/sa/013.xml Spec Sections:2.3 3.1 [13] [40] Description:Test demonstrates that the Attribute in a Start-tag can consist of numerals along with special characters. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/013.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa014() { /* Test ID:valid-sa-014 Test URI:valid/sa/014.xml Spec Sections:2.3 3.1 [13] [40] Description:Test demonstrates that all lower case letters are valid for the Attribute in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/014.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa015() { /* Test ID:valid-sa-015 Test URI:valid/sa/015.xml Spec Sections:2.3 3.1 [13] [40] Description:Test demonstrates that all upper case letters are valid for the Attribute in a Start-tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/015.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa016() { /* Test ID:valid-sa-016 Test URI:valid/sa/016.xml Spec Sections:2.6 3.1 [16] [43] Description:Test demonstrates that Processing Instructions are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/016.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa017() { /* Test ID:valid-sa-017 Test URI:valid/sa/017.xml Spec Sections:2.6 3.1 [16] [43] Description:Test demonstrates that Processing Instructions are valid element content and there can be more than one. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/017.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa018() { /* Test ID:valid-sa-018 Test URI:valid/sa/018.xml Spec Sections:2.7 3.1 [18] [43] Description:Test demonstrates that CDATA sections are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/018.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa019() { /* Test ID:valid-sa-019 Test URI:valid/sa/019.xml Spec Sections:2.7 3.1 [18] [43] Description:Test demonstrates that CDATA sections are valid element content and thatampersands may occur in their literal form. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/019.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa020() { /* Test ID:valid-sa-020 Test URI:valid/sa/020.xml Spec Sections:2.7 3.1 [18] [43] Description:Test demonstractes that CDATA sections are valid element content and thateveryting between the CDStart and CDEnd is recognized as character data not markup. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/020.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa021() { /* Test ID:valid-sa-021 Test URI:valid/sa/021.xml Spec Sections:2.5 3.1 [15] [43] Description:Test demonstrates that comments are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/021.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa022() { /* Test ID:valid-sa-022 Test URI:valid/sa/022.xml Spec Sections:2.5 3.1 [15] [43] Description:Test demonstrates that comments are valid element content and that all characters before the double-hypen right angle combination are considered part of thecomment. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/022.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa023() { /* Test ID:valid-sa-023 Test URI:valid/sa/023.xml Spec Sections:3.1 [43] Description:Test demonstrates that Entity References are valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/023.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa024() { /* Test ID:valid-sa-024 Test URI:valid/sa/024.xml Spec Sections:3.1 4.1 [43] [66] Description:Test demonstrates that Entity References are valid element content and also demonstrates a valid Entity Declaration. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/024.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa025() { /* Test ID:valid-sa-025 Test URI:valid/sa/025.xml Spec Sections:3.2 [46] Description:Test demonstrates an Element Type Declaration and that the contentspec can be of mixed content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/025.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa026() { /* Test ID:valid-sa-026 Test URI:valid/sa/026.xml Spec Sections:3.2 [46] Description:Test demonstrates an Element Type Declaration and that EMPTY is a valid contentspec. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/026.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa027() { /* Test ID:valid-sa-027 Test URI:valid/sa/027.xml Spec Sections:3.2 [46] Description:Test demonstrates an Element Type Declaration and that ANY is a valid contenspec. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/027.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa028() { /* Test ID:valid-sa-028 Test URI:valid/sa/028.xml Spec Sections:2.8 [24] Description:Test demonstrates a valid prolog that uses double quotes as delimeters around the VersionNum. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/028.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa029() { /* Test ID:valid-sa-029 Test URI:valid/sa/029.xml Spec Sections:2.8 [24] Description:Test demonstrates a valid prolog that uses single quotes as delimters around the VersionNum. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/029.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa030() { /* Test ID:valid-sa-030 Test URI:valid/sa/030.xml Spec Sections:2.8 [25] Description:Test demonstrates a valid prolog that contains whitespace on both sides of the equal sign in the VersionInfo. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/030.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa031() { /* Test ID:valid-sa-031 Test URI:valid/sa/031.xml Spec Sections:4.3.3 [80] Description:Test demonstrates a valid EncodingDecl within the prolog. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/031.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa032() { /* Test ID:valid-sa-032 Test URI:valid/sa/032.xml Spec Sections:2.9 [32] Description:Test demonstrates a valid SDDecl within the prolog. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/032.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa033() { /* Test ID:valid-sa-033 Test URI:valid/sa/033.xml Spec Sections:2.8 [23] Description:Test demonstrates that both a EncodingDecl and SDDecl are valid within the prolog. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/033.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa034() { /* Test ID:valid-sa-034 Test URI:valid/sa/034.xml Spec Sections:3.1 [44] Description:Test demonstrates the correct syntax for an Empty element tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/034.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa035() { /* Test ID:valid-sa-035 Test URI:valid/sa/035.xml Spec Sections:3.1 [44] Description:Test demonstrates that whitespace is permissible after the name in an Empty element tag. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/035.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa036() { /* Test ID:valid-sa-036 Test URI:valid/sa/036.xml Spec Sections:2.6 [16] Description:Test demonstrates a valid processing instruction. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/036.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa017a() { /* Test ID:valid-sa-017a Test URI:valid/sa/017a.xml Spec Sections:2.6 3.1 [16] [43] Description:Test demonstrates that two apparently wrong Processing Instructions make aright one, with very odd content "some data ? > <?". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/017a.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa037() { /* Test ID:valid-sa-037 Test URI:valid/sa/037.xml Spec Sections:2.6 [15] Description:Test demonstrates a valid comment and that it may appear anywhere in the document including at the end. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/037.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa038() { /* Test ID:valid-sa-038 Test URI:valid/sa/038.xml Spec Sections:2.6 [15] Description:Test demonstrates a valid comment and that it may appear anywhere in the document including the beginning. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/038.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa039() { /* Test ID:valid-sa-039 Test URI:valid/sa/039.xml Spec Sections:2.6 [16] Description:Test demonstrates a valid processing instruction and that it may appear at the beginning of the document. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/039.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa040() { /* Test ID:valid-sa-040 Test URI:valid/sa/040.xml Spec Sections:3.3 3.3.1 [52] [54] Description:Test demonstrates an Attribute List declaration that uses a StringType as the AttType. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/040.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa041() { /* Test ID:valid-sa-041 Test URI:valid/sa/041.xml Spec Sections:3.3.1 4.1 [54] [66] Description:Test demonstrates an Attribute List declaration that uses a StringType as the AttType and also expands the CDATA attribute with a character reference. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/041.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa042() { /* Test ID:valid-sa-042 Test URI:valid/sa/042.xml Spec Sections:3.3.1 4.1 [54] [66] Description:Test demonstrates an Attribute List declaration that uses a StringType as the AttType and also expands the CDATA attribute with a character reference. The test also shows that the leading zeros in the character reference are ignored. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/042.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa043() { /* Test ID:valid-sa-043 Test URI:valid/sa/043.xml Spec Sections:3.3 Description:An element's attributes may be declared before its content model; and attribute values may contain newlines. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/043.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa044() { /* Test ID:valid-sa-044 Test URI:valid/sa/044.xml Spec Sections:3.1 [44] Description:Test demonstrates that the empty-element tag must be use for an elements that are declared EMPTY. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/044.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa045() { /* Test ID:valid-sa-045 Test URI:valid/sa/045.xml Spec Sections:3.3 [52] Description:Tests whether more than one definition can be provided for the same attribute of a given element type with the first declaration being binding. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/045.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa046() { /* Test ID:valid-sa-046 Test URI:valid/sa/046.xml Spec Sections:3.3 [52] Description:Test demonstrates that when more than one AttlistDecl is provided for a given element type, the contents of all those provided are merged. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/046.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa047() { /* Test ID:valid-sa-047 Test URI:valid/sa/047.xml Spec Sections:3.1 [43] Description:Test demonstrates that extra whitespace is normalized into single space character. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/047.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa048() { /* Test ID:valid-sa-048 Test URI:valid/sa/048.xml Spec Sections:2.4 3.1 [14] [43] Description:Test demonstrates that character data is valid element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/048.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa049() { /* Test ID:valid-sa-049 Test URI:valid/sa/049.xml Spec Sections:2.2 [2] Description:Test demonstrates that characters outside of normal ascii range can be used as element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/049.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa050() { /* Test ID:valid-sa-050 Test URI:valid/sa/050.xml Spec Sections:2.2 [2] Description:Test demonstrates that characters outside of normal ascii range can be used as element content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/050.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa051() { /* Test ID:valid-sa-051 Test URI:valid/sa/051.xml Spec Sections:2.2 [2] Description:The document is encoded in UTF-16 and uses some name characters well outside of the normal ASCII range. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/051.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa052() { /* Test ID:valid-sa-052 Test URI:valid/sa/052.xml Spec Sections:2.2 [2] Description:The document is encoded in UTF-8 and the text inside the root element uses two non-ASCII characters, encoded in UTF-8 and each of which expands to a Unicode surrogate pair. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/052.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa053() { /* Test ID:valid-sa-053 Test URI:valid/sa/053.xml Spec Sections:4.4.2 Description:Tests inclusion of a well-formed internal entity, which holds an element required by the content model. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/053.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa054() { /* Test ID:valid-sa-054 Test URI:valid/sa/054.xml Spec Sections:3.1 [40] [42] Description:Test demonstrates that extra whitespace within Start-tags and End-tags are nomalized into single spaces. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/054.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa055() { /* Test ID:valid-sa-055 Test URI:valid/sa/055.xml Spec Sections:2.6 2.10 [16] Description:Test demonstrates that extra whitespace within a processing instruction willnormalized into s single space character. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/055.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa056() { /* Test ID:valid-sa-056 Test URI:valid/sa/056.xml Spec Sections:3.3.1 4.1 [54] [66] Description:Test demonstrates an Attribute List declaration that uses a StringType as the AttType and also expands the CDATA attribute with a character reference. The test also shows that the leading zeros in the character reference are ignored. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/056.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa057() { /* Test ID:valid-sa-057 Test URI:valid/sa/057.xml Spec Sections:3.2.1 [47] Description:Test demonstrates an element content model whose element can occur zero or more times. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/057.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa058() { /* Test ID:valid-sa-058 Test URI:valid/sa/058.xml Spec Sections:3.3.3 Description:Test demonstrates that extra whitespace be normalized into a single space character in an attribute of type NMTOKENS. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/valid/sa/out/058.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); } #[test] fn validsa059() { /* Test ID:valid-sa-059 Test URI:valid/sa/059.xml Spec Sections:3.2 3.3 [46] [53]
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
true
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_namespaces_10_error.rs
tests/conformance/xml/eduni_namespaces_10_error.rs
/* Richard Tobin's XML Namespaces 1.0 test suite 14 Feb 2003 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn rmtns10004() { /* Test ID:rmt-ns10-004 Test URI:004.xml Spec Sections:2 Description:Namespace name test: a relative URI (deprecated) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/004.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmtns10005() { /* Test ID:rmt-ns10-005 Test URI:005.xml Spec Sections:2 Description:Namespace name test: a same-document relative URI (deprecated) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/005.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmtns10006() { /* Test ID:rmt-ns10-006 Test URI:006.xml Spec Sections:2 Description:Namespace name test: an http IRI that is not a URI */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/006.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/sun_valid.rs
tests/conformance/xml/sun_valid.rs
use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] #[ignore] fn pe01() { /* Test ID:pe01 Test URI:valid/pe01.xml Spec Sections:2.8 Description: Parameter entities references are NOT RECOGNIZED in default attribute values. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn dtd00() { /* Test ID:dtd00 Test URI:valid/dtd00.xml Spec Sections:3.2.2 [51] Description:Tests parsing of alternative forms of text-only mixedcontent declaration. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/dtd00.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/dtd00.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn dtd01() { /* Test ID:dtd01 Test URI:valid/dtd01.xml Spec Sections:2.5 [15] Description:Comments don't get parameter entity expansion */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/dtd01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/dtd01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn element() { /* Test ID:element Test URI:valid/element.xml Spec Sections:3 Description:Tests clauses 1, 3, and 4 of the Element Validvalidity constraint. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/element.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/element.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); assert_eq!( parseresult.unwrap().get_canonical().unwrap(), canonicalparseresult.unwrap().get_canonical().unwrap() ); } #[test] #[ignore] fn ext01() { /* Test ID:ext01 Test URI:valid/ext01.xml Spec Sections:4.3.1 4.3.2 [77] [78] Description:Tests use of external parsed entities with and without content. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/ext01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/ext01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn ext02() { /* Test ID:ext02 Test URI:valid/ext02.xml Spec Sections:4.3.2 [78] Description:Tests use of external parsed entities with differentencodings than the base document. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/ext02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/ext02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn notsa01() { /* Test ID:not-sa01 Test URI:valid/not-sa01.xml Spec Sections:2.9 Description:A non-standalone document is valid if declared as such. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/sun/valid/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa01.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn notsa02() { /* Test ID:not-sa02 Test URI:valid/not-sa02.xml Spec Sections:2.9 Description:A non-standalone document is valid if declared as such. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn notsa03() { /* Test ID:not-sa03 Test URI:valid/not-sa03.xml Spec Sections:2.9 Description:A non-standalone document is valid if declared as such. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn notsa04() { /* Test ID:not-sa04 Test URI:valid/not-sa04.xml Spec Sections:2.9 Description:A non-standalone document is valid if declared as such. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa04.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn notation01() { /* Test ID:notation01 Test URI:valid/notation01.xml Spec Sections:4.7 [82] Description:NOTATION declarations don't need SYSTEM IDs; andexternally declared notations may be used to declareunparsed entities in the internal DTD subset.The notation must be reported to the application. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/notation01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/notation01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn optional() { /* Test ID:optional Test URI:valid/optional.xml Spec Sections:3 3.2.1 [47] Description:Tests declarations of "children" content models, andthe validity constraints associated with them. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/optional.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/optional.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn required00() { /* Test ID:required00 Test URI:valid/required00.xml Spec Sections:3.3.2 [60] Description:Tests the #REQUIRED attribute declaration syntax, andthe associated validity constraint. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/required00.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/required00.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn sa01() { /* Test ID:sa01 Test URI:valid/sa01.xml Spec Sections:2.9 [32] Description:A document may be marked 'standalone' if any optional whitespace is defined within the internal DTD subset. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn sa02() { /* Test ID:sa02 Test URI:valid/sa02.xml Spec Sections:2.9 [32] Description:A document may be marked 'standalone' if anyattributes that need normalization aredefined within the internal DTD subset. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn sa03() { /* Test ID:sa03 Test URI:valid/sa03.xml Spec Sections:2.9 [32] Description:A document may be marked 'standalone' if anythe defined entities need expanding are internal,and no attributes need defaulting or normalization.On output, requires notations to be correctly reported. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn sa04() { /* Test ID:sa04 Test URI:valid/sa04.xml Spec Sections:2.9 [32] Description:Like sa03 but relies on attributedefaulting defined in the internal subset.On output, requires notations to be correctly reported. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa04.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn sa05() { /* Test ID:sa05 Test URI:valid/sa05.xml Spec Sections:2.9 [32] Description:Like sa01 but this document is standalone since it has no optional whitespace.On output, requires notations to be correctly reported. */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/sun/valid/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa05.xml") .unwrap() .as_str(), Some(pc), ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn vsgml01() { /* Test ID:v-sgml01 Test URI:valid/sgml01.xml Spec Sections:3.3.1 [59] Description:XML permits token reuse, while SGML does not. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sgml01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sgml01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn vlang01() { /* Test ID:v-lang01 Test URI:valid/v-lang01.xml Spec Sections:2.12 [35] Description:Tests a lowercase ISO language code. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang01.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn vlang02() { /* Test ID:v-lang02 Test URI:valid/v-lang02.xml Spec Sections:2.12 [35] Description:Tests a ISO language code with a subcode. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn vlang03() { /* Test ID:v-lang03 Test URI:valid/v-lang03.xml Spec Sections:2.12 [36] Description:Tests a IANA language code with a subcode. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn vlang04() { /* Test ID:v-lang04 Test URI:valid/v-lang04.xml Spec Sections:2.12 [37] Description:Tests a user language code with a subcode. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang04.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn vlang05() { /* Test ID:v-lang05 Test URI:valid/v-lang05.xml Spec Sections:2.12 [35] Description:Tests an uppercase ISO language code. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang05.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn vlang06() { /* Test ID:v-lang06 Test URI:valid/v-lang06.xml Spec Sections:2.12 [37] Description:Tests a user language code. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang06.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn vpe00() { /* Test ID:v-pe00 Test URI:valid/pe00.xml Spec Sections:4.5 Description:Tests construction of internal entity replacement text, usingan example in the XML specification. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe00.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/pe00.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn vpe03() { /* Test ID:v-pe03 Test URI:valid/pe03.xml Spec Sections:4.5 Description:Tests construction of internal entity replacement text, usingan example in the XML specification. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe03.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/pe03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); assert_eq!( parseresult.unwrap().get_canonical().unwrap(), canonicalparseresult.unwrap().get_canonical().unwrap() ); } #[test] #[ignore] fn vpe02() { /* Test ID:v-pe02 Test URI:valid/pe02.xml Spec Sections:4.5 Description:Tests construction of internal entity replacement text, usinga complex example in the XML specification. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe02.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/pe02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/xmltest_notwf_ext_sa.rs
tests/conformance/xml/xmltest_notwf_ext_sa.rs
/* James Clark XMLTEST cases This contains cases that are not well-formed XML documents */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] #[ignore] fn notwfextsa001() { /* Test ID:not-wf-ext-sa-001 Test URI:not-wf/ext-sa/001.xml Spec Sections:4.1 Description:Tests the No Recursion WFC by having an external general entity be self-recursive. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/ext-sa/001.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn notwfextsa002() { /* Test ID:not-wf-ext-sa-002 Test URI:not-wf/ext-sa/002.xml Spec Sections:4.3.1 4.3.2 [77, 78] Description:External entities have "text declarations", which do not permit the "standalone=..." attribute that's allowed in XML declarations. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/ext-sa/002.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn notwfextsa003() { /* Test ID:not-wf-ext-sa-003 Test URI:not-wf/ext-sa/003.xml Spec Sections:2.6 [17] Description:Only one text declaration is permitted; a second one looks like an illegal processing instruction (target names of "xml" in any case are not allowed). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/xmltest/not-wf/ext-sa/003.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_xml11_valid.rs
tests/conformance/xml/eduni_xml11_valid.rs
/* Richard Tobin's XML 1.1 test suite 13 Feb 2003 */ use crate::conformance::non_utf8_file_reader; use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] #[ignore] fn rmt006() { /* Test ID:rmt-006 Test URI:006.xml Spec Sections:2.8 4.3.4 Description:Second-level external general entity has later version number than first-level, but not later than document, so not an error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/006.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/006.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt007() { /* Test ID:rmt-007 Test URI:007.xml Spec Sections:2.8 4.3.4 Description:A vanilla XML 1.1 document */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/007.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/007.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt010() { /* Test ID:rmt-010 Test URI:010.xml Spec Sections:2.2 Description:Contains a C1 control, legal in XML 1.0, illegal in XML 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/eduni/xml-1.1/010.xml").as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/010.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt012() { /* Test ID:rmt-012 Test URI:012.xml Spec Sections:2.2 Description:Contains a DEL, legal in XML 1.0, illegal in XML 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/012.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/012.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt022() { /* Test ID:rmt-022 Test URI:022.xml Spec Sections:2.11 Description:Has a NEL character; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/eduni/xml-1.1/022.xml").as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/022.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt023() { /* Test ID:rmt-023 Test URI:023.xml Spec Sections:2.11 Description:Has a NEL character; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/eduni/xml-1.1/023.xml").as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/023.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt024() { /* Test ID:rmt-024 Test URI:024.xml Spec Sections:2.11 Description:Has an LSEP character; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/024.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/024.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt025() { /* Test ID:rmt-025 Test URI:025.xml Spec Sections:2.11 Description:Has an LSEP character; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/025.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/025.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt026() { /* Test ID:rmt-026 Test URI:026.xml Spec Sections:2.11 Description:Has CR-NEL; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/026.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/026.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt027() { /* Test ID:rmt-027 Test URI:027.xml Spec Sections:2.11 Description:Has CR-NEL; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/027.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/027.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt028() { /* Test ID:rmt-028 Test URI:028.xml Spec Sections:2.11 Description:Has CR-LSEP; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1. Note that CR and LSEP are not combined into a single LF */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/028.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/028.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt029() { /* Test ID:rmt-029 Test URI:029.xml Spec Sections:2.11 Description:Has CR-LSEP; legal in both XML 1.0 and 1.1, but different canonical output because of normalization in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/029.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/029.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt031() { /* Test ID:rmt-031 Test URI:031.xml Spec Sections:2.11 Description:Has a NEL character in an NMTOKENS attribute; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/eduni/xml-1.1/031.xml").as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/031.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt033() { /* Test ID:rmt-033 Test URI:033.xml Spec Sections:2.11 Description:Has an LSEP character in an NMTOKENS attribute; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/033.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/033.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt034() { /* Test ID:rmt-034 Test URI:034.xml Spec Sections:2.3 Description:Has an NMTOKENS attribute containing a CR character that comes from a character reference in an internal entity. Because CR is in the S production, this is valid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/034.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/034.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt035() { /* Test ID:rmt-035 Test URI:035.xml Spec Sections:2.3 Description:Has an NMTOKENS attribute containing a CR character that comes from a character reference in an internal entity. Because CR is in the S production, this is valid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/035.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/035.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt040() { /* Test ID:rmt-040 Test URI:040.xml Spec Sections:2.2 Description:Contains a C1 control character (partial line up), legal in XML 1.0 but not 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/eduni/xml-1.1/040.xml").as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/040.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt043() { /* Test ID:rmt-043 Test URI:043.xml Spec Sections:4.1 Description:Contains a character reference to a C0 control character (form-feed), legal in XML 1.1 but not 1.0 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/043.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/043.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt044() { /* Test ID:rmt-044 Test URI:044.xml Spec Sections:4.1 Description:Contains a character reference to a C1 control character (partial line up), legal in both XML 1.0 and 1.1 (but for different reasons) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/044.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/044.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] fn rmt045() { /* Test ID:rmt-045 Test URI:045.xml Spec Sections:4.1 Description:Contains a character reference to a C1 control character (partial line up), legal in both XML 1.0 and 1.1 (but for different reasons) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/045.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/045.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt047() { /* Test ID:rmt-047 Test URI:047.xml Spec Sections:2.11 Description:Has a NEL character in element content whitespace; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, non_utf8_file_reader("tests/conformance/xml/xmlconf/eduni/xml-1.1/047.xml").as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/047.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt049() { /* Test ID:rmt-049 Test URI:049.xml Spec Sections:2.11 Description:has an LSEP character in element content whitespace; well-formed in both XML 1.0 and 1.1, but valid only in 1.1 */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/049.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/049.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt050() { /* Test ID:rmt-050 Test URI:050.xml Spec Sections:2.3 Description:Has element content whitespace containing a CR character that comes from a character reference in an internal entity. Because CR is in the S production, this is valid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/050.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/050.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt051() { /* Test ID:rmt-051 Test URI:051.xml Spec Sections:2.3 Description:Has element content whitespace containing a CR character that comes from a character reference in an internal entity. Because CR is in the S production, this is valid in both XML 1.0 and 1.1. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/051.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/051.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); } #[test] #[ignore] fn rmt054() { /* Test ID:rmt-054 Test URI:054.xml Spec Sections:4.3.2 Description:Contains a character reference to a C0 control character (form-feed) in an entity value. This will be legal (in XML 1.1) when the entity declaration is parsed, but what about when it is used? According to the grammar in the CR spec, it should be illegal (because the replacement text must match "content"), but this is probably not intended. This will be fixed in the PR version. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/054.xml") .unwrap() .as_str(), None, ); let canonicalxml = RNode::new_document(); let canonicalparseresult = xml::parse( canonicalxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/xml-1.1/out/054.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); assert!(canonicalparseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/mod.rs
tests/conformance/xml/mod.rs
mod eduni_errata2e_error; mod eduni_errata2e_invalid; mod eduni_errata2e_notwf; mod eduni_errata2e_valid; mod eduni_errata3e_invalid; mod eduni_errata3e_notwf; mod eduni_errata3e_valid; mod eduni_errata4e_error; mod eduni_errata4e_invalid; mod eduni_errata4e_notwf; mod eduni_errata4e_valid; mod eduni_misc_invalid; mod eduni_misc_notwf; mod eduni_namespaces_10_error; mod eduni_namespaces_10_invalid; mod eduni_namespaces_10_notwf; mod eduni_namespaces_10_valid; mod eduni_namespaces_11_notwf; mod eduni_namespaces_11_valid; mod eduni_namespaces_errata1e_notwf; mod eduni_xml11_error; mod eduni_xml11_invalid; mod eduni_xml11_notwf; mod eduni_xml11_valid; mod ibm11_invalid; mod ibm11_notwf; mod ibm11_valid; mod ibm_error; mod ibm_invalid; mod ibm_notwf; mod ibm_valid; mod oasis_error; mod oasis_invalid; mod oasis_notwf; mod oasis_valid; mod sun_error; mod sun_invalid; mod sun_notwf; mod sun_valid; mod xmltest_invalid; mod xmltest_notwf_ext_sa; mod xmltest_notwf_not_sa; mod xmltest_notwf_sa; mod xmltest_valid_ext_sa; mod xmltest_valid_not_sa; mod xmltest_valid_sa; mod xmltest_valid_sa_canonicalonly;
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_namespaces_10_valid.rs
tests/conformance/xml/eduni_namespaces_10_valid.rs
/* Richard Tobin's XML Namespaces 1.0 test suite 14 Feb 2003 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] fn rmtns10001() { /* Test ID:rmt-ns10-001 Test URI:001.xml Spec Sections:2 Description:Namespace name test: a perfectly good http URI */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/001.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmtns10002() { /* Test ID:rmt-ns10-002 Test URI:002.xml Spec Sections:2 Description:Namespace name test: a syntactically plausible URI with a fictitious scheme */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/002.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn rmtns10003() { /* Test ID:rmt-ns10-003 Test URI:003.xml Spec Sections:2 Description:Namespace name test: a perfectly good http URI with a fragment */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/003.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] #[ignore] fn rmtns10007() { /* Test ID:rmt-ns10-007 Test URI:007.xml Spec Sections:1 Description:Namespace inequality test: different capitalization */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/007.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] #[ignore] fn rmtns10008() { /* Test ID:rmt-ns10-008 Test URI:008.xml Spec Sections:1 Description:Namespace inequality test: different escaping */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/008.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn htns10047() { /* Test ID:ht-ns10-047 Test URI:047.xml Spec Sections:NE03 Description:Reserved name: _not_ an error */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/047.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); } #[test] fn htns10048() { /* Test ID:ht-ns10-048 Test URI:048.xml Spec Sections:NE03 Description:Reserved name: _not_ an error */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.0/048.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_ok()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata2e_notwf.rs
tests/conformance/xml/eduni_errata2e_notwf.rs
/* Richard Tobin's XML 1.0 2nd edition errata test suite. */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] #[ignore] fn rmte2e27() { /* Test ID:rmt-e2e-27 Test URI:E27.xml Spec Sections:E27 Description:Contains an irregular UTF-8 sequence (i.e. a surrogate pair) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E27.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn rmte2e38() { /* Test ID:rmt-e2e-38 Test URI:E38.xml Spec Sections:E38 Description:XML 1.0 document refers to 1.1 entity */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E38.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] #[ignore] fn rmte2e61() { /* Test ID:rmt-e2e-61 Test URI:E61.xml Spec Sections:E61 Description:(From John Cowan) An encoding declaration in ASCII specifying an encoding that is not compatible with ASCII (so the document is not in its declared encoding). It should generate a fatal error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E61.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_errata4e_invalid.rs
tests/conformance/xml/eduni_errata4e_invalid.rs
/* University of Edinburgh XML 1.0 4th edition errata test suite. */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; use xrust::validators::Schema; #[test] #[ignore] fn invalidbo1() { /* Test ID:invalid-bo-1 Test URI:inclbom_be.xml Spec Sections:4.3.3 Description:Byte order mark in general entity should go away (big-endian) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbom_be.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invalidbo2() { /* Test ID:invalid-bo-2 Test URI:inclbom_le.xml Spec Sections:4.3.3 Description:Byte order mark in general entity should go away (little-endian) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbom_le.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invalidbo3() { /* Test ID:invalid-bo-3 Test URI:incl8bom.xml Spec Sections:4.3.3 Description:Byte order mark in general entity should go away (utf-8) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/incl8bom.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invalidbo4() { /* Test ID:invalid-bo-4 Test URI:inclbombom_be.xml Spec Sections:4.3.3 Description:Two byte order marks in general entity produce only one (big-endian) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbombom_be.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invalidbo5() { /* Test ID:invalid-bo-5 Test URI:inclbombom_le.xml Spec Sections:4.3.3 Description:Two byte order marks in general entity produce only one (little-endian) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbombom_le.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn invalidbo6() { /* Test ID:invalid-bo-6 Test URI:incl8bombom.xml Spec Sections:4.3.3 Description:Two byte order marks in general entity produce only one (utf-8) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/incl8bombom.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } /* #[test] #[ignore] fn invalidsa140() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:invalid-sa-140 Test URI:140.xml Spec Sections:2.3 [4] Description:Character '&#x309a;' is a CombiningChar, not a Letter, but as of 5th edition, may begin a name (c.f. xmltest/not-wf/sa/140.xml). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/140.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn invalidsa141() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:invalid-sa-141 Test URI:141.xml Spec Sections:2.3 [5] Description:As of 5th edition, character #x0E5C is legal in XML names (c.f. xmltest/not-wf/sa/141.xml). */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/141.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn xrmt5014() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:x-rmt5-014 Test URI:014.xml Spec Sections:2.3 Description:Has a "long s" in a name, legal in XML 1.1, legal in XML 1.0 5th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/014.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn xrmt5016() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:x-rmt5-016 Test URI:016.xml Spec Sections:2.3 Description:Has a Byzantine Musical Symbol Kratimata in a name, legal in XML 1.1, legal in XML 1.0 5th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/016.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } */ /* #[test] #[ignore] fn xrmt5019() { /* This test is deliberately ignored. This document is now well formed, as per the 5th edition. */ /* Test ID:x-rmt5-019 Test URI:019.xml Spec Sections:2.3 Description:Has the last legal namechar in XML 1.1, legal in XML 1.0 5th edition */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/019.xml") .unwrap() .as_str(), None, ); assert!(testxml.is_err()); } */ #[test] #[ignore] fn ibminvalid_p89ibm89n06xml() { /* Test ID:ibm-invalid-P89-ibm89n06.xml Test URI:ibm89n06.xml Spec Sections:B. Description:Tests Extender with an only legal per 5th edition character. The character #x0EC7 occurs as the second character in the PITarget in the PI in the prolog, and in an element name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/ibm89n06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn ibminvalid_p89ibm89n07xml() { /* Test ID:ibm-invalid-P89-ibm89n07.xml Test URI:ibm89n07.xml Spec Sections:B. Description:Tests Extender with an only legal per 5th edition character. The character #x3006 occurs as the second character in the PITarget in the PI in the prolog, and in an element name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/ibm89n07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn ibminvalid_p89ibm89n08xml() { /* Test ID:ibm-invalid-P89-ibm89n08.xml Test URI:ibm89n08.xml Spec Sections:B. Description:Tests Extender with an only legal per 5th edition character. The character #x3030 occurs as the second character in the PITarget in the PI in the prolog, and in an element name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/ibm89n08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn ibminvalid_p89ibm89n09xml() { /* Test ID:ibm-invalid-P89-ibm89n09.xml Test URI:ibm89n09.xml Spec Sections:B. Description:Tests Extender with an only legal per 5th edition character. The character #x3036 occurs as the second character in the PITarget in the PI in the prolog, and in an element name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/ibm89n09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn ibminvalid_p89ibm89n10xml() { /* Test ID:ibm-invalid-P89-ibm89n10.xml Test URI:ibm89n10.xml Spec Sections:B. Description:Tests Extender with an only legal per 5th edition character. The character #x309C occurs as the second character in the PITarget in the PI in the prolog, and in an element name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/ibm89n10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn ibminvalid_p89ibm89n11xml() { /* Test ID:ibm-invalid-P89-ibm89n11.xml Test URI:ibm89n11.xml Spec Sections:B. Description:Tests Extender with an only legal per 5th edition character. The character #x309F occurs as the second character in the PITarget in the PI in the prolog, and in an element name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/ibm89n11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); } #[test] #[ignore] fn ibminvalid_p89ibm89n12xml() { /* Test ID:ibm-invalid-P89-ibm89n12.xml Test URI:ibm89n12.xml Spec Sections:B. Description:Tests Extender with an only legal per 5th edition character. The character #x30FF occurs as the second character in the PITarget in the PI in the prolog, and in an element name. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/ibm89n12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_ok()); let doc = parseresult.unwrap(); let validation = doc.validate(Schema::DTD); assert!(validation.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/eduni_namespaces_11_notwf.rs
tests/conformance/xml/eduni_namespaces_11_notwf.rs
/* Richard Tobin's XML Namespaces 1.1 test suite 14 Feb 2003 */ use std::fs; use xrust::item::Node; use xrust::parser::xml; use xrust::trees::smite::RNode; #[test] fn rmtns11005() { /* Test ID:rmt-ns11-005 Test URI:005.xml Spec Sections:5 Description:Illegal use of prefix that has been unbound */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/005.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn htbhns11007() { /* Test ID:ht-bh-ns11-007 Test URI:007.xml Spec Sections:3 Description:Attempt to unbind xmlns 'namespace' */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/007.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn htbhns11008() { /* Test ID:ht-bh-ns11-008 Test URI:008.xml Spec Sections:3 Description:Attempt to unbind xml namespace */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/eduni/namespaces/1.1/008.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false
ballsteve/xrust
https://github.com/ballsteve/xrust/blob/4b8681166cc9894c2bf068afe79a8414d7a13970/tests/conformance/xml/sun_notwf.rs
tests/conformance/xml/sun_notwf.rs
/* Sun Microsystems test cases */ use crate::conformance::dtdfileresolve; use std::fs; use xrust::item::Node; use xrust::parser::{xml, ParserConfig}; use xrust::trees::smite::RNode; #[test] fn notwfsa03() { /* Test ID:not-wf-sa03 Test URI:not-wf/not-sa03.xml Spec Sections:2.9 Description:Tests the Entity Declared WFC, ensuring that a reference to externally defined entity causes a well-formedness error. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/not-sa03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist01() { /* Test ID:attlist01 Test URI:not-wf/attlist01.xml Spec Sections:3.3.1 [56] Description:SGML's NUTOKEN is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist02() { /* Test ID:attlist02 Test URI:not-wf/attlist02.xml Spec Sections:3.3.1 [56] Description:SGML's NUTOKENS attribute type is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist03() { /* Test ID:attlist03 Test URI:not-wf/attlist03.xml Spec Sections:3.3.1 [59] Description:Comma doesn't separate enumerations, unlike in SGML. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist04() { /* Test ID:attlist04 Test URI:not-wf/attlist04.xml Spec Sections:3.3.1 [56] Description:SGML's NUMBER attribute type is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist05() { /* Test ID:attlist05 Test URI:not-wf/attlist05.xml Spec Sections:3.3.1 [56] Description:SGML's NUMBERS attribute type is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist06() { /* Test ID:attlist06 Test URI:not-wf/attlist06.xml Spec Sections:3.3.1 [56] Description:SGML's NAME attribute type is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist07() { /* Test ID:attlist07 Test URI:not-wf/attlist07.xml Spec Sections:3.3.1 [56] Description:SGML's NAMES attribute type is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist08() { /* Test ID:attlist08 Test URI:not-wf/attlist08.xml Spec Sections:3.3.1 [56] Description:SGML's #CURRENT is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist09() { /* Test ID:attlist09 Test URI:not-wf/attlist09.xml Spec Sections:3.3.1 [56] Description:SGML's #CONREF is not allowed. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist10() { /* Test ID:attlist10 Test URI:not-wf/attlist10.xml Spec Sections:3.1 [40] Description:Whitespace required between attributes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn attlist11() { /* Test ID:attlist11 Test URI:not-wf/attlist11.xml Spec Sections:3.1 [44] Description:Whitespace required between attributes */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/attlist11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn cond01() { /* Test ID:cond01 Test URI:not-wf/cond01.xml Spec Sections:3.4 [61] Description:Only INCLUDE and IGNORE are conditional section keywords */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/sun/not-wf/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/cond01.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn cond02() { /* Test ID:cond02 Test URI:not-wf/cond02.xml Spec Sections:3.4 [61] Description:Must have keyword in conditional sections */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/sun/not-wf/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/cond02.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn content01() { /* Test ID:content01 Test URI:not-wf/content01.xml Spec Sections:3.2.1 [48] Description:No whitespace before "?" in content model */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/content01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn content02() { /* Test ID:content02 Test URI:not-wf/content02.xml Spec Sections:3.2.1 [48] Description:No whitespace before "*" in content model */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/content02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn content03() { /* Test ID:content03 Test URI:not-wf/content03.xml Spec Sections:3.2.1 [48] Description:No whitespace before "+" in content model */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/content03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn decl01() { /* Test ID:decl01 Test URI:not-wf/decl01.xml Spec Sections:4.3.1 [77] Description:External entities may not have standalone decls. */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/decl01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn nwfdtd00() { /* Test ID:nwf-dtd00 Test URI:not-wf/dtd00.xml Spec Sections:3.2.1 [55] Description:Comma mandatory in content model */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/dtd00.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn nwfdtd01() { /* Test ID:nwf-dtd01 Test URI:not-wf/dtd01.xml Spec Sections:3.2.1 [55] Description:Can't mix comma and vertical bar in content models */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/dtd01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn dtd02() { /* Test ID:dtd02 Test URI:not-wf/dtd02.xml Spec Sections:4.1 [69] Description:PE name immediately after "%" */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/dtd02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn dtd03() { /* Test ID:dtd03 Test URI:not-wf/dtd03.xml Spec Sections:4.1 [69] Description:PE name immediately followed by ";" */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/dtd03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn dtd04() { /* Test ID:dtd04 Test URI:not-wf/dtd04.xml Spec Sections:4.2.2 [75] Description:PUBLIC literal must be quoted */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/dtd04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn dtd05() { /* Test ID:dtd05 Test URI:not-wf/dtd05.xml Spec Sections:4.2.2 [75] Description:SYSTEM identifier must be quoted */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/dtd05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn dtd07() { /* Test ID:dtd07 Test URI:not-wf/dtd07.xml Spec Sections:4.3.1 [77] Description: Text declarations (which optionally begin any external entity) are required to have "encoding=...". */ let mut pc = ParserConfig::new(); pc.ext_dtd_resolver = Some(dtdfileresolve()); pc.docloc = Some("tests/conformance/xml/xmlconf/sun/not-wf/".to_string()); let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/dtd07.xml") .unwrap() .as_str(), Some(pc), ); assert!(parseresult.is_err()); } #[test] fn element00() { /* Test ID:element00 Test URI:not-wf/element00.xml Spec Sections:3.1 [42] Description:EOF in middle of incomplete ETAG */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/element00.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn element01() { /* Test ID:element01 Test URI:not-wf/element01.xml Spec Sections:3.1 [42] Description:EOF in middle of incomplete ETAG */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/element01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn element02() { /* Test ID:element02 Test URI:not-wf/element02.xml Spec Sections:3.1 [43] Description:Illegal markup (<%@ ... %>) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/element02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn element03() { /* Test ID:element03 Test URI:not-wf/element03.xml Spec Sections:3.1 [43] Description:Illegal markup (<% ... %>) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/element03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn element04() { /* Test ID:element04 Test URI:not-wf/element04.xml Spec Sections:3.1 [43] Description:Illegal markup (<!ELEMENT ... >) */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/element04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn encoding01() { /* Test ID:encoding01 Test URI:not-wf/encoding01.xml Spec Sections:4.3.3 [81] Description:Illegal character " " in encoding name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/encoding01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn encoding02() { /* Test ID:encoding02 Test URI:not-wf/encoding02.xml Spec Sections:4.3.3 [81] Description:Illegal character "/" in encoding name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/encoding02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn encoding03() { /* Test ID:encoding03 Test URI:not-wf/encoding03.xml Spec Sections:4.3.3 [81] Description:Illegal character reference in encoding name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/encoding03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn encoding04() { /* Test ID:encoding04 Test URI:not-wf/encoding04.xml Spec Sections:4.3.3 [81] Description:Illegal character ":" in encoding name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/encoding04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn encoding05() { /* Test ID:encoding05 Test URI:not-wf/encoding05.xml Spec Sections:4.3.3 [81] Description:Illegal character "@" in encoding name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/encoding05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn encoding06() { /* Test ID:encoding06 Test URI:not-wf/encoding06.xml Spec Sections:4.3.3 [81] Description:Illegal character "+" in encoding name */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/encoding06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn encoding07() { /* Test ID:encoding07 Test URI:not-wf/encoding07.xml Spec Sections:4.3.1 [77] Description:Text declarations (which optionally begin any external entity)are required to have "encoding=...". */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/encoding07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn pi() { /* Test ID:pi Test URI:not-wf/pi.xml Spec Sections:2.6 [16] Description:No space between PI target name and data */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/pi.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn pubid01() { /* Test ID:pubid01 Test URI:not-wf/pubid01.xml Spec Sections:2.3 [12] Description:Illegal entity ref in public ID */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/pubid01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn pubid02() { /* Test ID:pubid02 Test URI:not-wf/pubid02.xml Spec Sections:2.3 [12] Description:Illegal characters in public ID */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/pubid02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn pubid03() { /* Test ID:pubid03 Test URI:not-wf/pubid03.xml Spec Sections:2.3 [12] Description:Illegal characters in public ID */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/pubid03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn pubid04() { /* Test ID:pubid04 Test URI:not-wf/pubid04.xml Spec Sections:2.3 [12] Description:Illegal characters in public ID */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/pubid04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn pubid05() { /* Test ID:pubid05 Test URI:not-wf/pubid05.xml Spec Sections:2.3 [12] Description:SGML-ism: public ID without system ID */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/pubid05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml01() { /* Test ID:sgml01 Test URI:not-wf/sgml01.xml Spec Sections:3 [39] Description:SGML-ism: omitted end tag for EMPTY content */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml01.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml02() { /* Test ID:sgml02 Test URI:not-wf/sgml02.xml Spec Sections:2.8 Description:XML declaration must be at the very beginning of a document;it"s not a processing instruction */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml02.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml03() { /* Test ID:sgml03 Test URI:not-wf/sgml03.xml Spec Sections:2.5 [15] Description:Comments may not contain "--" */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml03.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml04() { /* Test ID:sgml04 Test URI:not-wf/sgml04.xml Spec Sections:3.3 [52] Description:ATTLIST declarations apply to only one element, unlike SGML */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml04.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml05() { /* Test ID:sgml05 Test URI:not-wf/sgml05.xml Spec Sections:3.2 [45] Description:ELEMENT declarations apply to only one element, unlike SGML */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml05.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml06() { /* Test ID:sgml06 Test URI:not-wf/sgml06.xml Spec Sections:3.3 [52] Description:ATTLIST declarations are never global, unlike in SGML */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml06.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml07() { /* Test ID:sgml07 Test URI:not-wf/sgml07.xml Spec Sections:3.2 [45] Description:SGML Tag minimization specifications are not allowed */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml07.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml08() { /* Test ID:sgml08 Test URI:not-wf/sgml08.xml Spec Sections:3.2 [45] Description:SGML Tag minimization specifications are not allowed */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml08.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml09() { /* Test ID:sgml09 Test URI:not-wf/sgml09.xml Spec Sections:3.2 [45] Description:SGML Content model exception specifications are not allowed */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml09.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml10() { /* Test ID:sgml10 Test URI:not-wf/sgml10.xml Spec Sections:3.2 [45] Description:SGML Content model exception specifications are not allowed */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml10.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml11() { /* Test ID:sgml11 Test URI:not-wf/sgml11.xml Spec Sections:3.2 [46] Description:CDATA is not a valid content model spec */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml11.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml12() { /* Test ID:sgml12 Test URI:not-wf/sgml12.xml Spec Sections:3.2 [46] Description:RCDATA is not a valid content model spec */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml12.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); } #[test] fn sgml13() { /* Test ID:sgml13 Test URI:not-wf/sgml13.xml Spec Sections:3.2.1 [47] Description:SGML Unordered content models not allowed */ let testxml = RNode::new_document(); let parseresult = xml::parse( testxml, fs::read_to_string("tests/conformance/xml/xmlconf/sun/not-wf/sgml13.xml") .unwrap() .as_str(), None, ); assert!(parseresult.is_err()); }
rust
Apache-2.0
4b8681166cc9894c2bf068afe79a8414d7a13970
2026-01-04T20:23:44.719720Z
false