@@ -352,7 +352,7 @@ struct TempAttributeData<'input> {
352
352
prefix : & ' input str ,
353
353
local : & ' input str ,
354
354
value : StringStorage < ' input > ,
355
- pos : usize ,
355
+ range : Range < usize > ,
356
356
}
357
357
358
358
impl < ' input > Document < ' input > {
@@ -644,8 +644,8 @@ impl<'input> tokenizer::XmlEvents<'input> for Context<'input> {
644
644
645
645
self . after_text = false ;
646
646
}
647
- tokenizer:: Token :: Attribute ( attr_start , prefix, local, value) => {
648
- process_attribute ( attr_start , prefix, local, value, self ) ?;
647
+ tokenizer:: Token :: Attribute ( range , prefix, local, value) => {
648
+ process_attribute ( range , prefix, local, value, self ) ?;
649
649
}
650
650
tokenizer:: Token :: ElementEnd ( end, range) => {
651
651
process_element ( end, range, self ) ?;
@@ -665,7 +665,7 @@ impl<'input> tokenizer::XmlEvents<'input> for Context<'input> {
665
665
666
666
#[ allow( clippy:: too_many_arguments) ]
667
667
fn process_attribute < ' input > (
668
- attr_pos : usize ,
668
+ range : Range < usize > ,
669
669
prefix : & ' input str ,
670
670
local : & ' input str ,
671
671
value : StrSpan < ' input > ,
@@ -676,7 +676,7 @@ fn process_attribute<'input>(
676
676
if prefix == XMLNS {
677
677
// The xmlns namespace MUST NOT be declared as the default namespace.
678
678
if value. as_str ( ) == NS_XMLNS_URI {
679
- let pos = ctx. err_pos_at ( attr_pos ) ;
679
+ let pos = ctx. err_pos_at ( range . start ) ;
680
680
return Err ( Error :: UnexpectedXmlnsUri ( pos) ) ;
681
681
}
682
682
@@ -687,13 +687,13 @@ fn process_attribute<'input>(
687
687
// It MUST NOT be bound to any other namespace name.
688
688
if local == NS_XML_PREFIX {
689
689
if !is_xml_ns_uri {
690
- let pos = ctx. err_pos_at ( attr_pos ) ;
690
+ let pos = ctx. err_pos_at ( range . start ) ;
691
691
return Err ( Error :: InvalidXmlPrefixUri ( pos) ) ;
692
692
}
693
693
} else {
694
694
// The xml namespace MUST NOT be bound to a non-xml prefix.
695
695
if is_xml_ns_uri {
696
- let pos = ctx. err_pos_at ( attr_pos ) ;
696
+ let pos = ctx. err_pos_at ( range . start ) ;
697
697
return Err ( Error :: UnexpectedXmlUri ( pos) ) ;
698
698
}
699
699
}
@@ -704,7 +704,7 @@ fn process_attribute<'input>(
704
704
. namespaces
705
705
. exists ( ctx. namespace_start_idx , Some ( local) )
706
706
{
707
- let pos = ctx. err_pos_at ( attr_pos ) ;
707
+ let pos = ctx. err_pos_at ( range . start ) ;
708
708
return Err ( Error :: DuplicatedNamespace ( local. to_string ( ) , pos) ) ;
709
709
}
710
710
@@ -715,13 +715,13 @@ fn process_attribute<'input>(
715
715
} else if local == XMLNS {
716
716
// The xml namespace MUST NOT be declared as the default namespace.
717
717
if value. as_str ( ) == NS_XML_URI {
718
- let pos = ctx. err_pos_at ( attr_pos ) ;
718
+ let pos = ctx. err_pos_at ( range . start ) ;
719
719
return Err ( Error :: UnexpectedXmlUri ( pos) ) ;
720
720
}
721
721
722
722
// The xmlns namespace MUST NOT be declared as the default namespace.
723
723
if value. as_str ( ) == NS_XMLNS_URI {
724
- let pos = ctx. err_pos_at ( attr_pos ) ;
724
+ let pos = ctx. err_pos_at ( range . start ) ;
725
725
return Err ( Error :: UnexpectedXmlnsUri ( pos) ) ;
726
726
}
727
727
@@ -731,7 +731,7 @@ fn process_attribute<'input>(
731
731
prefix,
732
732
local,
733
733
value,
734
- pos : attr_pos ,
734
+ range ,
735
735
} ) ;
736
736
}
737
737
@@ -888,7 +888,7 @@ fn resolve_attributes(namespaces: ShortRange, ctx: &mut Context) -> Result<Short
888
888
// always has no value.'
889
889
None
890
890
} else {
891
- get_ns_idx_by_prefix ( namespaces, attr. pos , attr. prefix , ctx) ?
891
+ get_ns_idx_by_prefix ( namespaces, attr. range . start , attr. prefix , ctx) ?
892
892
} ;
893
893
894
894
let attr_name = ExpandedNameIndexed {
@@ -900,15 +900,15 @@ fn resolve_attributes(namespaces: ShortRange, ctx: &mut Context) -> Result<Short
900
900
if ctx. doc . attributes [ start_idx..] . iter ( ) . any ( |attr| {
901
901
attr. name . as_expanded_name ( & ctx. doc ) == attr_name. as_expanded_name ( & ctx. doc )
902
902
} ) {
903
- let pos = ctx. err_pos_at ( attr. pos ) ;
903
+ let pos = ctx. err_pos_at ( attr. range . start ) ;
904
904
return Err ( Error :: DuplicatedAttribute ( attr. local . to_string ( ) , pos) ) ;
905
905
}
906
906
907
907
ctx. doc . attributes . push ( AttributeData {
908
908
name : attr_name,
909
909
value : attr. value ,
910
910
#[ cfg( feature = "positions" ) ]
911
- pos : attr. pos ,
911
+ range : attr. range ,
912
912
} ) ;
913
913
}
914
914
0 commit comments