`preserveOrder: true` with `format: true`: output starts with a line break and has none at the end — intended?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 54/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- backend
Direzione di ricerca
Start with spec/j2x_ordered_spec.js and the toXml() formatting path mentioned in the issue. Compare the ordered and keyed outputs for the same input, including the case with ?xml, and check how the existing specs define the leading and trailing line breaks. Done means the intended behavior is decided and the output and specs agree.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
With format: true, the ordered mode and the keyed mode put line breaks in different places for the same document:
- The ordered mode starts the output with a line break and doesn't end it with one.
- The keyed mode starts directly with the root element and ends with a line break.
When the input starts with ?xml, the ordered mode writes no line break before the declaration. So the ordered mode isn't consistent with itself either. The top-level indentation in toXml() is the line break itself, and only ?xml is exempt from it (tempInd).
Code
import XMLBuilder from "fast-xml-builder"; // 1.3.1
const ordered = new XMLBuilder({ format: true, preserveOrder: true, ignoreAttributes: false });
const keyed = new XMLBuilder({ format: true });
ordered.build([{ root: [{ a: [{ "#text": "1" }] }] }]);
keyed.build({ root: { a: "1" } });
ordered.build([
{ "?xml": [], ":@": { "@_version": "1.0" } },
{ root: [{ a: [{ "#text": "1" }] }] },
]);
Output
"\n<root>\n <a>1</a>\n</root>"
"<root>\n <a>1</a>\n</root>\n"
"<?xml version=\"1.0\"?>\n<root>\n <a>1</a>\n</root>"
Question
Several specs expect the leading line break, for example "should build formatted XML" in spec/j2x_ordered_spec.js. So I'm not sure whether this is intended. Would you accept a change that makes the ordered mode behave like the keyed mode, either by default in a major version or behind an option? I'd be happy to open a PR.
Would you like to work on this issue?
- Yes
- No
- Lingua principale
- JavaScript
- Stelle
- 22
- Fork
- 9
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NaturalIntelligence/fast-xml-builder
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
-
`preserveOrder: true` with `format: true` formats mixed content wrongly and adds whitespace to content that ends with `>`Forse già presa @neumaennl l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
`XMLBuilder` object should be exported as a named export, not just the typeForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NaturalIntelligence/fast-xml-builder#25 · 1 commento ·
-
sanitizeName not applied to names inside stopNodes (quote injection / tag break-out bypass)Forse già presa @hicay l’ha presa 5 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
NaturalIntelligence/fast-xml-builder#34 · 1 commento ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
NaturalIntelligence/fast-xml-builder#4 · 5 commenti · 2 reazioni ·
Tutte le issue di NaturalIntelligence/fast-xml-builder
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
-
Extended search drops any query term that contains a line breakForse già presa @goranai l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
0.3.14: pdfmake.virtualfs renamed to sharedVirtualfs without changelog entry (breaking change)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
area:mcp
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno