Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions vendor/xslt-tests/filters
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@ attribute-0401
attribute-0501
attribute-0601
attribute-0701
attribute-0801
attribute-0803
attribute-0804
attribute-0805
Expand Down Expand Up @@ -756,7 +755,6 @@ axes-045
axes-046
axes-048
axes-049
axes-050
axes-051
axes-052
axes-057
Expand Down Expand Up @@ -1011,21 +1009,17 @@ bug-0701
bug-0801
bug-0901
bug-1001
bug-1101
bug-1201
bug-1202
bug-1203
bug-1301
bug-1401
bug-1402
bug-1403
bug-1405
bug-1406
bug-1501
bug-1601
bug-1701
bug-1801
bug-1802
bug-1901
bug-2001
bug-2101
Expand All @@ -1051,7 +1045,6 @@ bug-4001
bug-4301
bug-4401
bug-4501
bug-4601
bug-4701
bug-4702
bug-4703
Expand Down Expand Up @@ -1368,9 +1361,6 @@ copy-2801
copy-3001
copy-3002
copy-3003
copy-3102
copy-3301
copy-3302
copy-3501
copy-3601
copy-3602
Expand Down Expand Up @@ -1729,14 +1719,12 @@ element-0003
element-0004
element-0005
element-0006
element-0102
element-0104
element-0105
element-0106
element-0107
element-0108
element-0110
element-0111
element-0201
element-0301
element-0302
Expand Down Expand Up @@ -3223,7 +3211,6 @@ import-schema-060
import-schema-061
import-schema-062
import-schema-063
import-schema-064
import-schema-065
import-schema-066
import-schema-067
Expand Down Expand Up @@ -3647,20 +3634,13 @@ load-xquery-module-002
load-xquery-module-003
load-xquery-module-004
= lre
lre-003
lre-005
lre-006
lre-010
lre-011
lre-012
lre-014
lre-017
lre-018
lre-019
lre-020
lre-021
lre-022
lre-024
lre-025
lre-026
lre-027
Expand Down Expand Up @@ -4431,7 +4411,6 @@ mode-1905
= namespace
namespace-0101
namespace-0201
namespace-0202
namespace-0501
namespace-0601
namespace-0602
Expand All @@ -4442,7 +4421,6 @@ namespace-0802
namespace-0901
namespace-0902
namespace-0903
namespace-0904
namespace-0906
namespace-0907
namespace-0908
Expand All @@ -4453,7 +4431,6 @@ namespace-0912
namespace-0913
namespace-0914
namespace-1101
namespace-1102
namespace-1103
namespace-1104
namespace-1502
Expand All @@ -4464,13 +4441,10 @@ namespace-1801
namespace-1901
namespace-2001
namespace-2101
namespace-2201
namespace-2301
namespace-2302
namespace-2401
namespace-2501
namespace-2503
namespace-2601
namespace-2602
namespace-2606
namespace-2607
Expand All @@ -4479,9 +4453,7 @@ namespace-2609
namespace-2610
namespace-2611
namespace-2612
namespace-2614
namespace-2615
namespace-2616
namespace-2617
namespace-2618
namespace-2619
Expand All @@ -4502,8 +4474,6 @@ namespace-2701
namespace-2801
namespace-2901
namespace-3002
namespace-3003
namespace-3004
namespace-3101
namespace-3102
namespace-3103
Expand All @@ -4523,31 +4493,18 @@ namespace-3116
namespace-3117
namespace-3118
namespace-3119
namespace-3120
namespace-3121
namespace-3122
namespace-3123
namespace-3124
namespace-3126
namespace-3127
namespace-3128
namespace-3129
namespace-3130
namespace-3131
namespace-3132
namespace-3133
namespace-3134
namespace-3135
namespace-3136
namespace-3137
namespace-3138
namespace-3139
namespace-3140
namespace-3142
namespace-3143
namespace-3144
namespace-3145
namespace-3146
namespace-3147
namespace-3148
namespace-3149
Expand All @@ -4557,63 +4514,37 @@ namespace-3152
namespace-3153
namespace-3154
namespace-3155
namespace-3158
namespace-3159
namespace-3160
namespace-3161
namespace-3162
namespace-3163
namespace-3164
namespace-3201
namespace-3202
namespace-3203
namespace-3301
namespace-3302
namespace-3303
namespace-3304
namespace-3306
namespace-3307
namespace-3308
namespace-3309
namespace-3310
namespace-3311
namespace-3312
namespace-3313
namespace-3314
namespace-3315
namespace-3401
namespace-3501
namespace-3502
namespace-3503
namespace-3504
namespace-3505
namespace-3601
namespace-4001
namespace-4002
namespace-4003
namespace-4004
namespace-4005
namespace-4007
namespace-4008
namespace-4009
namespace-4301
namespace-4302
namespace-4401
namespace-4501
namespace-4601
namespace-4801
namespace-4901
namespace-5001
namespace-5101
namespace-5201
namespace-5601
namespace-5602
namespace-5701
namespace-5901
namespace-5902
namespace-5903
namespace-6002
namespace-6003
namespace-6201
namespace-6202
= namespace-alias
Expand Down Expand Up @@ -13619,7 +13550,6 @@ xml-to-json-D511
= xml-version
xml-version-002
xml-version-003
xml-version-006
xml-version-007
xml-version-008
xml-version-009
Expand Down Expand Up @@ -13678,7 +13608,6 @@ xpath-default-namespace-0107
xpath-default-namespace-0108
xpath-default-namespace-0201
xpath-default-namespace-0202
xpath-default-namespace-0301
xpath-default-namespace-0401
xpath-default-namespace-0501
xpath-default-namespace-0502
Expand Down
23 changes: 23 additions & 0 deletions xee-interpreter/src/sequence/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,35 @@ pub(crate) fn serialize_sequence(
}
}

