Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10921] [XMLElement] Incorrect behavior of addNamespace(_:) & var xmlString with SwiftFoundation. #3304

Closed
YOCKOW opened this issue Jun 12, 2019 · 2 comments
Assignees

Comments

@YOCKOW
Copy link
Collaborator

YOCKOW commented Jun 12, 2019

Previous ID SR-10921
Radar None
Original Reporter @YOCKOW
Type Bug
Status Resolved
Resolution Done
Environment

macOS Mojave 10.14.5
Ubuntu 18.04
Swift 5.0.1

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @YOCKOW
Priority Medium

md5: f7b4a550f3942ba9fa7b163190f64d8d

Issue Description:

As you can see the following code, the behavior on Linux seems strange.

import Foundation

let element = XMLElement(name:"element")
let defaultNS = XMLNode.namespace(withName: "", stringValue: "https://default/ns") as! XMLNode
element.addNamespace(defaultNS)
print(element.xmlString)
// -> Prints "<element xmlns="https://default/ns"></element>" on macOS (DarwinFoundation).
// -> Prints "<:element></:element>" on Linux (SwiftFoundation).

let anotherElement = XMLElement(name:"anotherElem")
let anotherNS = XMLNode.namespace(withName: "anotherNS", stringValue: "https://another/ns") as! XMLNode
anotherElement.addNamespace(anotherNS)
print(anotherElement.xmlString)
// -> Prints "<anotherElem xmlns:anotherNS="https://another/ns"></anotherElem>" on macOS (DarwinFoundation).
// -> Prints "<anotherNS:anotherElem></anotherNS:anotherElem>" on Linux (SwiftFoundation).

let elementFromString = try! XMLElement(xmlString:#"<string xmlns="http://string/ns" xmlns:prefix="http://string/prefix" />"#)
print(elementFromString.xmlString)
// -> Prints "<string xmlns="http://string/ns" xmlns:prefix="http://string/prefix"></string>" on both OS.
@YOCKOW
Copy link
Collaborator Author

YOCKOW commented Jun 14, 2019

Opened PR#2343.

@YOCKOW
Copy link
Collaborator Author

YOCKOW commented Jul 24, 2019

Merged into master fe53405

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant