Skip to content

Commit 6f9c636

Browse files
committed
Remove deprecated items (TODO: edit changelog after release 0.39)
1 parent 646ce4b commit 6f9c636

File tree

3 files changed

+5
-261
lines changed

3 files changed

+5
-261
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@
2525
of `NsReader`. Use `.resolver().bindings()` and `.resolver().resolve()` methods instead.
2626
- [#913]: `Attributes::has_nil` now accepts `NamespaceResolver` instead of `Reader<R>`.
2727

28+
- [#914]: Remove deprecated `.prefixes()`, `.resolve()`, `.resolve_attribute()`, and `.resolve_element()`
29+
of `NsReader`. Use `.resolver().<...>` methods instead.
30+
2831
[#908]: https://github.com/tafia/quick-xml/pull/908
2932
[#913]: https://github.com/tafia/quick-xml/pull/913
33+
[#914]: https://github.com/tafia/quick-xml/pull/914
3034

3135

3236
## 0.38.4 -- 2025-11-11

src/name.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,6 @@ impl<'a> Iterator for NamespaceBindingsIter<'a> {
10811081

10821082
impl<'a> FusedIterator for NamespaceBindingsIter<'a> {}
10831083

1084-
/// The previous name for [`NamespaceBindingsIter`].
1085-
#[deprecated = "Use NamespaceBindingsIter instead. This alias will be removed in 0.40.0"]
1086-
pub type PrefixIter<'a> = NamespaceBindingsIter<'a>;
1087-
10881084
/// Iterator on the declared namespace bindings on specified level. Returns pairs of the _(prefix, namespace)_.
10891085
///
10901086
/// See [`NamespaceResolver::bindings_of`] for documentation.

src/reader/ns_reader.rs

Lines changed: 1 addition & 257 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::path::Path;
1212

1313
use crate::errors::Result;
1414
use crate::events::Event;
15-
use crate::name::{LocalName, NamespaceBindingsIter, NamespaceResolver, QName, ResolveResult};
15+
use crate::name::{NamespaceResolver, QName, ResolveResult};
1616
use crate::reader::{Config, Reader, Span, XmlSource};
1717

1818
/// A low level encoding-agnostic XML event reader that performs namespace resolution.
@@ -49,91 +49,6 @@ impl<R> NsReader<R> {
4949
pub fn config_mut(&mut self) -> &mut Config {
5050
self.reader.config_mut()
5151
}
52-
53-
/// Returns all the prefixes currently declared except the default `xml` and `xmlns` namespaces.
54-
///
55-
/// # Examples
56-
///
57-
/// This example shows what results the returned iterator would return after
58-
/// reading each event of a simple XML.
59-
///
60-
/// ```
61-
/// # use pretty_assertions::assert_eq;
62-
/// use quick_xml::name::{Namespace, PrefixDeclaration};
63-
/// use quick_xml::NsReader;
64-
///
65-
/// let src = "<root>
66-
/// <a xmlns=\"a1\" xmlns:a=\"a2\">
67-
/// <b xmlns=\"b1\" xmlns:b=\"b2\">
68-
/// <c/>
69-
/// </b>
70-
/// <d/>
71-
/// </a>
72-
/// </root>";
73-
/// let mut reader = NsReader::from_str(src);
74-
/// reader.config_mut().trim_text(true);
75-
/// // No prefixes at the beginning
76-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![]);
77-
///
78-
/// reader.read_resolved_event()?; // <root>
79-
/// // No prefixes declared on root
80-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![]);
81-
///
82-
/// reader.read_resolved_event()?; // <a>
83-
/// // Two prefixes declared on "a"
84-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![
85-
/// (PrefixDeclaration::Default, Namespace(b"a1")),
86-
/// (PrefixDeclaration::Named(b"a"), Namespace(b"a2"))
87-
/// ]);
88-
///
89-
/// reader.read_resolved_event()?; // <b>
90-
/// // The default prefix got overridden and new "b" prefix
91-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![
92-
/// (PrefixDeclaration::Named(b"a"), Namespace(b"a2")),
93-
/// (PrefixDeclaration::Default, Namespace(b"b1")),
94-
/// (PrefixDeclaration::Named(b"b"), Namespace(b"b2"))
95-
/// ]);
96-
///
97-
/// reader.read_resolved_event()?; // <c/>
98-
/// // Still the same
99-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![
100-
/// (PrefixDeclaration::Named(b"a"), Namespace(b"a2")),
101-
/// (PrefixDeclaration::Default, Namespace(b"b1")),
102-
/// (PrefixDeclaration::Named(b"b"), Namespace(b"b2"))
103-
/// ]);
104-
///
105-
/// reader.read_resolved_event()?; // </b>
106-
/// // Still the same
107-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![
108-
/// (PrefixDeclaration::Named(b"a"), Namespace(b"a2")),
109-
/// (PrefixDeclaration::Default, Namespace(b"b1")),
110-
/// (PrefixDeclaration::Named(b"b"), Namespace(b"b2"))
111-
/// ]);
112-
///
113-
/// reader.read_resolved_event()?; // <d/>
114-
/// // </b> got closed so back to the prefixes declared on <a>
115-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![
116-
/// (PrefixDeclaration::Default, Namespace(b"a1")),
117-
/// (PrefixDeclaration::Named(b"a"), Namespace(b"a2"))
118-
/// ]);
119-
///
120-
/// reader.read_resolved_event()?; // </a>
121-
/// // Still the same
122-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![
123-
/// (PrefixDeclaration::Default, Namespace(b"a1")),
124-
/// (PrefixDeclaration::Named(b"a"), Namespace(b"a2"))
125-
/// ]);
126-
///
127-
/// reader.read_resolved_event()?; // </root>
128-
/// // <a> got closed
129-
/// assert_eq!(reader.prefixes().collect::<Vec<_>>(), vec![]);
130-
/// # quick_xml::Result::Ok(())
131-
/// ```
132-
#[inline]
133-
#[deprecated = "Use `.resolver().bindings()` instead. This method will be removed in 0.40.0"]
134-
pub const fn prefixes(&self) -> NamespaceBindingsIter<'_> {
135-
self.ns_resolver.bindings()
136-
}
13752
}
13853

13954
/// Private methods
@@ -207,177 +122,6 @@ impl<R> NsReader<R> {
207122
pub const fn resolver(&self) -> &NamespaceResolver {
208123
&self.ns_resolver
209124
}
210-
211-
/// Resolves a potentially qualified **element name** or **attribute name**
212-
/// into _(namespace name, local name)_.
213-
///
214-
/// _Qualified_ names have the form `local-name` or `prefix:local-name` where the `prefix`
215-
/// is defined on any containing XML element via `xmlns:prefix="the:namespace:uri"`.
216-
/// The namespace prefix can be defined on the same element as the name in question.
217-
///
218-
/// The method returns following results depending on the `name` shape, `attribute` flag
219-
/// and the presence of the default namespace on element or any of its parents:
220-
///
221-
/// |attribute|`xmlns="..."`|QName |ResolveResult |LocalName
222-
/// |---------|-------------|-------------------|-----------------------|------------
223-
/// |`true` |_(any)_ |`local-name` |[`Unbound`] |`local-name`
224-
/// |`true` |_(any)_ |`prefix:local-name`|[`Bound`] / [`Unknown`]|`local-name`
225-
/// |`false` |Not defined |`local-name` |[`Unbound`] |`local-name`
226-
/// |`false` |Defined |`local-name` |[`Bound`] (to `xmlns`) |`local-name`
227-
/// |`false` |_(any)_ |`prefix:local-name`|[`Bound`] / [`Unknown`]|`local-name`
228-
///
229-
/// If you want to clearly indicate that name that you resolve is an element
230-
/// or an attribute name, you could use [`resolve_attribute()`] or [`resolve_element()`]
231-
/// methods.
232-
///
233-
/// # Lifetimes
234-
///
235-
/// - `'n`: lifetime of a name. Returned local name will be bound to the same
236-
/// lifetime as the name in question.
237-
/// - returned namespace name will be bound to the reader itself
238-
///
239-
/// [`Bound`]: ResolveResult::Bound
240-
/// [`Unbound`]: ResolveResult::Unbound
241-
/// [`Unknown`]: ResolveResult::Unknown
242-
/// [`resolve_attribute()`]: Self::resolve_attribute()
243-
/// [`resolve_element()`]: Self::resolve_element()
244-
#[inline]
245-
#[deprecated = "Use `.resolver().resolve()` instead. Note, that boolean argument should be inverted! This method will be removed in 0.40.0"]
246-
pub fn resolve<'n>(
247-
&self,
248-
name: QName<'n>,
249-
attribute: bool,
250-
) -> (ResolveResult<'_>, LocalName<'n>) {
251-
self.ns_resolver.resolve(name, !attribute)
252-
}
253-
254-
/// Resolves a potentially qualified **element name** into _(namespace name, local name)_.
255-
///
256-
/// _Qualified_ element names have the form `prefix:local-name` where the
257-
/// `prefix` is defined on any containing XML element via `xmlns:prefix="the:namespace:uri"`.
258-
/// The namespace prefix can be defined on the same element as the element
259-
/// in question.
260-
///
261-
/// _Unqualified_ elements inherits the current _default namespace_.
262-
///
263-
/// The method returns following results depending on the `name` shape and
264-
/// the presence of the default namespace:
265-
///
266-
/// |`xmlns="..."`|QName |ResolveResult |LocalName
267-
/// |-------------|-------------------|-----------------------|------------
268-
/// |Not defined |`local-name` |[`Unbound`] |`local-name`
269-
/// |Defined |`local-name` |[`Bound`] (default) |`local-name`
270-
/// |_any_ |`prefix:local-name`|[`Bound`] / [`Unknown`]|`local-name`
271-
///
272-
/// # Lifetimes
273-
///
274-
/// - `'n`: lifetime of an element name. Returned local name will be bound
275-
/// to the same lifetime as the name in question.
276-
/// - returned namespace name will be bound to the reader itself
277-
///
278-
/// # Examples
279-
///
280-
/// This example shows how you can resolve qualified name into a namespace.
281-
/// Note, that in the code like this you do not need to do that manually,
282-
/// because the namespace resolution result returned by the [`read_resolved_event()`].
283-
///
284-
/// ```
285-
/// # use pretty_assertions::assert_eq;
286-
/// use quick_xml::events::Event;
287-
/// use quick_xml::name::{Namespace, QName, ResolveResult::*};
288-
/// use quick_xml::reader::NsReader;
289-
///
290-
/// let mut reader = NsReader::from_str("<tag xmlns='root namespace'/>");
291-
///
292-
/// match reader.read_event().unwrap() {
293-
/// Event::Empty(e) => assert_eq!(
294-
/// reader.resolve_element(e.name()),
295-
/// (Bound(Namespace(b"root namespace")), QName(b"tag").into())
296-
/// ),
297-
/// _ => unreachable!(),
298-
/// }
299-
/// ```
300-
///
301-
/// [`Bound`]: ResolveResult::Bound
302-
/// [`Unbound`]: ResolveResult::Unbound
303-
/// [`Unknown`]: ResolveResult::Unknown
304-
/// [`read_resolved_event()`]: Self::read_resolved_event
305-
#[inline]
306-
#[deprecated = "Use `.resolver().resolve_element()` instead. This method will be removed in 0.40.0"]
307-
pub fn resolve_element<'n>(&self, name: QName<'n>) -> (ResolveResult<'_>, LocalName<'n>) {
308-
self.ns_resolver.resolve_element(name)
309-
}
310-
311-
/// Resolves a potentially qualified **attribute name** into _(namespace name, local name)_.
312-
///
313-
/// _Qualified_ attribute names have the form `prefix:local-name` where the
314-
/// `prefix` is defined on any containing XML element via `xmlns:prefix="the:namespace:uri"`.
315-
/// The namespace prefix can be defined on the same element as the attribute
316-
/// in question.
317-
///
318-
/// _Unqualified_ attribute names do *not* inherit the current _default namespace_.
319-
///
320-
/// The method returns following results depending on the `name` shape and
321-
/// the presence of the default namespace:
322-
///
323-
/// |`xmlns="..."`|QName |ResolveResult |LocalName
324-
/// |-------------|-------------------|-----------------------|------------
325-
/// |Not defined |`local-name` |[`Unbound`] |`local-name`
326-
/// |Defined |`local-name` |[`Unbound`] |`local-name`
327-
/// |_any_ |`prefix:local-name`|[`Bound`] / [`Unknown`]|`local-name`
328-
///
329-
/// # Lifetimes
330-
///
331-
/// - `'n`: lifetime of an attribute name. Returned local name will be bound
332-
/// to the same lifetime as the name in question.
333-
/// - returned namespace name will be bound to the reader itself
334-
///
335-
/// # Examples
336-
///
337-
/// ```
338-
/// # use pretty_assertions::assert_eq;
339-
/// use quick_xml::events::Event;
340-
/// use quick_xml::name::{Namespace, QName, ResolveResult::*};
341-
/// use quick_xml::reader::NsReader;
342-
///
343-
/// let mut reader = NsReader::from_str("
344-
/// <tag one='1'
345-
/// p:two='2'
346-
/// xmlns='root namespace'
347-
/// xmlns:p='other namespace'/>
348-
/// ");
349-
/// reader.config_mut().trim_text(true);
350-
///
351-
/// match reader.read_event().unwrap() {
352-
/// Event::Empty(e) => {
353-
/// let mut iter = e.attributes();
354-
///
355-
/// // Unlike elements, attributes without explicit namespace
356-
/// // not bound to any namespace
357-
/// let one = iter.next().unwrap().unwrap();
358-
/// assert_eq!(
359-
/// reader.resolve_attribute(one.key),
360-
/// (Unbound, QName(b"one").into())
361-
/// );
362-
///
363-
/// let two = iter.next().unwrap().unwrap();
364-
/// assert_eq!(
365-
/// reader.resolve_attribute(two.key),
366-
/// (Bound(Namespace(b"other namespace")), QName(b"two").into())
367-
/// );
368-
/// }
369-
/// _ => unreachable!(),
370-
/// }
371-
/// ```
372-
///
373-
/// [`Bound`]: ResolveResult::Bound
374-
/// [`Unbound`]: ResolveResult::Unbound
375-
/// [`Unknown`]: ResolveResult::Unknown
376-
#[inline]
377-
#[deprecated = "Use `.resolver().resolve_attribute()` instead. This method will be removed in 0.40.0"]
378-
pub fn resolve_attribute<'n>(&self, name: QName<'n>) -> (ResolveResult<'_>, LocalName<'n>) {
379-
self.ns_resolver.resolve_attribute(name)
380-
}
381125
}
382126

383127
impl<R: BufRead> NsReader<R> {

0 commit comments

Comments
 (0)