/// Namespace fixup on a normalized document: constructed elements and
/// attributes can use a namespace that has no prefix binding anywhere in
/// the tree; invent prefixes for these so the result can be serialized.
/// The document can have multiple top-level elements, and each is fixed
/// up separately.
fn namespace_fixup(xot: &mut Xot, node: xot::Node) -> Result<(), error::Error> {
let xml_prefix = xot.xml_prefix();
let xml_namespace = xot.xml_namespace();
let elements: Vec<_> = xot
.children(node)
.filter(|child| xot.is_element(*child))
.collect();
for element in elements {
// bind the implicit xml prefix explicitly so create_missing_prefixes
// doesn't invent a prefix for it; the binding is never serialized
xot.namespaces_mut(element)
.insert(xml_prefix, xml_namespace);
xot.create_missing_prefixes(element)?;
}
Ok(())
}

fn serialize_xml(
arg: &Sequence,
parameters: SerializationParameters,
xot: &mut Xot,
) -> Result<String, error::Error> {
let node = arg.normalize(&parameters.item_separator, xot)?;
namespace_fixup(xot, node)?;
let indentation = xot_indentation(&parameters, xot);
let cdata_section_elements = xot_names(&parameters.cdata_section_elements, xot);
let declaration = if !parameters.omit_xml_declaration {
Expand Down
21 changes: 2 additions & 19 deletions xee-xslt-ast/src/ast_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,6 @@ pub enum ExcludeResultPrefixes {
Prefixes(Vec<ExcludeResultPrefix>),
}

impl ExcludeResultPrefixes {
// TODO: This combine isn't good enough; it should take existing prefixes
// into account, which we do have on context
pub(crate) fn combine(&self, other: ExcludeResultPrefixes) -> Self {
match (self, other) {
(ExcludeResultPrefixes::All, _) => ExcludeResultPrefixes::All,
(_, ExcludeResultPrefixes::All) => ExcludeResultPrefixes::All,
(
ExcludeResultPrefixes::Prefixes(prefixes),
ExcludeResultPrefixes::Prefixes(other_prefixes),
) => {
let mut prefixes = prefixes.clone();
prefixes.extend(other_prefixes);
ExcludeResultPrefixes::Prefixes(prefixes)
}
}
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub enum ExcludeResultPrefix {
Expand Down Expand Up @@ -1827,6 +1808,8 @@ pub type SequenceConstructor = Vec<SequenceConstructorItem>;
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct ElementNode {
pub name: Name,
/// prefix/namespace pairs this element declares in the result
pub namespaces: Vec<(String, String)>,
pub attributes: Vec<(Name, ValueTemplate<String>)>,
pub sequence_constructor: SequenceConstructor,
pub span: Span,
Expand Down
12 changes: 7 additions & 5 deletions xee-xslt-ast/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ impl<'a> Attributes<'a> {

pub(crate) fn with_standard(self) -> Result<Self, AttributeError> {
// create a new content has a context including standard attributes
let content = self.content.with_context(
self.content
.context
.with_standard(self.content.xot_namespaces(), self.standard()?),
);
let content = self
.content
.with_context(self.content.context.with_standard(
self.content.state,
self.content.xot_namespaces(),
self.standard()?,
));
// we now create a new attributes object that has the new content
Ok(Self { content, ..self })
}
Expand Down
Loading